Merge pull request #1496 from basecamp/cached-attributions

Make sure attribution in events is cache-friendly
This commit is contained in:
Jorge Manrubia
2025-11-05 11:49:26 +01:00
committed by GitHub
4 changed files with 20 additions and 3 deletions
+6 -1
View File
@@ -68,7 +68,12 @@ module EventsHelper
end
def event_creator_name(event)
event.creator == Current.user ? "You" : h(event.creator.name)
tag.span data: { creator_id: event.creator.id } do
safe_join([
tag.span("You", data: { only_visible_to_you: true }),
tag.span(h(event.creator.name), data: { only_visible_to_others: true })
])
end
end
def card_event_action_sentence(event)
+2
View File
@@ -20,6 +20,8 @@
<%= javascript_importmap_tags %>
<%= tenanted_action_cable_meta_tag %>
<%= render "layouts/shared/user_css" %>
<%= yield :head %>
<% if ApplicationRecord.current_tenant %>
@@ -0,0 +1,10 @@
<% if Current.user %>
<style>
[data-creator-id="<%= Current.user.id %>"] {
[data-only-visible-to-others] { display: none; }
}
[data-creator-id]:not([data-creator-id="<%= Current.user.id %>"]) {
[data-only-visible-to-you] { display: none; }
}
</style>
<% end %>
+2 -2
View File
@@ -12,7 +12,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest
get events_path
assert_select "div.events__time-block[style='grid-area: 17/2']" do
assert_select "strong", text: "David assigned JZ to Layout is broken"
assert_select "strong", text: /assigned JZ to Layout is broken/
end
end
@@ -22,7 +22,7 @@ class EventsControllerTest < ActionDispatch::IntegrationTest
get events_path
assert_select "div.events__time-block[style='grid-area: 22/2']" do
assert_select "strong", text: "David assigned JZ to Layout is broken"
assert_select "strong", text: /assigned JZ to Layout is broken/
end
end