Created
January 9, 2013 21:37
-
-
Save anonymous/4497186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb | |
index af91fb2..f3e4d10 100644 | |
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb | |
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb | |
@@ -894,4 +894,11 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase | |
end | |
end | |
+ def test_validation_call_counter_on_join_records | |
+ author = Author.create(:name => "tenderlove") | |
+ Categorization.any_instance.expects(:check_validation_call_count).times(1) | |
+ category = Category.new(:name => "rails 4.0") | |
+ category.authors << author | |
+ category.save | |
+ end | |
end | |
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb | |
index 6935cfb..bd7fd86 100644 | |
--- a/activerecord/test/models/author.rb | |
+++ b/activerecord/test/models/author.rb | |
@@ -181,6 +181,8 @@ class Author < ActiveRecord::Base | |
def raise_exception(object) | |
raise Exception.new("You can't add a post") | |
end | |
+ | |
+ | |
end | |
class AuthorAddress < ActiveRecord::Base | |
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb | |
index 6588531..cad9e15 100644 | |
--- a/activerecord/test/models/categorization.rb | |
+++ b/activerecord/test/models/categorization.rb | |
@@ -8,6 +8,13 @@ class Categorization < ActiveRecord::Base | |
belongs_to :author_using_custom_pk, :class_name => 'Author', :foreign_key => :author_id, :primary_key => :author_address_extra_id | |
has_many :authors_using_custom_pk, :class_name => 'Author', :foreign_key => :id, :primary_key => :category_id | |
+ validate :check_validation_call_count | |
+ | |
+ private | |
+ def check_validation_call_count | |
+ @count ||= 0 | |
+ @count = @count + 1 | |
+ end | |
end | |
class SpecialCategorization < ActiveRecord::Base |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment