aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-12 17:03:41 +0000
committerAaron Patterson <aaron.patterson@gmail.com>2010-12-15 11:03:58 -0800
commita04e1036691ca98579dd8b8b6cb19ffb23f85c72 (patch)
tree31939cee462d979cdddc31c99bc58238e261367d /activerecord/test/models
parent16e93f2c3c3ca37d2bae9801b680b05f75c48c18 (diff)
downloadrails-a04e1036691ca98579dd8b8b6cb19ffb23f85c72.tar.gz
rails-a04e1036691ca98579dd8b8b6cb19ffb23f85c72.tar.bz2
rails-a04e1036691ca98579dd8b8b6cb19ffb23f85c72.zip
Verify that creating a has_many through record where there is a default_scope on the join model works correctly (creates the join record with the default scope applied)
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb4
-rw-r--r--activerecord/test/models/categorization.rb11
2 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 29ee50e801..fd6d2b384a 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -77,6 +77,10 @@ class Author < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
+ has_many :special_categorizations
+ has_many :special_categories, :through => :special_categorizations, :source => :category
+ has_one :special_category, :through => :special_categorizations, :source => :category
+
has_many :categories_like_general, :through => :categorizations, :source => :category, :class_name => 'Category', :conditions => { :name => 'General' }
has_many :categorized_posts, :through => :categorizations, :source => :post
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb
index 10594323ff..b3fc29fa15 100644
--- a/activerecord/test/models/categorization.rb
+++ b/activerecord/test/models/categorization.rb
@@ -2,4 +2,13 @@ class Categorization < ActiveRecord::Base
belongs_to :post
belongs_to :category
belongs_to :author
-end \ No newline at end of file
+end
+
+class SpecialCategorization < ActiveRecord::Base
+ self.table_name = 'categorizations'
+
+ default_scope where(:special => true)
+
+ belongs_to :author
+ belongs_to :category
+end