From 17366c6eab17c5b408f4de60a748b8f7b96eea6b Mon Sep 17 00:00:00 2001 From: Andrew Kvalheim Date: Wed, 1 Mar 2023 11:33:21 -0800 Subject: [PATCH] Update events when rated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When fragment caching is enabled— --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -27 +26,0 @@ - config.action_controller.perform_caching = false @@ -29 +27,0 @@ - config.cache_store = :null_store —the test of voting fails with: expected to find css ".rating.bright" … 3 times but there were no matches expected to find visible css ".rating:not(.bright)" … 2 times, found 5 matches # ./spec/features/voting_spec.rb:31 # ./spec/features/voting_spec.rb:30 # ./spec/features/voting_spec.rb:53 i.e. the rating displayed on the event index is not updated after voting, because while the fragment’s cache dependencies include the event, voting doesn’t update the event. re #2767 --- app/models/vote.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/vote.rb b/app/models/vote.rb index 64ab74de..cdd1e4cb 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -2,7 +2,7 @@ class Vote < ApplicationRecord belongs_to :user - belongs_to :event + belongs_to :event, touch: true validates :user_id, uniqueness: { scope: :event_id }