diff options
author | Kevin McPhillips <github@kevinmcphillips.ca> | 2017-04-06 21:43:58 -0400 |
---|---|---|
committer | Kevin McPhillips <github@kevinmcphillips.ca> | 2017-04-07 10:06:40 -0400 |
commit | 06f45435da941d713afefd3140421d1ced7abbdc (patch) | |
tree | de536df446cc9c4b2d13d7abb106691e23fdf96e /activerecord/test | |
parent | e88e35804a017b10d93e7e9c6b5708a2273047df (diff) | |
download | rails-06f45435da941d713afefd3140421d1ced7abbdc.tar.gz rails-06f45435da941d713afefd3140421d1ced7abbdc.tar.bz2 rails-06f45435da941d713afefd3140421d1ced7abbdc.zip |
Passing in no arguments to the dynamic fixture accessor method returns all fixtures, not an empty array.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index 3720b0cc1a..a0a6d3c7ef 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -95,6 +95,24 @@ class FixturesTest < ActiveRecord::TestCase assert_nil(topics["second"]["author_email_address"]) end + def test_no_args_returns_all + all_topics = topics + assert_equal 5, all_topics.length + assert_equal "The First Topic", all_topics.first["title"] + assert_equal 5, all_topics.last.id + end + + def test_no_args_record_returns_all_without_array + all_binaries = binaries + assert_kind_of(Array, all_binaries) + assert_equal 1, binaries.length + end + + def test_nil_raises + assert_raise(StandardError) { topics(nil) } + assert_raise(StandardError) { topics([nil]) } + end + def test_inserts create_fixtures("topics") first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'") |