aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_through_associations_test.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-12-09 09:29:54 +1030
committerMatthew Draper <matthew@trebex.net>2016-12-09 09:32:07 +1030
commit847e9dd5c12b34856f5c74d52bc6c86b1735ffe5 (patch)
treed117d74cdd6b4deda31fbf352dcba42127080bf4 /activerecord/test/cases/associations/has_many_through_associations_test.rb
parent0951306ca5edbaec10edf3440d5ba11062a4f2e5 (diff)
downloadrails-847e9dd5c12b34856f5c74d52bc6c86b1735ffe5.tar.gz
rails-847e9dd5c12b34856f5c74d52bc6c86b1735ffe5.tar.bz2
rails-847e9dd5c12b34856f5c74d52bc6c86b1735ffe5.zip
Resolve association class correctly when assigning ids on a through association
Diffstat (limited to 'activerecord/test/cases/associations/has_many_through_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 8defb09db7..83b1f8d4d6 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -904,6 +904,13 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
assert_match(/Couldn't find all Clients with 'name'/, e.message)
end
+ def test_collection_singular_ids_through_setter_raises_exception_when_invalid_ids_set
+ author = authors(:david)
+ ids = [categories(:general).name, "Unknown"]
+ e = assert_raises(ActiveRecord::RecordNotFound) { author.essay_category_ids = ids }
+ assert_equal "Couldn't find all Categories with 'name': (General, Unknown) (found 1 results, but was looking for 2)", e.message
+ end
+
def test_build_a_model_from_hm_through_association_with_where_clause
assert_nothing_raised { books(:awdr).subscribers.where(nick: "marklazz").build }
end