From 6d10d64cbafe70e343cef0f94e015908b9348ac5 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Mon, 10 Jun 2013 13:52:22 +0200 Subject: fixture setup does not rely on `AR::Base.configurations`. As you can also configure your database connection using `ENV["DATABASE_URL"]`, the fixture setup can't reply on the `.configurations` Hash. As the fixtures are only loaded when ActiveRecord is actually used (`rails/test_help.rb`) it should be safe to drop the check for an existing configuration. --- activerecord/test/cases/fixtures_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'activerecord/test/cases/fixtures_test.rb') diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index f6cfee0cb8..df6edc4057 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -245,6 +245,22 @@ class FixturesTest < ActiveRecord::TestCase def test_serialized_fixtures assert_equal ["Green", "Red", "Orange"], traffic_lights(:uk).state end + + def test_fixtures_are_set_up_with_database_env_variable + ENV.stubs(:[]).with("DATABASE_URL").returns("sqlite3:///:memory:") + ActiveRecord::Base.stubs(:configurations).returns({}) + test_case = Class.new(ActiveRecord::TestCase) do + fixtures :accounts + + def test_fixtures + assert accounts(:signals37) + end + end + + result = test_case.new(:test_fixtures).run + + assert result.passed?, "Expected #{result.name} to pass:\n#{result}" + end end if Account.connection.respond_to?(:reset_pk_sequence!) -- cgit v1.2.3