diff options
author | Gaurish Sharma <contact@gaurishsharma.com> | 2017-07-23 23:02:27 +0530 |
---|---|---|
committer | Gaurish Sharma <contact@gaurishsharma.com> | 2017-07-29 19:40:31 +0530 |
commit | 702e36e2f303aa5864209d43c25f1b9008ae976e (patch) | |
tree | ba3ca75421cc8956ccd40d70646a4c84021377d1 /activerecord/test/cases/associations/has_many_through_associations_test.rb | |
parent | 904f1a8747958129124d86b44e36c5f0263e0125 (diff) | |
download | rails-702e36e2f303aa5864209d43c25f1b9008ae976e.tar.gz rails-702e36e2f303aa5864209d43c25f1b9008ae976e.tar.bz2 rails-702e36e2f303aa5864209d43c25f1b9008ae976e.zip |
Return Not found Ids in ActiveRecord::NotFound
This builds on top of 15e2da656f41af0124f7577858536f3b65462ad5.
now it also returns exact Ids which were not found which will be debugging simple.
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.rb | 6 |
1 files changed, 4 insertions, 2 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 5797ffef38..2528d3ee70 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -891,7 +891,8 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase company = companies(:rails_core) ids = [Developer.first.id, -9999] e = assert_raises(ActiveRecord::RecordNotFound) { company.developer_ids = ids } - assert_match(/Couldn't find all Developers with 'id'/, e.message) + msg = "Couldn't find all Developers with 'id': (1, -9999) (found 1 results, but was looking for 2). Couldn't find Developer with id -9999." + assert_equal(msg, e.message) end def test_collection_singular_ids_setter_raises_exception_when_invalid_ids_set_with_changed_primary_key @@ -905,7 +906,8 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase 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 + msg = "Couldn't find all Categories with 'name': (General, Unknown) (found 1 results, but was looking for 2). Couldn't find Category with name Unknown." + assert_equal msg, e.message end def test_build_a_model_from_hm_through_association_with_where_clause |