Permalink
Browse files

Merge pull request #5564 from carlosantoniodasilva/fix-build-3-1

Fix build for branch 3-1-stable
  • Loading branch information...
2 parents fea82eb + c8d5680 commit dafded21343ffcc642ec6d3a8b52170851dcaf8a @josevalim josevalim committed Mar 23, 2012
@@ -825,7 +825,7 @@ def test_clearing_an_association_collection
end
def test_clearing_updates_counter_cache
- topic = Topic.first
+ topic = Topic.order(:id).first
assert_difference 'topic.reload.replies_count', -1 do
topic.replies.clear
@@ -914,14 +914,14 @@ def test_dependent_association_respects_optional_hash_conditions_on_delete
end
def test_delete_all_association_with_primary_key_deletes_correct_records
- firm = Firm.find(:first)
+ firm = Firm.order(:id).first
# break the vanilla firm_id foreign key
assert_equal 2, firm.clients.count
firm.clients.first.update_column(:firm_id, nil)
assert_equal 1, firm.clients(true).count
assert_equal 1, firm.clients_using_primary_key_with_delete_all.count
old_record = firm.clients_using_primary_key_with_delete_all.first
- firm = Firm.find(:first)
+ firm = Firm.order(:id).first
firm.destroy
assert_nil Client.find_by_id(old_record.id)
end
@@ -1081,13 +1081,12 @@ def test_depends_and_nullify
core = companies(:rails_core)
assert_equal accounts(:rails_core_account), core.account
- assert_equal companies(:leetsoft, :jadedpixel), core.companies
+ assert_equal companies(:leetsoft, :jadedpixel), core.companies.order(:id)
core.destroy
assert_nil accounts(:rails_core_account).reload.firm_id
assert_nil companies(:leetsoft).reload.client_of
assert_nil companies(:jadedpixel).reload.client_of
-
assert_equal num_accounts, Account.count
end
@@ -403,7 +403,7 @@ def test_has_many_through_has_many_find_by_id
end
def test_has_many_through_polymorphic_has_one
- assert_equal Tagging.find(1,2).sort_by { |t| t.id }, authors(:david).tagging
+ assert_equal Tagging.find(1,2).sort_by { |t| t.id }, authors(:david).tagging.order(:id)
end
def test_has_many_through_polymorphic_has_many
@@ -452,7 +452,7 @@ def test_add_to_self_referential_has_many_through
end
def test_has_many_through_uses_conditions_specified_on_the_has_many_association
- author = Author.find(:first)
+ author = Author.order(:id).first
assert_present author.comments
assert_blank author.nonexistant_comments
end
@@ -649,7 +649,7 @@ def test_preload_polymorphic_has_many_through
end
def test_preload_polymorph_many_types
- taggings = Tagging.find :all, :include => :taggable, :conditions => ['taggable_type != ?', 'FakeModel']
+ taggings = Tagging.find :all, :include => :taggable, :conditions => ['taggable_type != ?', 'FakeModel'], :order => 'id'
assert_no_queries do
taggings.first.taggable.id
taggings[1].taggable.id
@@ -55,7 +55,7 @@ def test_has_many_through_has_many_with_has_many_through_source_reflection
end
def test_has_many_through_has_many_with_has_many_through_source_reflection_preload
- authors = assert_queries(5) { Author.includes(:tags).to_a }
+ authors = assert_queries(5) { Author.includes(:tags).order(:id).to_a }
general = tags(:general)
assert_no_queries do
@@ -84,7 +84,7 @@ def test_has_many_through_has_many_through_with_has_many_source_reflection
def test_has_many_through_has_many_through_with_has_many_source_reflection_preload
luke, david = subscribers(:first), subscribers(:second)
- authors = assert_queries(4) { Author.includes(:subscribers).to_a }
+ authors = assert_queries(4) { Author.includes(:subscribers).order(:id).to_a }
assert_no_queries do
assert_equal [luke, david, david], authors.first.subscribers.sort_by(&:nick)
end
@@ -106,10 +106,10 @@ def test_has_many_through_has_one_with_has_one_through_source_reflection
end
def test_has_many_through_has_one_with_has_one_through_source_reflection_preload
- members = assert_queries(4) { Member.includes(:nested_member_types).to_a }
+ members = assert_queries(4) { Member.includes(:nested_member_types).order(:id).to_a }
founding = member_types(:founding)
assert_no_queries do
- assert_equal [founding], members.first.nested_member_types
+ assert_equal [founding], members.first.nested_member_types.to_a
end
end
@@ -128,10 +128,10 @@ def test_has_many_through_has_one_through_with_has_one_source_reflection
end
def test_has_many_through_has_one_through_with_has_one_source_reflection_preload
- members = assert_queries(4) { Member.includes(:nested_sponsors).to_a }
+ members = assert_queries(4) { Member.includes(:nested_sponsors).order(:id).to_a }
mustache = sponsors(:moustache_club_sponsor_for_groucho)
assert_no_queries do
- assert_equal [mustache], members.first.nested_sponsors
+ assert_equal [mustache], members.first.nested_sponsors.to_a
end
end
@@ -163,7 +163,7 @@ def test_has_many_through_has_one_with_has_many_through_source_reflection_preloa
def test_has_many_through_has_one_with_has_many_through_source_reflection_preload_via_joins
assert_includes_and_joins_equal(
- Member.where('member_details.id' => member_details(:groucho).id).order('member_details.id'),
+ Member.where('member_details.id' => member_details(:groucho).id).order('members.id'),
[members(:groucho), members(:some_other_guy)], :organization_member_details
)
@@ -193,7 +193,7 @@ def test_has_many_through_has_one_through_with_has_many_source_reflection_preloa
def test_has_many_through_has_one_through_with_has_many_source_reflection_preload_via_joins
assert_includes_and_joins_equal(
- Member.where('member_details.id' => member_details(:groucho).id).order('member_details.id'),
+ Member.where('member_details.id' => member_details(:groucho).id).order('members.id'),
[members(:groucho), members(:some_other_guy)], :organization_member_details_2
)
@@ -285,7 +285,7 @@ def test_has_many_through_has_many_through_with_belongs_to_source_reflection
end
def test_has_many_through_has_many_through_with_belongs_to_source_reflection_preload
- authors = assert_queries(5) { Author.includes(:tagging_tags).to_a }
+ authors = assert_queries(5) { Author.includes(:tagging_tags).order(:id).to_a }
general = tags(:general)
assert_no_queries do
@@ -6,15 +6,15 @@ class CloneTest < ActiveRecord::TestCase
fixtures :topics
def test_persisted
- topic = Topic.first
+ topic = Topic.order(:id).first
cloned = topic.clone
assert topic.persisted?, 'topic persisted'
assert cloned.persisted?, 'topic persisted'
assert !cloned.new_record?, 'topic is not new'
end
def test_stays_frozen
- topic = Topic.first
+ topic = Topic.order(:id).first
topic.freeze
cloned = topic.clone
@@ -24,7 +24,7 @@ def test_stays_frozen
end
def test_shallow
- topic = Topic.first
+ topic = Topic.order(:id).first
cloned = topic.clone
topic.author_name = 'Aaron'
assert_equal 'Aaron', cloned.author_name
@@ -10,43 +10,43 @@ def test_dup
end
def test_not_readonly
- topic = Topic.first
+ topic = Topic.order(:id).first
duped = topic.dup
assert !duped.readonly?, 'should not be readonly'
end
def test_is_readonly
- topic = Topic.first
+ topic = Topic.order(:id).first
topic.readonly!
duped = topic.dup
assert duped.readonly?, 'should be readonly'
end
def test_dup_not_persisted
- topic = Topic.first
+ topic = Topic.order(:id).first
duped = topic.dup
assert !duped.persisted?, 'topic not persisted'
assert duped.new_record?, 'topic is new'
end
def test_dup_has_no_id
- topic = Topic.first
+ topic = Topic.order(:id).first
duped = topic.dup
assert_nil duped.id
end
def test_dup_with_modified_attributes
- topic = Topic.first
+ topic = Topic.order(:id).first
topic.author_name = 'Aaron'
duped = topic.dup
assert_equal 'Aaron', duped.author_name
end
def test_dup_with_changes
- dbtopic = Topic.first
+ dbtopic = Topic.order(:id).first
topic = Topic.new
topic.attributes = dbtopic.attributes
@@ -61,7 +61,7 @@ def test_dup_with_changes
end
def test_dup_topics_are_independent
- topic = Topic.first
+ topic = Topic.order(:id).first
topic.author_name = 'Aaron'
duped = topic.dup
@@ -71,7 +71,7 @@ def test_dup_topics_are_independent
end
def test_dup_attributes_are_independent
- topic = Topic.first
+ topic = Topic.order(:id).first
duped = topic.dup
duped.author_name = 'meow'
@@ -82,7 +82,7 @@ def test_dup_attributes_are_independent
end
def test_dup_timestamps_are_cleared
- topic = Topic.first
+ topic = Topic.order(:id).first
assert_not_nil topic.updated_at
assert_not_nil topic.created_at
@@ -98,6 +98,5 @@ def test_dup_timestamps_are_cleared
assert_not_nil new_topic.updated_at
assert_not_nil new_topic.created_at
end
-
end
end
@@ -53,8 +53,8 @@ def test_exists_returns_true_with_one_record_and_no_args
def test_exists_with_nil_arg
assert !Topic.exists?(nil)
assert Topic.exists?
- assert !Topic.first.replies.exists?(nil)
- assert Topic.first.replies.exists?
+ assert !Topic.order(:id).first.replies.exists?(nil)
+ assert Topic.order(:id).first.replies.exists?
end
def test_does_not_exist_with_empty_table_and_no_args_given
@@ -301,20 +301,20 @@ def test_eager_loading_with_conditions_on_joined_table_preloads
posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
end
def test_eager_loading_with_conditions_on_string_joined_table_preloads
@@ -336,38 +336,38 @@ def test_eager_loading_with_conditions_on_string_joined_table_preloads
##############################################################################
def test_reload_object_if_save_failed
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert !developer.save
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
assert_not_equal developer.salary, same_developer.salary
end
def test_reload_object_if_forced_save_failed
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert_raise(ActiveRecord::RecordInvalid) { developer.save! }
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
assert_not_equal developer.salary, same_developer.salary
end
def test_reload_object_if_update_attributes_fails
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert !developer.update_attributes(:salary => 0)
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
@@ -379,10 +379,10 @@ def test_reload_object_if_update_attributes_fails
##############################################################################
def test_find_using_identity_map_respects_readonly_when_loading_associated_object_first
- author = Author.first
+ author = Author.order(:id).first
readonly_comment = author.readonly_comments.first
- comment = Comment.first
+ comment = Comment.order(:id).first
assert !comment.readonly?
assert readonly_comment.readonly?
@@ -392,10 +392,10 @@ def test_find_using_identity_map_respects_readonly_when_loading_associated_objec
end
def test_find_using_identity_map_respects_readonly
- comment = Comment.first
+ comment = Comment.order(:id).first
assert !comment.readonly?
- author = Author.first
+ author = Author.order(:id).first
readonly_comment = author.readonly_comments.first
assert readonly_comment.readonly?
@@ -405,13 +405,13 @@ def test_find_using_identity_map_respects_readonly
end
def test_find_using_select_and_identity_map
- author_id, author = Author.select('id').first, Author.first
+ author_id, author = Author.select('id').order(:id).first, Author.order(:id).first
assert_equal author_id, author
assert_same author_id, author
assert_not_nil author.name
- post, post_id = Post.first, Post.select('id').first
+ post, post_id = Post.order(:id).first, Post.select('id').order(:id).first
assert_equal post_id, post
assert_same post_id, post
@@ -202,7 +202,7 @@ def test_should_allow_includes_for_list_of_authors
['"name":"David"', '"posts":[', '{"id":1}', '{"id":2}', '{"id":4}',
'{"id":5}', '{"id":6}', '"name":"Mary"', '"posts":[', '{"id":7}', '{"id":9}'].each do |fragment|
assert json.include?(fragment), json
- end
+ end
end
def test_should_allow_options_for_hash_of_authors
@@ -214,7 +214,7 @@ def test_should_allow_options_for_hash_of_authors
end
def test_should_be_able_to_encode_relation
- authors_relation = Author.where(:id => [@david.id, @mary.id])
+ authors_relation = Author.where(:id => [@david.id, @mary.id]).order(:id)
json = ActiveSupport::JSON.encode authors_relation, :only => :name
assert_equal '[{"author":{"name":"David"}},{"author":{"name":"Mary"}}]', json
@@ -868,7 +868,7 @@ def setup
def test_should_update_existing_records_with_non_standard_primary_key
@owner.update_attributes(@params)
- assert_equal ['Foo', 'Bar'], @owner.pets.map(&:name)
+ assert_equal %w(Bar Foo), @owner.pets.map(&:name).sort
end
def test_attr_accessor_of_child_should_be_value_provided_during_update_attributes
Oops, something went wrong.

0 comments on commit dafded2

Please sign in to comment.