aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-18 23:14:31 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-18 23:14:31 +0000
commit9c9069a67595f620f80eabc475181cb36a26cdde (patch)
treea2a8aebf762be6d73ec8cab1d5f0a1c8eb84356b /activerecord/test/fixtures
parenta46214c4f9e7117796f2a5ed1414a83c2ca4c6bd (diff)
downloadrails-9c9069a67595f620f80eabc475181cb36a26cdde.tar.gz
rails-9c9069a67595f620f80eabc475181cb36a26cdde.tar.bz2
rails-9c9069a67595f620f80eabc475181cb36a26cdde.zip
Fixed has_many :through to include :conditions set on the :through association. closes #4020 [jonathan@bluewire.net.nz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3958 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures')
-rw-r--r--activerecord/test/fixtures/author.rb19
-rw-r--r--activerecord/test/fixtures/post.rb4
-rw-r--r--activerecord/test/fixtures/tagging.rb3
3 files changed, 15 insertions, 11 deletions
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