diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-16 21:10:50 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-16 21:10:50 +0900 |
commit | 9a9d5af1e4c1531bf96917717249ed43f3a75270 (patch) | |
tree | 79c5c1910dbbed38f515285d409a8a1cc5da4a8c | |
parent | 09ca939eabc8b0cda865ecf2893c48800a7c51e3 (diff) | |
parent | 5e92770e5a6d997e5f973cc59aebc58c4ebff80b (diff) | |
download | rails-9a9d5af1e4c1531bf96917717249ed43f3a75270.tar.gz rails-9a9d5af1e4c1531bf96917717249ed43f3a75270.tar.bz2 rails-9a9d5af1e4c1531bf96917717249ed43f3a75270.zip |
Merge pull request #34203 from albertoalmagro/add-habtm-singular-ids-regression-test
Add regression test against has_and_belong_to_many memoized singular_ids
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index ed7dde115a..515eb65d37 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -25,6 +25,8 @@ require "models/user" require "models/member" require "models/membership" require "models/sponsor" +require "models/lesson" +require "models/student" require "models/country" require "models/treaty" require "models/vertex" @@ -780,6 +782,16 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal [projects(:active_record), projects(:action_controller)].map(&:id).sort, developer.project_ids.sort end + def test_singular_ids_are_reloaded_after_collection_concat + student = Student.create(name: "Alberto Almagro") + student.lesson_ids + + lesson = Lesson.create(name: "DSI") + student.lessons << lesson + + assert_includes student.lesson_ids, lesson.id + end + def test_scoped_find_on_through_association_doesnt_return_read_only_records tag = Post.find(1).tags.find_by_name("General") |