Skip to content

Commit

Permalink
Merge pull request #5565 from carlosantoniodasilva/fix-build-3-0
Browse files Browse the repository at this point in the history
Fix build for branch 3-0-stable
  • Loading branch information
josevalim committed Mar 23, 2012
2 parents 8645745 + f748d36 commit 728a65d
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 35 deletions.
Expand Up @@ -656,7 +656,7 @@ def test_clearing_an_association_collection
end

def test_clearing_updates_counter_cache
topic = Topic.first
topic = Topic.order(:id).first

topic.replies.clear
topic.reload
Expand Down Expand Up @@ -736,14 +736,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_attribute(: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
Expand Down Expand Up @@ -909,13 +909,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

Expand Down
6 changes: 3 additions & 3 deletions activerecord/test/cases/associations/join_model_test.rb
Expand Up @@ -384,7 +384,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).taggings
assert_equal Tagging.find(1,2).sort_by { |t| t.id }, authors(:david).taggings.order(:id)
end

def test_has_many_through_polymorphic_has_many
Expand Down Expand Up @@ -441,7 +441,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
Expand Down Expand Up @@ -634,7 +634,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
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/finder_test.rb
Expand Up @@ -103,8 +103,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
Expand Down
4 changes: 2 additions & 2 deletions activerecord/test/cases/json_serialization_test.rb
Expand Up @@ -198,7 +198,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}]'].each do |fragment|
assert json.include?(fragment), json
end
end
end

def test_should_allow_options_for_hash_of_authors
Expand All @@ -210,7 +210,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
Expand Down
14 changes: 9 additions & 5 deletions activerecord/test/cases/nested_attributes_test.rb
Expand Up @@ -114,7 +114,7 @@ def test_reject_if_with_indifferent_keys
pirate.ship_attributes = { :name => 'Hello Pearl' }
assert_difference('Ship.count') { pirate.save! }
end

def test_has_many_association_updating_a_single_record
Man.accepts_nested_attributes_for(:interests)
man = Man.create(:name => 'John')
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_should_accept_update_only_option

def test_should_create_new_model_when_nothing_is_there_and_update_only_is_true
@ship.delete

@pirate.reload.update_attributes(:update_only_ship_attributes => { :name => 'Mayflower' })

assert_not_nil @pirate.ship
Expand Down Expand Up @@ -459,7 +459,7 @@ def test_should_work_with_update_attributes_as_well

def test_should_not_destroy_the_associated_model_until_the_parent_is_saved
pirate = @ship.pirate

@ship.attributes = { :pirate_attributes => { :id => pirate.id, '_destroy' => true } }
assert_nothing_raised(ActiveRecord::RecordNotFound) { Pirate.find(pirate.id) }
@ship.save
Expand Down Expand Up @@ -607,9 +607,13 @@ def test_should_raise_RecordNotFound_if_an_id_is_given_but_doesnt_return_a_recor
end

def test_should_automatically_build_new_associated_models_for_each_entry_in_a_hash_where_the_id_is_missing
attributes = ActiveSupport::OrderedHash.new
attributes['foo'] = { :name => 'Grace OMalley' }
attributes['bar'] = { :name => 'Privateers Greed' }

@pirate.send(@association_name).destroy_all
@pirate.reload.attributes = {
association_getter => { 'foo' => { :name => 'Grace OMalley' }, 'bar' => { :name => 'Privateers Greed' }}
association_getter => attributes
}

assert @pirate.send(@association_name).first.new_record?
Expand Down Expand Up @@ -850,7 +854,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
Expand Down
11 changes: 6 additions & 5 deletions activerecord/test/cases/persistence_test.rb
Expand Up @@ -17,15 +17,16 @@
require 'active_support/core_ext/exception'

class PersistencesTest < ActiveRecord::TestCase
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics,
'warehouse-things', :authors, :categorizations, :categories, :posts, :minivans

fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts, :minivans

# Oracle UPDATE does not support ORDER BY
unless current_adapter?(:OracleAdapter)
# Skip databases that don't support UPDATE + ORDER BY
unless current_adapter?(:OracleAdapter, :PostgreSQLAdapter)
def test_update_all_ignores_order_without_limit_from_association
author = authors(:david)
assert_nothing_raised do
assert_equal author.posts_with_comments_and_categories.length, author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ])
assert_equal author.posts_with_comments_and_categories.length,
author.posts_with_comments_and_categories.update_all([ "body = ?", "bulk update!" ])
end
end

Expand Down
20 changes: 10 additions & 10 deletions activerecord/test/cases/relations_test.rb
Expand Up @@ -270,50 +270,50 @@ def test_eager_association_loading_of_stis_with_multiple_references

def test_find_with_preloaded_associations
assert_queries(2) do
posts = Post.preload(:comments)
posts = Post.preload(:comments).order('posts.id')
assert posts.first.comments.first
end

assert_queries(2) do
posts = Post.preload(:comments).to_a
posts = Post.preload(:comments).order('posts.id').to_a
assert posts.first.comments.first
end

assert_queries(2) do
posts = Post.preload(:author)
posts = Post.preload(:author).order('posts.id')
assert posts.first.author
end

assert_queries(2) do
posts = Post.preload(:author).to_a
posts = Post.preload(:author).order('posts.id').to_a
assert posts.first.author
end

assert_queries(3) do
posts = Post.preload(:author, :comments).to_a
posts = Post.preload(:author, :comments).order('posts.id').to_a
assert posts.first.author
assert posts.first.comments.first
end
end

def test_find_with_included_associations
assert_queries(2) do
posts = Post.includes(:comments)
posts = Post.includes(:comments).order('posts.id')
assert posts.first.comments.first
end

assert_queries(2) do
posts = Post.scoped.includes(:comments)
posts = Post.scoped.includes(:comments).order('posts.id')
assert posts.first.comments.first
end

assert_queries(2) do
posts = Post.includes(:author)
posts = Post.includes(:author).order('posts.id')
assert posts.first.author
end

assert_queries(3) do
posts = Post.includes(:author, :comments).to_a
posts = Post.includes(:author, :comments).order('posts.id').to_a
assert posts.first.author
assert posts.first.comments.first
end
Expand Down Expand Up @@ -570,7 +570,7 @@ def test_relation_merging_with_locks

def test_relation_merging_with_preload
[Post.scoped.merge(Post.preload(:author)), Post.preload(:author).merge(Post.scoped)].each do |posts|
assert_queries(2) { assert posts.first.author }
assert_queries(2) { assert posts.order(:id).first.author }
end
end

Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/timestamp_test.rb
Expand Up @@ -10,7 +10,7 @@ class TimestampTest < ActiveRecord::TestCase
fixtures :developers, :owners, :pets, :toys, :cars, :tasks

def setup
@developer = Developer.first
@developer = Developer.order(:id).first
@developer.update_attribute(:updated_at, Time.now.prev_month)
@previously_updated_at = @developer.updated_at
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/yaml_serialization_test.rb
Expand Up @@ -12,7 +12,7 @@ def test_to_yaml_with_time_with_zone_should_not_raise_exception
end

def test_roundtrip
topic = Topic.first
topic = Topic.order(:id).first
assert topic
t = YAML.load YAML.dump topic
assert_equal topic, t
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/company.rb
Expand Up @@ -92,7 +92,7 @@ class Firm < Company
end

class DependentFirm < Company
has_one :account, :foreign_key => "firm_id", :dependent => :nullify
has_one :account, :foreign_key => "firm_id", :dependent => :nullify, :order => "accounts.id"
has_many :companies, :foreign_key => 'client_of', :dependent => :nullify
end

Expand Down

0 comments on commit 728a65d

Please sign in to comment.