diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-06-10 13:52:22 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-06-15 14:58:38 +0200 |
commit | 6d10d64cbafe70e343cef0f94e015908b9348ac5 (patch) | |
tree | ba2fda07a5f8508178f8fad2f1f38c10909dce37 /activerecord/test/cases | |
parent | be4fac3c0ce80b8a739bba21dba6ac6c1eca9987 (diff) | |
download | rails-6d10d64cbafe70e343cef0f94e015908b9348ac5.tar.gz rails-6d10d64cbafe70e343cef0f94e015908b9348ac5.tar.bz2 rails-6d10d64cbafe70e343cef0f94e015908b9348ac5.zip |
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.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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!) |