diff options
author | Marcel Molina <marcel@vernix.org> | 2006-01-22 09:34:41 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-01-22 09:34:41 +0000 |
commit | 297618bddc59cdc4aaca76711874b774f9838afe (patch) | |
tree | 0f7384d0dd89444b3b2f9ae9419b44925a9cee5d /activerecord/test | |
parent | 8d4d88a4f01ed7b569b62489654f585434beea3a (diff) | |
download | rails-297618bddc59cdc4aaca76711874b774f9838afe.tar.gz rails-297618bddc59cdc4aaca76711874b774f9838afe.tar.bz2 rails-297618bddc59cdc4aaca76711874b774f9838afe.zip |
Make dynamic finders honor additional passed in :conditions. Closes #3569.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3463 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/finder_test.rb | 15 | ||||
-rw-r--r-- | activerecord/test/fixtures/accounts.yml | 5 |
2 files changed, 19 insertions, 1 deletions
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index 515ec0f777..61d5c20e98 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -6,7 +6,7 @@ require 'fixtures/developer' require 'fixtures/post' class FinderTest < Test::Unit::TestCase - fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts + fixtures :companies, :topics, :entrants, :developers, :developers_projects, :posts, :accounts def test_find assert_equal(topics(:first).title, Topic.find(1).title) @@ -200,6 +200,19 @@ class FinderTest < Test::Unit::TestCase assert_nil Topic.find_by_title("The First Topic!") end + def test_find_by_one_attribute_with_order_option + assert_equal accounts(:signals37), Account.find_by_credit_limit(50) + assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :order => 'id DESC') + end + + def test_find_by_one_attribute_with_conditions + assert_equal accounts(:rails_core_account), Account.find_by_credit_limit(50, :conditions => ['firm_id = ?', 6]) + end + + def test_find_by_one_attribute_with_several_options + assert_equal accounts(:unknown), Account.find_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3]) + end + def test_find_by_one_missing_attribute assert_raises(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } end diff --git a/activerecord/test/fixtures/accounts.yml b/activerecord/test/fixtures/accounts.yml index 8cff4389fd..707c5d0a7f 100644 --- a/activerecord/test/fixtures/accounts.yml +++ b/activerecord/test/fixtures/accounts.yml @@ -11,3 +11,8 @@ rails_core_account: id: 3 firm_id: 6 credit_limit: 50 + +last_account: + id: 4 + firm_id: 2 + credit_limit: 60 |