diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/fixtures/author.rb | 19 | ||||
-rw-r--r-- | activerecord/test/fixtures/post.rb | 4 | ||||
-rw-r--r-- | activerecord/test/fixtures/tagging.rb | 3 |
4 files changed, 20 insertions, 11 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index 79ac19ec61..9477e69e55 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -216,6 +216,11 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_raises (ActiveRecord::ActiveRecordError) { authors(:david).nothings } end + def test_has_many_through_join_model_with_conditions + assert_equal [], posts(:welcome).invalid_taggings + assert_equal [], posts(:welcome).invalid_tags + end + private # create dynamic Post models to allow different dependency options def find_post_with_dependency(post_id, association, association_name, dependency) diff --git a/activerecord/test/fixtures/author.rb b/activerecord/test/fixtures/author.rb index 0f0d1b12d9..06b0aaa1ae 100644 --- a/activerecord/test/fixtures/author.rb +++ b/activerecord/test/fixtures/author.rb @@ -4,20 +4,21 @@ class Author < ActiveRecord::Base has_many :posts_with_categories, :include => :categories, :class_name => "Post" has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" - has_many :special_posts, :class_name => "Post" - has_many :hello_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'hello'" - has_many :nonexistent_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'nonexistent'" + has_many :special_posts, :class_name => "Post" + has_many :hello_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'hello'" + has_many :nonexistent_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'nonexistent'" has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding, - :after_add => :log_after_adding, :before_remove => :log_before_removing, - :after_remove => :log_after_removing + :after_add => :log_after_adding, + :before_remove => :log_before_removing, + :after_remove => :log_after_removing has_many :posts_with_proc_callbacks, :class_name => "Post", - :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id}"}, - :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id}"}, + :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id}"}, + :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id}"}, :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"}, - :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} + :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} has_many :posts_with_multiple_callbacks, :class_name => "Post", :before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id}"}], - :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id}"}] + :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id}"}] has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding has_many :categorizations diff --git a/activerecord/test/fixtures/post.rb b/activerecord/test/fixtures/post.rb index 9456582729..23f4b5d8a5 100644 --- a/activerecord/test/fixtures/post.rb +++ b/activerecord/test/fixtures/post.rb @@ -23,9 +23,11 @@ class Post < ActiveRecord::Base has_many :taggings, :as => :taggable has_many :tags, :through => :taggings has_many :super_tags, :through => :taggings - has_one :tagging, :as => :taggable + has_many :invalid_taggings, :as => :taggable, :class_name => "Tagging", :conditions => 'taggings.id < 0' + has_many :invalid_tags, :through => :invalid_taggings, :class_name => "Tag" + has_many :categorizations, :foreign_key => :category_id has_many :authors, :through => :categorizations diff --git a/activerecord/test/fixtures/tagging.rb b/activerecord/test/fixtures/tagging.rb index 4d3878933a..51c3bd3604 100644 --- a/activerecord/test/fixtures/tagging.rb +++ b/activerecord/test/fixtures/tagging.rb @@ -1,5 +1,6 @@ class Tagging < ActiveRecord::Base belongs_to :tag - belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id' + belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id' + belongs_to :invalid_tag, :class_name => 'Tag', :foreign_key => 'tag_id' belongs_to :taggable, :polymorphic => true, :counter_cache => true end
\ No newline at end of file |