Skip to content
Browse files

Updated all references to the old find_first and find_all to use the …

…new style #1511 [Marcel Molina]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1520 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent ee4c834 commit 3dfa56ccfbdcaeba74273ace80cb752e6b716f87 @dhh dhh committed Jun 26, 2005
View
9 activerecord/lib/active_record/acts/list.rb
@@ -135,14 +135,14 @@ def last?
def higher_item
return nil unless in_list?
- self.class.find_first(
+ self.class.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i - 1).to_s}"
)
end
def lower_item
return nil unless in_list?
- self.class.find_first(
+ self.class.find(:first, :conditions =>
"#{scope_condition} AND #{position_column} = #{(send(position_column).to_i + 1).to_s}"
)
end
@@ -169,10 +169,7 @@ def bottom_position_in_list
end
def bottom_item
- self.class.find_first(
- "#{scope_condition} ",
- "#{position_column} DESC"
- )
+ self.class.find(:first, :conditions => scope_condition, :order => "#{position_column} DESC")
end
def assume_bottom_position
View
8 activerecord/lib/active_record/acts/nested_set.rb
@@ -181,17 +181,17 @@ def children_count
# Returns a set of itself and all of it's nested children
def full_set
- self.class.find_all( "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} and #{self[right_col_name]})" )
+ self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} BETWEEN #{self[left_col_name]} and #{self[right_col_name]})" )
end
# Returns a set of all of it's children and nested children
def all_children
- self.class.find_all( "#{scope_condition} AND (#{left_col_name} > #{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})" )
+ self.class.find(:all, :conditions => "#{scope_condition} AND (#{left_col_name} > #{self[left_col_name]}) and (#{right_col_name} < #{self[right_col_name]})" )
end
# Returns a set of only this entries immediate children
def direct_children
- self.class.find_all( "#{scope_condition} and #{parent_column} = #{self.id}")
+ self.class.find(:all, :conditions => "#{scope_condition} and #{parent_column} = #{self.id}")
end
# Prunes a branch off of the tree, shifting all of the elements on the right
@@ -209,4 +209,4 @@ def before_destroy
end
end
end
-end
+end
View
2 activerecord/lib/active_record/associations.rb
@@ -304,7 +304,7 @@ def has_many(association_id, options = {})
# with +attributes+ and linked to this object through a foreign key and that has already been saved (if it passed the validation).
#
# Example: An Account class declares <tt>has_one :beneficiary</tt>, which will add:
- # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find_first "account_id = #{id}"</tt>)
+ # * <tt>Account#beneficiary</tt> (similar to <tt>Beneficiary.find(:first, :conditions => "account_id = #{id}")</tt>)
# * <tt>Account#beneficiary=(beneficiary)</tt> (similar to <tt>beneficiary.account_id = account.id; beneficiary.save</tt>)
# * <tt>Account#beneficiary.nil?</tt>
# * <tt>Account#build_beneficiary</tt> (similar to <tt>Beneficiary.new("account_id" => id)</tt>)
View
14 activerecord/lib/active_record/base.rb
@@ -79,11 +79,11 @@ def initialize(errors)
#
# User < ActiveRecord::Base
# def self.authenticate_unsafely(user_name, password)
- # find_first("user_name = '#{user_name}' AND password = '#{password}'")
+ # find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'")
# end
#
# def self.authenticate_safely(user_name, password)
- # find_first([ "user_name = ? AND password = ?", user_name, password ])
+ # find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ])
# end
# end
#
@@ -362,7 +362,7 @@ def find(*args)
end
end
- # Works like find_all, but requires a complete SQL string. Examples:
+ # Works like find(:all), but requires a complete SQL string. Examples:
# Post.find_by_sql "SELECT p.*, c.author FROM posts p, comments c WHERE p.id = c.post_id"
# Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
def find_by_sql(sql)
@@ -426,7 +426,7 @@ def update_all(updates, conditions = nil)
# the destroy method. Example:
# Person.destroy_all "last_login < '2004-04-04'"
def destroy_all(conditions = nil)
- find_all(conditions).each { |object| object.destroy }
+ find(:all, :conditions => conditions).each { |object| object.destroy }
end
# Deletes all the records that matches the +condition+ without instantiating the objects first (and hence not
@@ -679,7 +679,7 @@ def sanitize(object) #:nodoc:
# Project.benchmark("Creating project") do
# project = Project.create("name" => "stuff")
# project.create_manager("name" => "David")
- # project.milestones << Milestone.find_all
+ # project.milestones << Milestone.find(:all)
# end
def benchmark(title)
result = nil
@@ -777,8 +777,8 @@ def undecorated_table_name(class_name = class_name_of_active_record_descendant(s
end
# Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into
- # find_first(["user_name = ?", user_name]) and find_first(["user_name = ? AND password = ?", user_name, password]) respectively. Also works
- # for find_all, but using find_all_by_amount(50) that are turned into find_all(["amount = ?", 50]).
+ # find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])
+ # respectively. Also works for find(:all), but using find_all_by_amount(50) that are turned into find(:all, :conditions => ["amount = ?", 50]).
#
# It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
# is actually find_all_by_amount(amount, options).
View
2 activerecord/lib/active_record/callbacks.rb
@@ -153,7 +153,7 @@ module ActiveRecord
#
# == The after_find and after_initialize exceptions
#
- # Because after_find and after_initialize is called for each object instantiated found by a finder, such as Base.find_all, we've had
+ # Because after_find and after_initialize is called for each object instantiated found by a finder, such as Base.find(:all), we've had
# to implement a simple performance constraint (50% more speed on a simple test case). Unlike all the other callbacks, after_find and
# after_initialize will only be run if an explicit implementation is defined (<tt>def after_find</tt>). In that case, all of the
# callback types will be called.
View
6 activerecord/lib/active_record/fixtures.rb
@@ -169,13 +169,13 @@
# fixtures :foos
#
# def test_godzilla
-# assert !Foo.find_all.emtpy?
+# assert !Foo.find(:all).empty?
# Foo.destroy_all
-# assert Foo.find_all.emtpy?
+# assert Foo.find(:all).empty?
# end
#
# def test_godzilla_aftermath
-# assert !Foo.find_all.emtpy?
+# assert !Foo.find(:all).empty?
# end
# end
#
View
4 activerecord/lib/active_record/validations.rb
@@ -465,11 +465,11 @@ def validates_uniqueness_of(*attr_names)
if scope = configuration[:scope]
validates_each(attr_names,configuration) do |record, attr_name, value|
- record.errors.add(attr_name, configuration[:message]) if record.class.find_first(record.new_record? ? ["#{attr_name} = ? AND #{scope} = ?", record.send(attr_name), record.send(scope)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ? AND #{scope} = ?", record.send(attr_name), record.send(:id), record.send(scope)])
+ record.errors.add(attr_name, configuration[:message]) if record.class.find(:first, :conditions => (record.new_record? ? ["#{attr_name} = ? AND #{scope} = ?", record.send(attr_name), record.send(scope)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ? AND #{scope} = ?", record.send(attr_name), record.send(:id), record.send(scope)]))
end
else
validates_each(attr_names,configuration) do |record, attr_name, value|
- record.errors.add(attr_name, configuration[:message]) if record.class.find_first(record.new_record? ? ["#{attr_name} = ?", record.send(attr_name)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ?", record.send(attr_name), record.send(:id) ] )
+ record.errors.add(attr_name, configuration[:message]) if record.class.find(:first, :conditions => (record.new_record? ? ["#{attr_name} = ?", record.send(attr_name)] : ["#{attr_name} = ? AND #{record.class.primary_key} <> ?", record.send(attr_name), record.send(:id) ] ))
end
end
end
View
48 activerecord/test/associations_test.rb
@@ -126,7 +126,7 @@ def test_dependence
firm = Firm.find(1)
assert !firm.account.nil?
firm.destroy
- assert_equal 1, Account.find_all.length
+ assert_equal 1, Account.count
end
def test_succesful_build_association
@@ -259,45 +259,45 @@ def force_signal37_to_load_all_clients_of_firm
end
def test_counting
- assert_equal 2, Firm.find_first.clients.count
+ assert_equal 2, Firm.find(:first).clients.count
end
def test_finding
- assert_equal 2, Firm.find_first.clients.length
+ assert_equal 2, Firm.find(:first).clients.length
end
def test_finding_default_orders
- assert_equal "Summit", Firm.find_first.clients.first.name
+ assert_equal "Summit", Firm.find(:first).clients.first.name
end
def test_finding_with_different_class_name_and_order
- assert_equal "Microsoft", Firm.find_first.clients_sorted_desc.first.name
+ assert_equal "Microsoft", Firm.find(:first).clients_sorted_desc.first.name
end
def test_finding_with_foreign_key
- assert_equal "Microsoft", Firm.find_first.clients_of_firm.first.name
+ assert_equal "Microsoft", Firm.find(:first).clients_of_firm.first.name
end
def test_finding_with_condition
- assert_equal "Microsoft", Firm.find_first.clients_like_ms.first.name
+ assert_equal "Microsoft", Firm.find(:first).clients_like_ms.first.name
end
def test_finding_using_sql
- firm = Firm.find_first
+ firm = Firm.find(:first)
first_client = firm.clients_using_sql.first
assert_not_nil first_client
assert_equal "Microsoft", first_client.name
assert_equal 1, firm.clients_using_sql.size
- assert_equal 1, Firm.find_first.clients_using_sql.size
+ assert_equal 1, Firm.find(:first).clients_using_sql.size
end
def test_counting_using_sql
- assert_equal 1, Firm.find_first.clients_using_counter_sql.size
- assert_equal 0, Firm.find_first.clients_using_zero_counter_sql.size
+ assert_equal 1, Firm.find(:first).clients_using_counter_sql.size
+ assert_equal 0, Firm.find(:first).clients_using_zero_counter_sql.size
end
def test_counting_non_existant_items_using_sql
- assert_equal 0, Firm.find_first.no_clients_using_counter_sql.size
+ assert_equal 0, Firm.find(:first).no_clients_using_counter_sql.size
end
def test_belongs_to_sanity
@@ -547,7 +547,7 @@ def test_dependence
end
def test_destroy_dependent_when_deleted_from_association
- firm = Firm.find_first
+ firm = Firm.find(:first)
assert_equal 2, firm.clients.size
client = firm.clients.first
@@ -579,17 +579,17 @@ def test_dependence_with_transaction_support_on_failure
end
def test_dependence_on_account
- assert_equal 2, Account.find_all.length
+ assert_equal 2, Account.count
companies(:first_firm).destroy
- assert_equal 1, Account.find_all.length
+ assert_equal 1, Account.count
end
def test_included_in_collection
assert companies(:first_firm).clients.include?(Client.find(2))
end
def test_adding_array_and_collection
- assert_nothing_raised { Firm.find_first.clients + Firm.find_all.last.clients }
+ assert_nothing_raised { Firm.find(:first).clients + Firm.find(:all).last.clients }
end
def test_find_all_without_conditions
@@ -598,15 +598,15 @@ def test_find_all_without_conditions
end
def test_replace_with_less
- firm = Firm.find_first
+ firm = Firm.find(:first)
firm.clients = [companies(:first_client)]
assert firm.save, "Could not save firm"
firm.reload
assert_equal 1, firm.clients.length
end
def test_replace_with_new
- firm = Firm.find_first
+ firm = Firm.find(:first)
new_client = Client.new("name" => "New Client")
firm.clients = [companies(:second_client),new_client]
firm.save
@@ -699,7 +699,7 @@ def test_belongs_to_counter
end
def test_assignment_before_parent_saved
- client = Client.find_first
+ client = Client.find(:first)
apple = Firm.new("name" => "Apple")
client.firm = apple
assert_equal apple, client.firm
@@ -738,15 +738,15 @@ def test_assignment_before_either_saved
def test_new_record_with_foreign_key_but_no_object
c = Client.new("firm_id" => 1)
- assert_equal Firm.find_first, c.firm_with_basic_id
+ assert_equal Firm.find(:first), c.firm_with_basic_id
end
def test_forgetting_the_load_when_foreign_key_enters_late
c = Client.new
assert_nil c.firm_with_basic_id
c.firm_id = 1
- assert_equal Firm.find_first, c.firm_with_basic_id
+ assert_equal Firm.find(:first), c.firm_with_basic_id
end
def test_field_name_same_as_foreign_key
@@ -764,7 +764,7 @@ def xtest_counter_cache
apple.companies_count = 2
apple.save
- apple = Firm.find_first("name = 'Apple'")
+ apple = Firm.find(:first, :conditions => "name = 'Apple'")
assert_equal 2, apple.clients.size, "Should use the new cached number"
apple.clients.to_s
@@ -966,7 +966,7 @@ def test_deleting
def test_deleting_array
david = Developer.find(1)
david.projects.reload
- david.projects.delete(Project.find_all)
+ david.projects.delete(Project.find(:all))
assert_equal 0, david.projects.size
assert_equal 0, david.projects(true).size
end
@@ -986,7 +986,7 @@ def test_deleting_array_with_sql
active_record.developers.reload
assert_equal 2, active_record.developers_by_sql.size
- active_record.developers_by_sql.delete(Developer.find_all)
+ active_record.developers_by_sql.delete(Developer.find(:all))
assert_equal 0, active_record.developers_by_sql(true).size
end
View
10 activerecord/test/base_test.rb
@@ -110,7 +110,7 @@ def test_update_array_content
end
def test_attributes_hash
- assert_equal @loaded_fixtures['projects']['active_record'].to_hash, Project.find_first.attributes
+ assert_equal @loaded_fixtures['projects']['active_record'].to_hash, Project.find(:first).attributes
end
def test_create
@@ -227,13 +227,13 @@ def test_initialize_with_invalid_attribute
end
def test_load
- topics = Topic.find_all nil, "id"
+ topics = Topic.find(:all, :order => 'id')
assert_equal(2, topics.size)
assert_equal(topics(:first).title, topics.first.title)
end
def test_load_with_condition
- topics = Topic.find_all "author_name = 'Mary'"
+ topics = Topic.find(:all, :conditions => "author_name = 'Mary'")
assert_equal(1, topics.size)
assert_equal(topics(:second).title, topics.first.title)
@@ -276,10 +276,10 @@ def test_table_name_guesses
end
def test_destroy_all
- assert_equal 2, Topic.find_all.size
+ assert_equal 2, Topic.count
Topic.destroy_all "author_name = 'Mary'"
- assert_equal 1, Topic.find_all.size
+ assert_equal 1, Topic.count
end
def test_destroy_many
View
2 activerecord/test/finder_test.rb
@@ -48,7 +48,7 @@ def test_find_all_with_limit
def test_find_all_with_prepared_limit_and_offset
if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
- assert_raises(ArgumentError) { Entrant.find_all nil, "id ASC", [2, 1] }
+ assert_raises(ArgumentError) { Entrant.find(:all, :order => 'id ASC', :limit => 2, :offset => 1) }
end
else
entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 1)
View
34 activerecord/test/inheritance_test.rb
@@ -23,7 +23,7 @@ def test_alt_inheritance_find
end
def test_inheritance_find_all
- companies = Company.find_all(nil, "id")
+ companies = Company.find(:all, :order => 'id')
assert companies[0].kind_of?(Firm), "37signals should be a firm"
assert companies[1].kind_of?(Client), "Summit should be a client"
end
@@ -48,9 +48,9 @@ def test_alt_inheritance_save
end
def test_inheritance_condition
- assert_equal 5, Company.find_all.length
- assert_equal 2, Firm.find_all.length
- assert_equal 3, Client.find_all.length
+ assert_equal 5, Company.count
+ assert_equal 2, Firm.count
+ assert_equal 3, Client.count
end
def test_alt_inheritance_condition
@@ -70,8 +70,8 @@ def test_alt_finding_incorrect_type_data
def test_update_all_within_inheritance
Client.update_all "name = 'I am a client'"
- assert_equal "I am a client", Client.find_all.first.name
- assert_equal "37signals", Firm.find_all.first.name
+ assert_equal "I am a client", Client.find(:all).first.name
+ assert_equal "37signals", Firm.find(:all).first.name
end
def test_alt_update_all_within_inheritance
@@ -81,8 +81,8 @@ def test_alt_update_all_within_inheritance
def test_destroy_all_within_inheritance
Client.destroy_all
- assert_equal 0, Client.find_all.length
- assert_equal 2, Firm.find_all.length
+ assert_equal 0, Client.count
+ assert_equal 2, Firm.count
end
def test_alt_destroy_all_within_inheritance
@@ -91,9 +91,9 @@ def test_alt_destroy_all_within_inheritance
end
def test_find_first_within_inheritance
- assert_kind_of Firm, Company.find_first("name = '37signals'")
- assert_kind_of Firm, Firm.find_first("name = '37signals'")
- assert_nil Client.find_first("name = '37signals'")
+ assert_kind_of Firm, Company.find(:first, :conditions => "name = '37signals'")
+ assert_kind_of Firm, Firm.find(:first, :conditions => "name = '37signals'")
+ assert_nil Client.find(:first, :conditions => "name = '37signals'")
end
def test_alt_find_first_within_inheritance
@@ -103,11 +103,11 @@ def test_alt_find_first_within_inheritance
def test_complex_inheritance
very_special_client = VerySpecialClient.create("name" => "veryspecial")
- assert_equal very_special_client, VerySpecialClient.find_first("name = 'veryspecial'")
- assert_equal very_special_client, SpecialClient.find_first("name = 'veryspecial'")
- assert_equal very_special_client, Company.find_first("name = 'veryspecial'")
- assert_equal very_special_client, Client.find_first("name = 'veryspecial'")
- assert_equal 1, Client.find_all("name = 'Summit'").size
+ assert_equal very_special_client, VerySpecialClient.find(:first, :conditions => "name = 'veryspecial'")
+ assert_equal very_special_client, SpecialClient.find(:first, :conditions => "name = 'veryspecial'")
+ assert_equal very_special_client, Company.find(:first, :conditions => "name = 'veryspecial'")
+ assert_equal very_special_client, Client.find(:first, :conditions => "name = 'veryspecial'")
+ assert_equal 1, Client.find(:all, :conditions => "name = 'Summit'").size
assert_equal very_special_client, Client.find(very_special_client.id)
end
@@ -125,7 +125,7 @@ def test_inheritance_without_mapping
private
def switch_to_alt_inheritance_column
# we don't want misleading test results, so get rid of the values in the type column
- Company.find_all(nil, "id").each do |c|
+ Company.find(:all, :order => 'id').each do |c|
c['type'] = nil
c.save
end
View
12 activerecord/test/migration_mysql.rb
@@ -40,10 +40,10 @@ def test_add_table
WeNeedReminders.up
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
- assert "hello world", Reminder.find_first
+ assert "hello world", Reminder.find(:first)
WeNeedReminders.down
- assert_raises(ActiveRecord::StatementInvalid) { Reminder.find_first }
+ assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
end
def test_migrator
@@ -56,15 +56,15 @@ def test_migrator
Person.reset_column_information
assert Person.column_methods_hash.include?(:last_name)
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
- assert "hello world", Reminder.find_first
+ assert "hello world", Reminder.find(:first)
ActiveRecord::Migrator.down(File.dirname(__FILE__) + '/fixtures/migrations/')
assert_equal 0, ActiveRecord::Migrator.current_version
Person.reset_column_information
assert !Person.column_methods_hash.include?(:last_name)
- assert_raises(ActiveRecord::StatementInvalid) { Reminder.find_first }
+ assert_raises(ActiveRecord::StatementInvalid) { Reminder.find(:first) }
end
def test_migrator_one_up
@@ -81,7 +81,7 @@ def test_migrator_one_up
ActiveRecord::Migrator.up(File.dirname(__FILE__) + '/fixtures/migrations/', 2)
assert Reminder.create("content" => "hello world", "remind_at" => Time.now)
- assert "hello world", Reminder.find_first
+ assert "hello world", Reminder.find(:first)
end
def test_migrator_one_down
@@ -101,4 +101,4 @@ def test_migrator_one_up_one_down
assert !Person.column_methods_hash.include?(:last_name)
assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash }
end
-end
+end
View
2 activerecord/test/mixin_nested_set_test.rb
@@ -143,7 +143,7 @@ def test_snipping_tree
def test_deleting_root
NestedSetWithStringScope.find(4001).destroy
- assert( NestedSetWithStringScope.find_all.length == 0 )
+ assert( NestedSetWithStringScope.count == 0 )
end
def test_common_usage
View
22 activerecord/test/mixin_test.rb
@@ -13,39 +13,39 @@ def test_reordering
mixins(:list_2),
mixins(:list_3),
mixins(:list_4)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_2).move_lower
assert_equal [mixins(:list_1),
mixins(:list_3),
mixins(:list_2),
mixins(:list_4)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_2).move_higher
assert_equal [mixins(:list_1),
mixins(:list_2),
mixins(:list_3),
mixins(:list_4)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_1).move_to_bottom
assert_equal [mixins(:list_2),
mixins(:list_3),
mixins(:list_4),
mixins(:list_1)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_1).move_to_top
assert_equal [mixins(:list_1),
mixins(:list_2),
mixins(:list_3),
mixins(:list_4)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_2).move_to_bottom
@@ -54,15 +54,15 @@ def test_reordering
mixins(:list_3),
mixins(:list_4),
mixins(:list_2)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_4).move_to_top
assert_equal [mixins(:list_4),
mixins(:list_1),
mixins(:list_3),
mixins(:list_2)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
end
@@ -134,14 +134,14 @@ def test_delete_middle
mixins(:list_2),
mixins(:list_3),
mixins(:list_4)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
mixins(:list_2).destroy
assert_equal [mixins(:list_1, :reload),
mixins(:list_3, :reload),
mixins(:list_4, :reload)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
assert_equal 1, mixins(:list_1).pos
assert_equal 2, mixins(:list_3).pos
@@ -151,7 +151,7 @@ def test_delete_middle
assert_equal [mixins(:list_3, :reload),
mixins(:list_4, :reload)],
- ListMixin.find_all("parent_id=5", "pos")
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
assert_equal 1, mixins(:list_3).pos
assert_equal 2, mixins(:list_4).pos
@@ -168,7 +168,7 @@ def test_with_string_based_scope
def test_nil_scope
new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create
new2.move_higher
- assert_equal [new2, new1, new3], ListMixin.find_all("parent_id IS NULL", "pos")
+ assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
end
end
View
6 activerecord/test/modules_test.rb
@@ -5,14 +5,14 @@ class ModulesTest < Test::Unit::TestCase
fixtures :accounts, :companies, :projects, :developers
def test_module_spanning_associations
- assert MyApplication::Business::Firm.find_first.has_clients?, "Firm should have clients"
- firm = MyApplication::Business::Firm.find_first
+ assert MyApplication::Business::Firm.find(:first).has_clients?, "Firm should have clients"
+ firm = MyApplication::Business::Firm.find(:first)
assert_nil firm.class.table_name.match('::'), "Firm shouldn't have the module appear in its table name"
assert_equal 2, firm.clients_count, "Firm should have two clients"
end
def test_module_spanning_has_and_belongs_to_many_associations
- project = MyApplication::Business::Project.find_first
+ project = MyApplication::Business::Project.find(:first)
project.developers << MyApplication::Business::Developer.create("name" => "John")
assert "John", project.developers.last.name
end

0 comments on commit 3dfa56c

Please sign in to comment.
Something went wrong with that request. Please try again.