Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix query counters when testing with IdentityMap on 3.2 #12364

Merged
merged 1 commit into from

2 participants

@arthurnn
Collaborator

Problem

When counting the number of queries(e.g. IdentityMap), we cannot touch firm when saving a Client

Solution

Add a instance var, which if set to true would touch the parent.

review @rafaelfranca
If you wanna to cherry-pick this to master is ok too.

@rafaelfranca rafaelfranca merged commit e82ceca into rails:3-2-stable
@arthurnn arthurnn deleted the arthurnn:test_fix_validate branch
@arthurnn
Collaborator

:green_heart:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2013
  1. @arthurnn
This page is out of date. Refresh to see the latest.
View
4 activerecord/test/cases/associations/has_many_associations_test.rb
@@ -656,7 +656,9 @@ def test_transactions_when_adding_to_new_record
def test_inverse_on_before_validate
firm = companies(:first_firm)
assert_queries(1) do
- firm.clients_of_firm << Client.new("name" => "Natural Company")
+ client = Client.new("name" => "Natural Company")
+ client.touch_firm_on_validate = true
+ firm.clients_of_firm << client
end
end
View
3  activerecord/test/models/company.rb
@@ -126,8 +126,9 @@ class Client < Company
has_many :accounts, :through => :firm
belongs_to :account
+ attr_accessor :touch_firm_on_validate
validate do
- firm
+ firm if touch_firm_on_validate
end
class RaisedOnSave < RuntimeError; end
Something went wrong with that request. Please try again.