Ticket #11413: add_first_and_last_aliases.diff
| File add_first_and_last_aliases.diff, 2.3 kB (added by thechrisoshow, 6 months ago) |
|---|
-
activerecord/test/cases/base_test.rb
old new 1625 1625 assert_equal last, Developer.find(:first, :order => 'id desc') 1626 1626 end 1627 1627 1628 def test_last 1629 assert_equal Developer.find(:first, :order => 'id desc'), Developer.last 1630 end 1631 1628 1632 def test_find_ordered_last 1629 1633 last = Developer.find :last, :order => 'developers.salary ASC' 1630 1634 assert_equal last, Developer.find(:all, :order => 'developers.salary ASC').last -
activerecord/test/cases/finder_test.rb
old new 143 143 first = Topic.find(:first, :conditions => "title = 'The First Topic!'") 144 144 assert_nil(first) 145 145 end 146 147 def test_first 148 assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title 149 end 150 151 def test_first_failing 152 assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'") 153 end 146 154 147 155 def test_unexisting_record_exception_handling 148 156 assert_raises(ActiveRecord::RecordNotFound) { -
activerecord/lib/active_record/base.rb
old new 511 511 else find_from_ids(args, options) 512 512 end 513 513 end 514 515 # This is an alias for find(:first). You can pass in all the same arguments to this method as you can 516 # to find(:first) 517 def first(*args) 518 find(:first, *args) 519 end 514 520 521 # This is an alias for find(:last). You can pass in all the same arguments to this method as you can 522 # to find(:last) 523 def last(*args) 524 find(:last, *args) 525 end 526 515 527 # 516 528 # Executes a custom sql query against your database and returns all the results. The results will 517 529 # be returned as an array with columns requested encapsulated as attributes of the model you call