diff options
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/associations_test.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 6b5b8a8d70..b87089b8ec 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -7,6 +7,7 @@ require 'fixtures/reply' require 'fixtures/computer' require 'fixtures/customer' require 'fixtures/order' +require 'fixtures/category' require 'fixtures/post' require 'fixtures/author' @@ -1080,7 +1081,7 @@ end class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase - fixtures :accounts, :companies, :developers, :projects, :developers_projects + fixtures :accounts, :companies, :categories, :posts, :categories_posts, :developers, :projects, :developers_projects def test_has_and_belongs_to_many david = Developer.find(1) @@ -1469,6 +1470,25 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase AND developer_id = #{developer.id} end_sql end + + def test_updating_attributes_on_non_rich_associations + welcome = categories(:technology).posts.first + welcome.title = "Something else" + assert welcome.save! + end + + def test_updating_attributes_on_rich_associations + david = projects(:action_controller).developers.first + david.name = "DHH" + assert_raises(ActiveRecord::ReadOnlyRecord) { david.save! } + end + + + def test_updating_attributes_on_rich_associations_with_limited_find + david = projects(:action_controller).developers.find(:all, :select => "developers.*").first + david.name = "DHH" + assert david.save! + end def test_join_table_alias assert_equal 3, Developer.find(:all, :include => {:projects => :developers}, :conditions => 'developers_projects_join.joined_on IS NOT NULL').size |