Ticket #11156: add_readonly_option_to_has_many_through_associations.diff
| File add_readonly_option_to_has_many_through_associations.diff, 2.5 kB (added by miloops, 8 months ago) |
|---|
-
test/models/author.rb
old new 20 20 has_many :funky_comments, :through => :posts, :source => :comments 21 21 has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id' 22 22 has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC' 23 23 has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true 24 24 25 has_many :special_posts 25 26 has_many :special_post_comments, :through => :special_posts, :source => :comments 26 27 -
test/cases/associations_test.rb
old new 554 554 companies(:first_firm).readonly_clients.find(:all).each { |c| assert c.readonly? } 555 555 end 556 556 557 def test_cant_save_has_many_readonly_association 558 authors(:david).readonly_comments.each { |c| assert_raise(ActiveRecord::ReadOnlyRecord) { c.save! } } 559 authors(:david).readonly_comments.each { |c| assert c.readonly? } 560 end 561 557 562 def test_triple_equality 558 563 assert !(Array === Firm.find(:first).clients) 559 564 assert Firm.find(:first).clients === Array -
lib/active_record/associations/has_many_through_association.rb
old new 145 145 :order => @reflection.options[:order], 146 146 :limit => @reflection.options[:limit], 147 147 :group => @reflection.options[:group], 148 :readonly => @reflection.options[:readonly], 148 149 :include => @reflection.options[:include] || @reflection.source_reflection.options[:include] 149 150 ) 150 151 … … 239 240 :include => @reflection.options[:include], 240 241 :select => construct_select, 241 242 :order => @reflection.options[:order], 242 :limit => @reflection.options[:limit] } } 243 :limit => @reflection.options[:limit], 244 :readonly => @reflection.options[:readonly], 245 } } 243 246 end 244 247 245 248 def construct_sql