aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-22 11:08:04 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-22 22:41:10 -0300
commitb332891b2ab4188e9d39737f4d214812afa3ce2c (patch)
tree72974490c032f9a753f3fc41d335a049c8abbc05 /activerecord/test/cases/associations/has_many_associations_test.rb
parentb714140f4df50d102e70b0151bbb3a09e470d61a (diff)
downloadrails-b332891b2ab4188e9d39737f4d214812afa3ce2c.tar.gz
rails-b332891b2ab4188e9d39737f4d214812afa3ce2c.tar.bz2
rails-b332891b2ab4188e9d39737f4d214812afa3ce2c.zip
Add order to tests that rely on db ordering, to fix failing tests on pg
Also skip persistente tests related to UPDATE + ORDER BY for postgresql PostgreSQL does not support updates with order by, and these tests are failing randomly depending on the fixture loading order now.
Diffstat (limited to 'activerecord/test/cases/associations/has_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb9
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index ead8eaf342..f7b2b42959 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -912,7 +912,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
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
@@ -1001,14 +1001,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
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
@@ -1168,13 +1168,12 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
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