Hide site-wide messaging for opted-out users (#8409) [deploy]
This commit is contained in:
parent
7d58818efa
commit
a3665406d5
3 changed files with 23 additions and 3 deletions
|
|
@ -80,14 +80,20 @@ function renderBroadcast(broadcastElement, data) {
|
|||
}
|
||||
|
||||
/**
|
||||
* A function to determine if a broadcast should render
|
||||
* Does not render broadcast it has already been inserted,
|
||||
* or if the key for the broadcast's title exists in localStorage.
|
||||
* A function to determine if a broadcast should render.
|
||||
* Does not render a broadcast if the current user has opted-out.
|
||||
* Does not render a broadcast it has already been inserted, or
|
||||
* if the key for the broadcast's title exists in localStorage.
|
||||
*
|
||||
* @function initializeBroadcast
|
||||
*/
|
||||
function initializeBroadcast() {
|
||||
const user = userData();
|
||||
const data = broadcastData();
|
||||
|
||||
if (user && !user.display_announcements) {
|
||||
return;
|
||||
}
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ FactoryBot.define do
|
|||
saw_onboarding { true }
|
||||
checked_code_of_conduct { true }
|
||||
checked_terms_and_conditions { true }
|
||||
display_announcements { true }
|
||||
signup_cta_variant { "navbar_basic" }
|
||||
email_digest_periodic { false }
|
||||
bg_color_hex { Faker::Color.hex_color }
|
||||
|
|
|
|||
|
|
@ -86,5 +86,18 @@ RSpec.describe "User visits a homepage", type: :system do
|
|||
expect_no_broadcast_data(page)
|
||||
end
|
||||
end
|
||||
|
||||
context "when opting-out of announcements" do
|
||||
before do
|
||||
user.update!(display_announcements: false)
|
||||
create(:announcement_broadcast, active: true)
|
||||
get "/async_info/base_data" # Explicitly ensure broadcast data is loaded before doing any checks
|
||||
visit "/"
|
||||
end
|
||||
|
||||
it "does not render the broadcast", js: true do
|
||||
expect_no_broadcast_data(page)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue