Allow Users to Opt-out of Announcements (#8343) [deploy]
* Add display_announcements boolean to Users table * Adds a boolean with a default of true to Users * Add display_announcements to #user_data and user_policy.rb * Adds display_announcements to #user_data in AsyncInfoController * Adds display_announcements to PERMITTED_ATTRIBUTES * Add display_announcements to _misc.html.erb * Adjust submit data request button and adjust Announcements heading * Adjusts submit data request button to follow button capitalization * Adjusts announcements heading to read Announcements not Sponsors * Add copy to _misc.html.erb to add context around Announcement toggle * Add request and system specs around Announcements * Adds a test for announcements to user_settings_spec.rb * Adds a system spec for updating announcements * Add user_updates_announcements_spec file and remove old spec from users_settings_spec * Fix spec weirdness * Add tests around misc tab and Announcement toggle to user_settings_spec.rb * Tests that misc tab renders properly * Tests that display_announcements toggle updates a users settings properly * Removes user_updates_announcements_spec.rb * Adjusts Export Content capitalization in _misc.html.erb * Resolve DB conflicts
This commit is contained in:
parent
defab11a4d
commit
b4b10a0cd7
6 changed files with 38 additions and 2 deletions
|
|
@ -66,6 +66,7 @@ class AsyncInfoController < ApplicationController
|
|||
checked_code_of_conduct: @user.checked_code_of_conduct,
|
||||
checked_terms_and_conditions: @user.checked_terms_and_conditions,
|
||||
display_sponsors: @user.display_sponsors,
|
||||
display_announcements: @user.display_announcements,
|
||||
trusted: @user.trusted,
|
||||
moderator_for_tags: @user.moderator_for_tags,
|
||||
config_body_class: @user.config_body_class,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class UserPolicy < ApplicationPolicy
|
|||
contact_consent
|
||||
currently_hacking_on
|
||||
currently_learning
|
||||
display_announcements
|
||||
display_sponsors dribbble_url
|
||||
editor_version education email
|
||||
email_badge_notifications
|
||||
|
|
|
|||
|
|
@ -46,8 +46,25 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-card grid gap-6 p-6 mb-6">
|
||||
<header>
|
||||
<h3 class="mb-2">Announcements</h3>
|
||||
<p>You have the option to dismiss announcements. Announcements are used to inform you on important site-wide information, like updates and events.</p>
|
||||
</header>
|
||||
|
||||
<%= form_for(@user, html: { id: nil, class: "grid gap-4" }) do |f| %>
|
||||
<div class="crayons-field crayons-field--checkbox">
|
||||
<%= f.check_box :display_announcements, class: "crayons-checkbox" %>
|
||||
<%= f.label :display_announcements, "Display Announcements (When browsing)", class: "crayons-field__label" %>
|
||||
</div>
|
||||
|
||||
<%= f.hidden_field :tab, value: @tab, id: nil %>
|
||||
<div><button type="submit" class="crayons-btn">Save Announcements Settings</button></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-card grid gap-4 p-6 mb-6">
|
||||
<h3>Export content</h3>
|
||||
<h3>Export Content</h3>
|
||||
|
||||
<% if @user.export_requested? %>
|
||||
<div class="crayons-notice crayons-notice--warning">
|
||||
|
|
@ -62,7 +79,7 @@
|
|||
<%= f.label :export_requested, "Request an export of your content", class: "crayons-field__label" %>
|
||||
</div>
|
||||
<%= f.hidden_field :tab, value: @tab, id: nil %>
|
||||
<div><button type="submit" class="crayons-btn">Submit data request</button></div>
|
||||
<div><button type="submit" class="crayons-btn">Submit Data Request</button></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddDisplayAnnouncementsBooleanToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :display_announcements, :boolean, default: true
|
||||
end
|
||||
end
|
||||
|
|
@ -1164,6 +1164,7 @@ ActiveRecord::Schema.define(version: 2020_06_08_175130) do
|
|||
t.string "currently_hacking_on"
|
||||
t.string "currently_learning"
|
||||
t.string "currently_streaming_on"
|
||||
t.boolean "display_announcements", default: true
|
||||
t.boolean "display_sponsors", default: true
|
||||
t.string "dribbble_url"
|
||||
t.string "editor_version", default: "v1"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ RSpec.describe "UserSettings", type: :request do
|
|||
expect(response.body).to include("Style Customization")
|
||||
end
|
||||
|
||||
it "displays content on misc tab properly" do
|
||||
get "/settings/misc"
|
||||
expect(response.body).to include("Connect", "Languages", "Sponsors", "Announcements", "Export Content")
|
||||
end
|
||||
|
||||
it "displays content on RSS tab properly" do
|
||||
get "/settings/publishing-from-rss"
|
||||
title = "Publishing to #{ApplicationConfig['COMMUNITY_NAME']} from RSS"
|
||||
|
|
@ -188,6 +193,12 @@ RSpec.describe "UserSettings", type: :request do
|
|||
expect(user.reload.mod_roundrobin_notifications).to be(true)
|
||||
end
|
||||
|
||||
it "updates the users announcement display preferences" do
|
||||
expect do
|
||||
put "/users/#{user.id}", params: { user: { tab: "misc", display_announcements: 0 } }
|
||||
end.to change { user.reload.display_announcements }.from(true).to(false)
|
||||
end
|
||||
|
||||
it "disables community-success notifications" do
|
||||
put "/users/#{user.id}", params: { user: { tab: "notifications", mod_roundrobin_notifications: 0 } }
|
||||
expect(user.reload.mod_roundrobin_notifications).to be(false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue