From 6c71369df57edb93e483d98b3b59151830d27b20 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Wed, 19 Aug 2020 14:54:40 -0400 Subject: [PATCH] [deploy] Add community_name to site config (#9864) * Add community_name to site config * Fix a spec * Remove SiteConfig from constants * Change subjects to method * Fix subjects method * Fix linting --- app/controllers/admin/configs_controller.rb | 1 + app/controllers/admin/welcome_controller.rb | 2 +- .../concerns/verify_setup_completed.rb | 1 + .../email_subscriptions_controller.rb | 24 ++++++----- app/controllers/stories_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/feedback_messages_helper.rb | 20 +++++----- app/labor/badge_rewarder.rb | 4 +- app/lib/constants/site_config.rb | 4 ++ app/liquid_tags/reddit_tag.rb | 2 +- app/mailers/application_mailer.rb | 2 +- app/mailers/digest_mailer.rb | 2 +- app/mailers/notify_mailer.rb | 20 +++++----- app/mailers/verification_mailer.rb | 4 +- app/models/site_config.rb | 1 + app/views/admin/configs/show.html.erb | 9 +++++ app/views/html_variants/_form.html.erb | 2 +- .../moderations/_mod_sidebar_right.html.erb | 2 +- .../follows/send_email_notification_worker.rb | 2 +- db/seeds.rb | 2 +- spec/helpers/application_helper_spec.rb | 4 +- spec/helpers/feedback_messages_helper_spec.rb | 6 +-- spec/mailers/digest_mailer_spec.rb | 2 +- spec/mailers/notify_mailer_spec.rb | 40 +++++++++---------- .../mailers/previews/notify_mailer_preview.rb | 2 +- spec/mailers/verification_mailer_spec.rb | 2 +- spec/requests/admin/configs_spec.rb | 11 ++++- spec/requests/admin/users_spec.rb | 2 +- spec/requests/articles/articles_show_spec.rb | 2 +- spec/requests/pages_spec.rb | 6 +-- spec/requests/service_worker_spec.rb | 2 +- spec/requests/user/user_settings_spec.rb | 2 +- .../user_logs_in_with_github_spec.rb | 2 +- .../user_logs_in_with_twitter_spec.rb | 2 +- .../user_views_an_organization_spec.rb | 2 +- spec/system/user/view_user_index_spec.rb | 2 +- .../unsubscribe.html.erb_spec.rb | 2 +- 38 files changed, 114 insertions(+), 87 deletions(-) diff --git a/app/controllers/admin/configs_controller.rb b/app/controllers/admin/configs_controller.rb index ea9f302b2..6ce3ecf65 100644 --- a/app/controllers/admin/configs_controller.rb +++ b/app/controllers/admin/configs_controller.rb @@ -93,6 +93,7 @@ module Admin def community_params %i[ + community_name community_description community_member_label community_action diff --git a/app/controllers/admin/welcome_controller.rb b/app/controllers/admin/welcome_controller.rb index 3235eba16..834516c2c 100644 --- a/app/controllers/admin/welcome_controller.rb +++ b/app/controllers/admin/welcome_controller.rb @@ -25,7 +25,7 @@ module Admin tags: welcome --- - Hey there! Welcome to #{ApplicationConfig['COMMUNITY_NAME']}! + Hey there! Welcome to #{SiteConfig.community_name}! ![WELCOME TO THE INTERNET](https://slack-imgs.com/?c=1&url=http%3A%2F%2Fmedia0.giphy.com%2Fmedia%2FzhbrTTpmSCYog%2Fgiphy-downsized.gif) diff --git a/app/controllers/concerns/verify_setup_completed.rb b/app/controllers/concerns/verify_setup_completed.rb index 98d2d494d..7af57783f 100644 --- a/app/controllers/concerns/verify_setup_completed.rb +++ b/app/controllers/concerns/verify_setup_completed.rb @@ -4,6 +4,7 @@ module VerifySetupCompleted module_function MANDATORY_CONFIGS = %i[ + community_name community_description community_action tagline diff --git a/app/controllers/email_subscriptions_controller.rb b/app/controllers/email_subscriptions_controller.rb index 6c062e97c..cd522e744 100644 --- a/app/controllers/email_subscriptions_controller.rb +++ b/app/controllers/email_subscriptions_controller.rb @@ -1,25 +1,27 @@ class EmailSubscriptionsController < ApplicationController - PREFERRED_EMAIL_NAME = { - email_digest_periodic: "#{ApplicationConfig['COMMUNITY_NAME']} digest emails", - email_comment_notifications: "comment notifications", - email_follower_notifications: "follower notifications", - email_mention_notifications: "mention notifications", - email_connect_messages: "#{ApplicationConfig['COMMUNITY_NAME']} connect messages", - email_unread_notifications: "unread notifications", - email_badge_notifications: "badge notifications" - }.freeze - def unsubscribe verified_params = Rails.application.message_verifier(:unsubscribe).verify(params[:ut]) if verified_params[:expires_at] > Time.current user = User.find(verified_params[:user_id]) user.update(verified_params[:email_type] => false) - @email_type = PREFERRED_EMAIL_NAME.fetch(verified_params[:email_type], "this list") + @email_type = preferred_email_name.fetch(verified_params[:email_type], "this list") else render "invalid_token" end rescue ActiveSupport::MessageVerifier::InvalidSignature not_found end + + def preferred_email_name + { + email_digest_periodic: "#{SiteConfig.community_name} digest emails", + email_comment_notifications: "comment notifications", + email_follower_notifications: "follower notifications", + email_mention_notifications: "mention notifications", + email_connect_messages: "#{SiteConfig.community_name} connect messages", + email_unread_notifications: "unread notifications", + email_badge_notifications: "badge notifications" + }.freeze + end end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 0618aa930..c8451b4f4 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -402,7 +402,7 @@ class StoriesController < ApplicationController "publisher": { "@context": "http://schema.org", "@type": "Organization", - "name": "#{ApplicationConfig['COMMUNITY_NAME']} Community", + "name": "#{SiteConfig.community_name} Community", "logo": { "@context": "http://schema.org", "@type": "ImageObject", diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5acdac207..df92e1daf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -335,7 +335,7 @@ class UsersController < ApplicationController end def handle_account_tab - community_name = ApplicationConfig["COMMUNITY_NAME"] + community_name = SiteConfig.community_name @email_body = <<~HEREDOC Hello #{community_name} Team,\n I would like to delete my account.\n diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 923f5acf1..1aaff43fe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -173,7 +173,7 @@ module ApplicationHelper end def community_name - @community_name ||= ApplicationConfig["COMMUNITY_NAME"] # rubocop:disable Rails/HelperInstanceVariable + @community_name ||= SiteConfig.community_name # rubocop:disable Rails/HelperInstanceVariable end def community_qualified_name diff --git a/app/helpers/feedback_messages_helper.rb b/app/helpers/feedback_messages_helper.rb index 8850a20f4..765208022 100644 --- a/app/helpers/feedback_messages_helper.rb +++ b/app/helpers/feedback_messages_helper.rb @@ -3,43 +3,43 @@ module FeedbackMessagesHelper body = <<~HEREDOC Hello, - It has been brought to our attention that you have violated the #{ApplicationConfig['COMMUNITY_NAME']} Code of Conduct and/or Terms of Use. + It has been brought to our attention that you have violated the #{SiteConfig.community_name} Code of Conduct and/or Terms of Use. - If this behavior continues, we may need to suspend your #{ApplicationConfig['COMMUNITY_NAME']} account. + If this behavior continues, we may need to suspend your #{SiteConfig.community_name} account. If you think that there's been a mistake, please reply to this email and we will take another look. - #{ApplicationConfig['COMMUNITY_NAME']} Team + #{SiteConfig.community_name} Team HEREDOC - { subject: "#{ApplicationConfig['COMMUNITY_NAME']} Code of Conduct Violation", body: body }.freeze + { subject: "#{SiteConfig.community_name} Code of Conduct Violation", body: body }.freeze end def reporter_email_details body = <<~HEREDOC Hi there, - Thank you for flagging content that may be in violation of the #{ApplicationConfig['COMMUNITY_NAME']} Code of Conduct and/or our Terms of Use. We are looking into your report and will take appropriate action. + Thank you for flagging content that may be in violation of the #{SiteConfig.community_name} Code of Conduct and/or our Terms of Use. We are looking into your report and will take appropriate action. We appreciate your help as we work to foster a positive and inclusive environment for all! - #{ApplicationConfig['COMMUNITY_NAME']} Team + #{SiteConfig.community_name} Team HEREDOC - { subject: "#{ApplicationConfig['COMMUNITY_NAME']} Report", body: body }.freeze + { subject: "#{SiteConfig.community_name} Report", body: body }.freeze end def affected_email_details body = <<~HEREDOC Hi there, - We noticed some comments (made by others) on your post that violate the #{ApplicationConfig['COMMUNITY_NAME']} Code of Conduct and/or our Terms of Use. We have zero tolerance for such behavior and are taking appropriate action. + We noticed some comments (made by others) on your post that violate the #{SiteConfig.community_name} Code of Conduct and/or our Terms of Use. We have zero tolerance for such behavior and are taking appropriate action. Thanks for being awesome, and please don't hesitate to email us with any questions! We welcome all feedback and ideas as we continue working to foster an open and inclusive community. - #{ApplicationConfig['COMMUNITY_NAME']} Team + #{SiteConfig.community_name} Team HEREDOC - { subject: "Courtesy Notice from #{ApplicationConfig['COMMUNITY_NAME']}", body: body }.freeze + { subject: "Courtesy Notice from #{SiteConfig.community_name}", body: body }.freeze end end diff --git a/app/labor/badge_rewarder.rb b/app/labor/badge_rewarder.rb index 34cc80914..3280c1d3c 100644 --- a/app/labor/badge_rewarder.rb +++ b/app/labor/badge_rewarder.rb @@ -3,7 +3,7 @@ module BadgeRewarder REPOSITORIES = ["thepracticaldev/dev.to", "thepracticaldev/DEV-ios", "thepracticaldev/DEV-Android"].freeze LONGEST_STREAK_WEEKS = 16 - LONGEST_STREAK_MESSAGE = "16 weeks! You've achieved the longest #{ApplicationConfig['COMMUNITY_NAME']} writing " \ + LONGEST_STREAK_MESSAGE = "16 weeks! You've achieved the longest writing " \ "streak possible. This makes you eligible for special quests in the future. Keep up the amazing contributions to" \ " our community!".freeze @@ -12,7 +12,7 @@ module BadgeRewarder def self.award_yearly_club_badges total_years = Time.current.year - SiteConfig.community_copyright_start_year.to_i (1..total_years).each do |i| - message = "Happy #{ApplicationConfig['COMMUNITY_NAME']} birthday! " \ + message = "Happy #{SiteConfig.community_name} birthday! " \ "Can you believe it's been #{i} #{'year'.pluralize(i)} already?!" badge = Badge.find_by!(slug: "#{YEARS[i]}-year-club") User.registered.where("created_at < ? AND created_at > ?", i.year.ago, i.year.ago - 2.days).find_each do |user| diff --git a/app/lib/constants/site_config.rb b/app/lib/constants/site_config.rb index 9bf2c531e..c891ded9d 100644 --- a/app/lib/constants/site_config.rb +++ b/app/lib/constants/site_config.rb @@ -33,6 +33,10 @@ module Constants description: "Used in meta description tags etc.", placeholder: "A fabulous community of kind and welcoming people." }, + community_name: { + description: "Primary name... e.g. DEV", + placeholder: "New Forem" + }, community_member_label: { description: "Used to determine what a member will be called e.g developer, hobbyist etc.", placeholder: "user" diff --git a/app/liquid_tags/reddit_tag.rb b/app/liquid_tags/reddit_tag.rb index 98b61b78d..ebde37a4b 100644 --- a/app/liquid_tags/reddit_tag.rb +++ b/app/liquid_tags/reddit_tag.rb @@ -34,7 +34,7 @@ class RedditTag < LiquidTagBase # Requests to Reddit require a custom `User-Agent` header to prevent 429 errors json = HTTParty.get("#{@url}.json", - headers: { "User-Agent" => "#{ApplicationConfig['COMMUNITY_NAME']} (#{URL.url})" }) + headers: { "User-Agent" => "#{SiteConfig.community_name} (#{URL.url})" }) # The JSON response is an array with two items. # The first one is the post itself, the second one are the comments diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3408e36df..6de404ff7 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -12,7 +12,7 @@ class ApplicationMailer < ActionMailer::Base ) def email_from(topic) - "#{ApplicationConfig['COMMUNITY_NAME']} #{topic} <#{SiteConfig.email_addresses[:default]}>" + "#{SiteConfig.community_name} #{topic} <#{SiteConfig.email_addresses[:default]}>" end def generate_unsubscribe_token(id, email_type) diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index 145009a92..4b200ed97 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -26,7 +26,7 @@ class DigestMailer < ApplicationMailer end def email_end_phrase - community_name = ApplicationConfig["COMMUNITY_NAME"] + community_name = SiteConfig.community_name # "more trending posts" won the previous split test # Included more often as per explore-exploit algorithm [ diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 07e905eef..17b2259e6 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,8 +1,4 @@ class NotifyMailer < ApplicationMailer - SUBJECTS = { - new_follower_email: "just followed you on #{ApplicationConfig['COMMUNITY_NAME']}".freeze - }.freeze - def new_reply_email @comment = params[:comment] @user = @comment.parent_user @@ -22,7 +18,7 @@ class NotifyMailer < ApplicationMailer @follower = follow.follower @unsubscribe = generate_unsubscribe_token(@user.id, :email_follower_notifications) - mail(to: @user.email, subject: "#{@follower.name} #{SUBJECTS[__method__]}") + mail(to: @user.email, subject: "#{@follower.name} #{subjects[__method__]}") end def new_mention_email @@ -43,7 +39,7 @@ class NotifyMailer < ApplicationMailer @unread_notifications_count = @user.notifications.unread.count @unsubscribe = generate_unsubscribe_token(@user.id, :email_unread_notifications) - subject = "🔥 You have #{@unread_notifications_count} unread notifications on #{ApplicationConfig['COMMUNITY_NAME']}" + subject = "🔥 You have #{@unread_notifications_count} unread notifications on #{SiteConfig.community_name}" mail(to: @user.email, subject: subject) end @@ -106,7 +102,7 @@ class NotifyMailer < ApplicationMailer def account_deleted_email @name = params[:name] - subject = "#{ApplicationConfig['COMMUNITY_NAME']} - Account Deletion Confirmation" + subject = "#{SiteConfig.community_name} - Account Deletion Confirmation" mail(to: params[:email], subject: subject) end @@ -115,7 +111,7 @@ class NotifyMailer < ApplicationMailer @name = user.name @token = params[:token] - subject = "#{ApplicationConfig['COMMUNITY_NAME']} - Account Deletion Requested" + subject = "#{SiteConfig.community_name} - Account Deletion Requested" mail(to: user.email, subject: subject) end @@ -140,7 +136,13 @@ class NotifyMailer < ApplicationMailer def trusted_role_email @user = params[:user] - subject = "You've been upgraded to #{ApplicationConfig['COMMUNITY_NAME']} Community mod status!" + subject = "You've been upgraded to #{SiteConfig.community_name} Community mod status!" mail(to: @user.email, subject: subject) end + + def subjects + { + new_follower_email: "just followed you on #{SiteConfig.community_name}".freeze + }.freeze + end end diff --git a/app/mailers/verification_mailer.rb b/app/mailers/verification_mailer.rb index fe140586e..eb846f4b3 100644 --- a/app/mailers/verification_mailer.rb +++ b/app/mailers/verification_mailer.rb @@ -1,6 +1,6 @@ class VerificationMailer < ApplicationMailer default from: lambda { - "#{ApplicationConfig['COMMUNITY_NAME']} Email Verification <#{SiteConfig.email_addresses[:default]}>" + "#{SiteConfig.community_name} Email Verification <#{SiteConfig.email_addresses[:default]}>" } def account_ownership_verification_email @@ -8,6 +8,6 @@ class VerificationMailer < ApplicationMailer email_authorization = EmailAuthorization.create(user: @user, type_of: "account_ownership") @confirmation_token = email_authorization.confirmation_token - mail(to: @user.email, subject: "Verify Your #{ApplicationConfig['COMMUNITY_NAME']} Account Ownership") + mail(to: @user.email, subject: "Verify Your #{SiteConfig.community_name} Account Ownership") end end diff --git a/app/models/site_config.rb b/app/models/site_config.rb index 8bc41a31f..026caef7e 100644 --- a/app/models/site_config.rb +++ b/app/models/site_config.rb @@ -26,6 +26,7 @@ class SiteConfig < RailsSettings::Base field :campaign_articles_require_approval, type: :boolean, default: 0 # Community Content + field :community_name, type: :string, default: ApplicationConfig["COMMUNITY_NAME"] || "New Forem" field :community_description, type: :string field :community_member_label, type: :string, default: "user" field :community_action, type: :string diff --git a/app/views/admin/configs/show.html.erb b/app/views/admin/configs/show.html.erb index 1b8b5459b..683c97b2e 100644 --- a/app/views/admin/configs/show.html.erb +++ b/app/views/admin/configs/show.html.erb @@ -208,6 +208,15 @@ expanded: "false" } %>
+
+ <%= admin_config_label :community_name %> + <%= f.text_field :community_name, + class: "form-control", + value: SiteConfig.community_name, + placeholder: Constants::SiteConfig::DETAILS[:community_name][:placeholder] %> +
<%= Constants::SiteConfig::DETAILS[:community_name][:description] %>
+
+
<%= admin_config_label :community_description %> <%= f.text_field :community_description, diff --git a/app/views/html_variants/_form.html.erb b/app/views/html_variants/_form.html.erb index 48786b869..d3c53c10f 100644 --- a/app/views/html_variants/_form.html.erb +++ b/app/views/html_variants/_form.html.erb @@ -20,7 +20,7 @@ <%= f.text_field :name, placeholder: "Unique, descriptive name" %> <% end %> <%= f.label :html %> - <%= f.text_area :html, placeholder: "HTML to be shown. Make sure all CSS is properly scoped, and all HTML tags are closed, etc. Manditory field." %> + <%= f.text_area :html, placeholder: "HTML to be shown. Make sure all CSS is properly scoped, and all HTML tags are closed, etc. Mandatory field." %>
<%= f.label :published %> <%= f.check_box :published %> diff --git a/app/views/moderations/_mod_sidebar_right.html.erb b/app/views/moderations/_mod_sidebar_right.html.erb index d0e7df7fc..d4c0558c4 100644 --- a/app/views/moderations/_mod_sidebar_right.html.erb +++ b/app/views/moderations/_mod_sidebar_right.html.erb @@ -3,7 +3,7 @@

Hello! 👋

- Thank you for helping to keep <%= ApplicationConfig["COMMUNITY_NAME"] %> safe! ❤️ + Thank you for helping to keep <%= SiteConfig.community_name %> safe! ❤️

diff --git a/app/workers/follows/send_email_notification_worker.rb b/app/workers/follows/send_email_notification_worker.rb index 9db5647f7..c107921b7 100644 --- a/app/workers/follows/send_email_notification_worker.rb +++ b/app/workers/follows/send_email_notification_worker.rb @@ -9,7 +9,7 @@ module Follows return if EmailMessage.where(user_id: follow.followable_id) .where("sent_at > ?", rand(15..35).hours.ago) - .exists?(["subject LIKE ?", "%#{NotifyMailer::SUBJECTS[:new_follower_email]}"]) + .exists?(["subject LIKE ?", "%#{NotifyMailer.subjects[:new_follower_email]}"]) mailer.constantize.with(follow: follow).new_follower_email.deliver_now end diff --git a/db/seeds.rb b/db/seeds.rb index b220a4946..7f342ae65 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -302,7 +302,7 @@ seeder.create_if_none(Broadcast) do tags: welcome --- - Hey there! Welcome to #{ApplicationConfig['COMMUNITY_NAME']}! + Hey there! Welcome to #{SiteConfig.community_name}! Leave a comment below to introduce yourself to the community!✌️ HEREDOC diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index df92e8fde..82277cdaf 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,14 +5,14 @@ RSpec.describe ApplicationHelper, type: :helper do describe "#community_name" do it "equals to the community name" do - allow(ApplicationConfig).to receive(:[]).with("COMMUNITY_NAME").and_return("SLOAN") + SiteConfig.community_name = "SLOAN" expect(helper.community_name).to eq("SLOAN") end end describe "#community_qualified_name" do it "equals to the full qualified community name" do - expected_name = "#{ApplicationConfig['COMMUNITY_NAME']} Community" + expected_name = "#{SiteConfig.community_name} Community" expect(helper.community_qualified_name).to eq(expected_name) end end diff --git a/spec/helpers/feedback_messages_helper_spec.rb b/spec/helpers/feedback_messages_helper_spec.rb index 519ac12ab..d357be8b5 100644 --- a/spec/helpers/feedback_messages_helper_spec.rb +++ b/spec/helpers/feedback_messages_helper_spec.rb @@ -4,7 +4,7 @@ RSpec.describe FeedbackMessagesHelper, type: :helper do describe "#offender_email_details" do it "have proper subject and body" do expect(helper.offender_email_details).to include( - subject: "#{ApplicationConfig['COMMUNITY_NAME']} Code of Conduct Violation", + subject: "#{SiteConfig.community_name} Code of Conduct Violation", body: a_string_starting_with("Hello"), ) end @@ -13,7 +13,7 @@ RSpec.describe FeedbackMessagesHelper, type: :helper do describe "#reporter_email_details" do it "have proper subject and body" do expect(helper.reporter_email_details).to include( - subject: "#{ApplicationConfig['COMMUNITY_NAME']} Report", + subject: "#{SiteConfig.community_name} Report", body: a_string_starting_with("Hi"), ) end @@ -22,7 +22,7 @@ RSpec.describe FeedbackMessagesHelper, type: :helper do describe "#affected_email_details" do it "have proper subject and body" do expect(helper.affected_email_details).to include( - subject: "Courtesy Notice from #{ApplicationConfig['COMMUNITY_NAME']}", + subject: "Courtesy Notice from #{SiteConfig.community_name}", body: a_string_starting_with("Hi"), ) end diff --git a/spec/mailers/digest_mailer_spec.rb b/spec/mailers/digest_mailer_spec.rb index 66e9b4780..7393589f2 100644 --- a/spec/mailers/digest_mailer_spec.rb +++ b/spec/mailers/digest_mailer_spec.rb @@ -15,7 +15,7 @@ RSpec.describe DigestMailer, type: :mailer do expect(email.subject).not_to be_nil expect(email.to).to eq([user.email]) expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Digest <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Digest <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end diff --git a/spec/mailers/notify_mailer_spec.rb b/spec/mailers/notify_mailer_spec.rb index 97ffd1c67..c79aba41a 100644 --- a/spec/mailers/notify_mailer_spec.rb +++ b/spec/mailers/notify_mailer_spec.rb @@ -16,7 +16,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -41,12 +41,12 @@ RSpec.describe NotifyMailer, type: :mailer do before { user2.follow(user) } it "renders proper subject" do - expect(email.subject).to eq("#{user2.name} just followed you on #{ApplicationConfig['COMMUNITY_NAME']}") + expect(email.subject).to eq("#{user2.name} just followed you on #{SiteConfig.community_name}") end it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -75,7 +75,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -98,12 +98,12 @@ RSpec.describe NotifyMailer, type: :mailer do let(:email) { described_class.with(user: user).unread_notifications_email } it "renders proper subject" do - expect(email.subject).to eq("🔥 You have 0 unread notifications on #{ApplicationConfig['COMMUNITY_NAME']}") + expect(email.subject).to eq("🔥 You have 0 unread notifications on #{SiteConfig.community_name}") end it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -131,7 +131,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -170,7 +170,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -268,7 +268,7 @@ RSpec.describe NotifyMailer, type: :mailer do let(:email_params) do { email_to: user.email, - email_subject: "#{ApplicationConfig['COMMUNITY_NAME']} Report Status Update", + email_subject: "#{SiteConfig.community_name} Report Status Update", email_body: "You've violated our code of conduct", email_type: "Reporter", feedback_message_id: feedback_message.id @@ -277,12 +277,12 @@ RSpec.describe NotifyMailer, type: :mailer do let(:email) { described_class.with(email_params).feedback_message_resolution_email } it "renders proper subject" do - expect(email.subject).to eq("#{ApplicationConfig['COMMUNITY_NAME']} Report Status Update") + expect(email.subject).to eq("#{SiteConfig.community_name} Report Status Update") end it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -325,7 +325,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -353,7 +353,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -376,12 +376,12 @@ RSpec.describe NotifyMailer, type: :mailer do let(:email) { described_class.with(name: user.name, email: user.email).account_deleted_email } it "renders proper subject" do - expect(email.subject).to eq("#{ApplicationConfig['COMMUNITY_NAME']} - Account Deletion Confirmation") + expect(email.subject).to eq("#{SiteConfig.community_name} - Account Deletion Confirmation") end it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -409,7 +409,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -449,7 +449,7 @@ RSpec.describe NotifyMailer, type: :mailer do it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -473,13 +473,13 @@ RSpec.describe NotifyMailer, type: :mailer do let(:email) { described_class.with(user: user).trusted_role_email } it "renders proper subject" do - expected_subject = "You've been upgraded to #{ApplicationConfig['COMMUNITY_NAME']} Community mod status!" + expected_subject = "You've been upgraded to #{SiteConfig.community_name} Community mod status!" expect(email.subject).to eq(expected_subject) end it "renders proper sender" do expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(expected_from) end @@ -513,7 +513,7 @@ RSpec.describe NotifyMailer, type: :mailer do end it "renders proper sender" do - expected_from = "#{ApplicationConfig['COMMUNITY_NAME']} Community <#{SiteConfig.email_addresses[:default]}>" + expected_from = "#{SiteConfig.community_name} Community <#{SiteConfig.email_addresses[:default]}>" expect(moderator_email.from).to eq([SiteConfig.email_addresses[:default]]) expect(moderator_email["from"].value).to eq(expected_from) diff --git a/spec/mailers/previews/notify_mailer_preview.rb b/spec/mailers/previews/notify_mailer_preview.rb index bec38380a..f27d9d3e1 100644 --- a/spec/mailers/previews/notify_mailer_preview.rb +++ b/spec/mailers/previews/notify_mailer_preview.rb @@ -64,7 +64,7 @@ class NotifyMailerPreview < ActionMailer::Preview HEREDOC params = { email_to: @user.email, - email_subject: "Courtesy notice from #{ApplicationConfig['COMMUNITY_NAME']}", + email_subject: "Courtesy notice from #{SiteConfig.community_name}", email_body: email_body, email_type: "Reporter", feedback_message_id: rand(100) diff --git a/spec/mailers/verification_mailer_spec.rb b/spec/mailers/verification_mailer_spec.rb index 910495fa7..10e6ce0c7 100644 --- a/spec/mailers/verification_mailer_spec.rb +++ b/spec/mailers/verification_mailer_spec.rb @@ -10,7 +10,7 @@ RSpec.describe VerificationMailer, type: :mailer do expect(email.subject).not_to be_nil expect(email.to).to eq([user.email]) expect(email.from).to eq([SiteConfig.email_addresses[:default]]) - from = "#{ApplicationConfig['COMMUNITY_NAME']} Email Verification <#{SiteConfig.email_addresses[:default]}>" + from = "#{SiteConfig.community_name} Email Verification <#{SiteConfig.email_addresses[:default]}>" expect(email["from"].value).to eq(from) end end diff --git a/spec/requests/admin/configs_spec.rb b/spec/requests/admin/configs_spec.rb index f41dc4c99..8fe184d1b 100644 --- a/spec/requests/admin/configs_spec.rb +++ b/spec/requests/admin/configs_spec.rb @@ -82,6 +82,13 @@ RSpec.describe "/admin/config", type: :request do expect(SiteConfig.community_description).to eq(description) end + it "updates the community_name" do + name_magoo = "Hey hey #{rand(100)}" + post "/admin/config", params: { site_config: { community_name: name_magoo }, + confirmation: confirmation_message } + expect(SiteConfig.community_name).to eq(name_magoo) + end + it "updates the community_member_label" do name = "developer" post "/admin/config", params: { site_config: { community_member_label: name }, @@ -306,7 +313,7 @@ RSpec.describe "/admin/config", type: :request do expect(SiteConfig.shop_url).to eq("") get "/privacy" expect(response.body).not_to include(previous_shop_url) - expect(response.body).not_to include("#{ApplicationConfig['COMMUNITY_NAME']} Shop") + expect(response.body).not_to include("#{SiteConfig.community_name} Shop") end it "updates shop url" do @@ -316,7 +323,7 @@ RSpec.describe "/admin/config", type: :request do expect(SiteConfig.shop_url).to eq(expected_shop_url) get "/privacy" expect(response.body).to include(expected_shop_url) - expect(response.body).to include("#{ApplicationConfig['COMMUNITY_NAME']} Shop") + expect(response.body).to include("#{SiteConfig.community_name} Shop") end end end diff --git a/spec/requests/admin/users_spec.rb b/spec/requests/admin/users_spec.rb index 61be07c66..80c95e088 100644 --- a/spec/requests/admin/users_spec.rb +++ b/spec/requests/admin/users_spec.rb @@ -63,7 +63,7 @@ RSpec.describe "admin/users", type: :request do deliveries = ActionMailer::Base.deliveries expect(deliveries.count).to eq(1) - expect(deliveries.first.subject).to eq("Verify Your #{ApplicationConfig['COMMUNITY_NAME']} Account Ownership") + expect(deliveries.first.subject).to eq("Verify Your #{SiteConfig.community_name} Account Ownership") expect(deliveries.first.text_part.body).to include(verification_link) sign_in(user) diff --git a/spec/requests/articles/articles_show_spec.rb b/spec/requests/articles/articles_show_spec.rb index 0674a9bce..fdbda6fe5 100644 --- a/spec/requests/articles/articles_show_spec.rb +++ b/spec/requests/articles/articles_show_spec.rb @@ -36,7 +36,7 @@ RSpec.describe "ArticlesShow", type: :request do "publisher" => { "@context" => "http://schema.org", "@type" => "Organization", - "name" => "#{ApplicationConfig['COMMUNITY_NAME']} Community", + "name" => "#{SiteConfig.community_name} Community", "logo" => { "@context" => "http://schema.org", "@type" => "ImageObject", diff --git a/spec/requests/pages_spec.rb b/spec/requests/pages_spec.rb index 7ce869662..6020fa1ed 100644 --- a/spec/requests/pages_spec.rb +++ b/spec/requests/pages_spec.rb @@ -55,7 +55,7 @@ RSpec.describe "Pages", type: :request do describe "GET /about-listings" do it "has proper headline" do get "/about-listings" - expect(response.body).to include("About #{ApplicationConfig['COMMUNITY_NAME']} Listings") + expect(response.body).to include("About #{SiteConfig.community_name} Listings") end end @@ -76,7 +76,7 @@ RSpec.describe "Pages", type: :request do describe "GET /page/post-a-job" do it "has proper headline" do get "/page/post-a-job" - expect(response.body).to include("Posting a Job on #{ApplicationConfig['COMMUNITY_NAME']} Listings") + expect(response.body).to include("Posting a Job on #{SiteConfig.community_name} Listings") end end @@ -93,7 +93,7 @@ RSpec.describe "Pages", type: :request do get "/privacy" expect(response.body).to include("Privacy Policy") expect(response.body).to include(SiteConfig.shop_url) - expect(response.body).to include("#{ApplicationConfig['COMMUNITY_NAME']} Shop") + expect(response.body).to include("#{SiteConfig.community_name} Shop") end end diff --git a/spec/requests/service_worker_spec.rb b/spec/requests/service_worker_spec.rb index 26b127c87..edb116a35 100644 --- a/spec/requests/service_worker_spec.rb +++ b/spec/requests/service_worker_spec.rb @@ -21,7 +21,7 @@ RSpec.describe "ServiceWorker", type: :request do describe "GET /manifest.json" do it "renders file with proper text" do get "/manifest.json" - expect(response.body).to include("\"name\": \"#{ApplicationConfig['COMMUNITY_NAME']} Community\"") + expect(response.body).to include("\"name\": \"#{SiteConfig.community_name} Community\"") end it "renders json file" do diff --git a/spec/requests/user/user_settings_spec.rb b/spec/requests/user/user_settings_spec.rb index fa3b149ea..9b15ad271 100644 --- a/spec/requests/user/user_settings_spec.rb +++ b/spec/requests/user/user_settings_spec.rb @@ -38,7 +38,7 @@ RSpec.describe "UserSettings", type: :request do it "displays content on RSS tab properly" do get "/settings/publishing-from-rss" - title = "Publishing to #{ApplicationConfig['COMMUNITY_NAME']} from RSS" + title = "Publishing to #{SiteConfig.community_name} from RSS" expect(response.body).to include(title) end diff --git a/spec/system/authentication/user_logs_in_with_github_spec.rb b/spec/system/authentication/user_logs_in_with_github_spec.rb index 8e1b998dd..209d1d0d7 100644 --- a/spec/system/authentication/user_logs_in_with_github_spec.rb +++ b/spec/system/authentication/user_logs_in_with_github_spec.rb @@ -76,7 +76,7 @@ RSpec.describe "Authenticating with GitHub" do expect(page).to have_current_path("/users/sign_in") expect(page).to have_link(sign_in_link) - expect(page).to have_link("All about #{ApplicationConfig['COMMUNITY_NAME']}") + expect(page).to have_link("All about #{SiteConfig.community_name}") end it "notifies Datadog about a callback error" do diff --git a/spec/system/authentication/user_logs_in_with_twitter_spec.rb b/spec/system/authentication/user_logs_in_with_twitter_spec.rb index e56a76985..8dd70111f 100644 --- a/spec/system/authentication/user_logs_in_with_twitter_spec.rb +++ b/spec/system/authentication/user_logs_in_with_twitter_spec.rb @@ -72,7 +72,7 @@ RSpec.describe "Authenticating with Twitter" do expect(page).to have_current_path("/users/sign_in") expect(page).to have_link(sign_in_link) - expect(page).to have_link("All about #{ApplicationConfig['COMMUNITY_NAME']}") + expect(page).to have_link("All about #{SiteConfig.community_name}") end it "notifies Datadog about a callback error" do diff --git a/spec/system/organization/user_views_an_organization_spec.rb b/spec/system/organization/user_views_an_organization_spec.rb index e47bca3ce..5b6e9e30f 100644 --- a/spec/system/organization/user_views_an_organization_spec.rb +++ b/spec/system/organization/user_views_an_organization_spec.rb @@ -31,7 +31,7 @@ RSpec.describe "Organization index", type: :system do end it "shows the proper title tag" do - expect(page).to have_title("#{organization.name} - #{ApplicationConfig['COMMUNITY_NAME']}") + expect(page).to have_title("#{organization.name} - #{SiteConfig.community_name}") end end diff --git a/spec/system/user/view_user_index_spec.rb b/spec/system/user/view_user_index_spec.rb index 6bf6d4345..ac27e5bcb 100644 --- a/spec/system/user/view_user_index_spec.rb +++ b/spec/system/user/view_user_index_spec.rb @@ -19,7 +19,7 @@ RSpec.describe "User index", type: :system, stub_elasticsearch: true do end it "shows proper title tag" do - expect(page).to have_title("#{user.name} - #{ApplicationConfig['COMMUNITY_NAME']}") + expect(page).to have_title("#{user.name} - #{SiteConfig.community_name}") end it "shows user's articles" do diff --git a/spec/views/email_subscriptions/unsubscribe.html.erb_spec.rb b/spec/views/email_subscriptions/unsubscribe.html.erb_spec.rb index 43fec46a3..b8b6aa3ee 100644 --- a/spec/views/email_subscriptions/unsubscribe.html.erb_spec.rb +++ b/spec/views/email_subscriptions/unsubscribe.html.erb_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe "email_subscriptions/unsubscribe.html.erb", type: :view do it "works" do - assign(:email_type, "#{ApplicationConfig['COMMUNITY_NAME']} digest emails") + assign(:email_type, "#{SiteConfig.community_name} digest emails") render Approvals.verify(rendered, name: "email_subscriptions/unsubscribe", format: :html) end