aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
diff options
context:
space:
mode:
authorMaximilian Schneider <mail@maximilianschneider.net>2012-06-22 16:44:01 +0200
committerMaximilian Schneider <mail@maximilianschneider.net>2012-06-22 16:44:01 +0200
commitf984b8152fb497919b30c9c96e471e0736f3a6d2 (patch)
tree7d8d56d7e662157a2b6c7c965c42263ebdda5a97 /activerecord/test/cases/finder_test.rb
parent323ee207cbbcd66574045ebedd30765da10d3f6f (diff)
downloadrails-f984b8152fb497919b30c9c96e471e0736f3a6d2.tar.gz
rails-f984b8152fb497919b30c9c96e471e0736f3a6d2.tar.bz2
rails-f984b8152fb497919b30c9c96e471e0736f3a6d2.zip
made dynamic finders alias_attribute aware
previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
Diffstat (limited to 'activerecord/test/cases/finder_test.rb')
-rw-r--r--activerecord/test/cases/finder_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index df21585961..e62d984ebd 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -535,6 +535,11 @@ class FinderTest < ActiveRecord::TestCase
assert_raise(ActiveRecord::RecordNotFound) { Topic.find_by_title!("The First Topic!") }
end
+ def test_find_by_one_attribute_that_is_an_alias
+ assert_equal topics(:first), Topic.find_by_heading("The First Topic")
+ assert_nil Topic.find_by_heading("The First Topic!")
+ end
+
def test_find_by_one_attribute_with_conditions
assert_equal accounts(:rails_core_account), Account.where('firm_id = ?', 6).find_by_credit_limit(50)
end