diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index f2d3b69ab..fb7c2e856 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -71,7 +71,7 @@ module Admin html = view_context.render partial: "pages/coc_text", locals: { community_name: view_context.community_name, - email_link: view_context.email_link + contact_link: view_context.contact_link } @page = case slug when Page::CODE_OF_CONDUCT_SLUG diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index e991153fc..ce2df2cd3 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -85,7 +85,7 @@ module Admin user = User.find(params[:id]) send_to_admin = params[:send_to_admin].to_boolean if send_to_admin - email = ::ForemInstance.email + email = ::ForemInstance.contact_email receiver = "admin" else email = user.email diff --git a/app/controllers/api_secrets_controller.rb b/app/controllers/api_secrets_controller.rb index 67847aa99..b35975831 100644 --- a/app/controllers/api_secrets_controller.rb +++ b/app/controllers/api_secrets_controller.rb @@ -24,7 +24,7 @@ class ApiSecretsController < ApplicationController flash[:notice] = I18n.t("api_secrets_controller.revoked") else flash[:error] = - I18n.t("errors.messages.try_again_email", email: ForemInstance.email) + I18n.t("errors.messages.try_again_email", email: ForemInstance.contact_email) end redirect_back(fallback_location: root_path) diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index addf55f90..c802e4694 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -21,7 +21,7 @@ class ConfirmationsController < Devise::ConfirmationsController self.resource = resource_class.send_confirmation_instructions(resource_params) resource.errors.clear # Don't leak user information, like paranoid mode. - message = I18n.t("confirmations_controller.email_sent", email: ForemInstance.email) + message = I18n.t("confirmations_controller.email_sent", email: ForemInstance.contact_email) flash.now[:global_notice] = message render :new end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f7b306818..bcc1e038b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -130,7 +130,7 @@ class UsersController < ApplicationController def remove_identity set_current_tab("account") - error_message = I18n.t("errors.messages.try_again_email", email: ForemInstance.email) + error_message = I18n.t("errors.messages.try_again_email", email: ForemInstance.contact_email) unless Authentication::Providers.enabled?(params[:provider]) flash[:error] = error_message redirect_to user_settings_path(@tab) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6476530d..0debdd95f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -227,8 +227,8 @@ module ApplicationHelper link_to body, collection.path, **kwargs end - def email_link(text: nil, additional_info: nil) - email = ForemInstance.email + def contact_link(text: nil, additional_info: nil) + email = ForemInstance.contact_email mail_to email, text || email, additional_info end diff --git a/app/lib/constants/settings/general.rb b/app/lib/constants/settings/general.rb index f191d1642..8cebf18bb 100644 --- a/app/lib/constants/settings/general.rb +++ b/app/lib/constants/settings/general.rb @@ -5,6 +5,11 @@ module Constants SVG_PLACEHOLDER = "".freeze DETAILS = { + contact_email: { + description: "Used for contact links. Please provide an email address where users " \ + "can get in touch with you or your team.", + placeholder: "hello@example.com" + }, credit_prices_in_cents: { small: { description: "Price for small credit purchase (<10 credits).", diff --git a/app/models/article.rb b/app/models/article.rb index 998e1d0a5..c004a2058 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -32,7 +32,7 @@ class Article < ApplicationRecord PROHIBITED_UNICODE_CHARACTERS_REGEX = /[\u202a-\u202e]/ # BIDI embedding controls def self.unique_url_error - I18n.t("models.article.unique_url", email: ForemInstance.email) + I18n.t("models.article.unique_url", email: ForemInstance.contact_email) end has_one :discussion_lock, dependent: :delete diff --git a/app/models/forem_instance.rb b/app/models/forem_instance.rb index 59dcf4fc4..008a67d89 100644 --- a/app/models/forem_instance.rb +++ b/app/models/forem_instance.rb @@ -13,6 +13,10 @@ class ForemInstance ApplicationConfig["DEFAULT_EMAIL"] end + def self.contact_email + Settings::General.contact_email + end + # Return true if we are operating on a local installation, false otherwise def self.local? Settings::General.app_domain.include?("localhost") diff --git a/app/models/settings/general.rb b/app/models/settings/general.rb index 8cb8fa790..9932220e2 100644 --- a/app/models/settings/general.rb +++ b/app/models/settings/general.rb @@ -17,7 +17,8 @@ module Settings setting :health_check_token, type: :string setting :video_encoder_key, type: :string - # Email digest frequency + # Emails + setting :contact_email, type: :string, default: ApplicationConfig["DEFAULT_EMAIL"] setting :periodic_email_digest, type: :integer, default: 2 # Google Analytics Tracking ID, e.g. UA-71991000-1 diff --git a/app/services/error_messages/clean.rb b/app/services/error_messages/clean.rb index 1a94dfadc..908f76134 100644 --- a/app/services/error_messages/clean.rb +++ b/app/services/error_messages/clean.rb @@ -5,7 +5,7 @@ module ErrorMessages def self.call(error_message) return error_message unless error_message.match?(FRONTMATTER_ERROR) - I18n.t("services.error_messages.clean.parse_error", email: ForemInstance.email) + I18n.t("services.error_messages.clean.parse_error", email: ForemInstance.contact_email) end end end diff --git a/app/views/admin/settings/forms/_email_digest_frequency.html.erb b/app/views/admin/settings/forms/_email_digest_frequency.html.erb deleted file mode 100644 index 461e24f97..000000000 --- a/app/views/admin/settings/forms/_email_digest_frequency.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -<%= form_for(Settings::General.new, - url: admin_settings_general_settings_path, - html: { data: { - action: "submit->config#updateConfigurationSettings", - testid: "emailDigestSectionForm" - } }) do |f| %> -
- <%= render partial: "admin/shared/card_header", - locals: { - header: "Email digest frequency", - state: "collapse", - target: "emailDigestBodyContainer", - expanded: false - } %> -
-
-
- <%= admin_config_label :periodic_email_digest %> - <%= admin_config_description Constants::Settings::General::DETAILS[:periodic_email_digest][:description] %> - <%= f.number_field :periodic_email_digest, - class: "crayons-textfield", - value: Settings::General.periodic_email_digest, - placeholder: Constants::Settings::General::DETAILS[:periodic_email_digest][:placeholder] %> -
-
- <%= render "update_setting_button", f: f %> -
-
-<% end %> diff --git a/app/views/admin/settings/forms/_emails.html.erb b/app/views/admin/settings/forms/_emails.html.erb index aef8a2398..40c9fc1ad 100644 --- a/app/views/admin/settings/forms/_emails.html.erb +++ b/app/views/admin/settings/forms/_emails.html.erb @@ -1,22 +1,38 @@ -
- <%= render partial: "admin/shared/card_header", - locals: { - header: "Emails", - state: "collapse", - target: "emailBodyContainer", - expanded: false - } %> -
-
-
- -
- Default (set via default_email environment variable) +<%= form_for(Settings::General.new, + url: admin_settings_general_settings_path, + html: { data: { + action: "submit->config#updateConfigurationSettings", + testid: "emailForm" + } }) do |f| %> +
+ <%= render partial: "admin/shared/card_header", + locals: { + header: "Emails", + state: "collapse", + target: "emailBodyContainer", + expanded: false + } %> +
+
+
+ <%= admin_config_label :contact_email %> + <%= admin_config_description Constants::Settings::General::DETAILS[:contact_email][:description] %> + <%= f.text_field :contact_email, + class: "crayons-textfield", + value: Settings::General.contact_email, + placeholder: Constants::Settings::General::DETAILS[:contact_email][:placeholder] %>
- -
-
+ +
+ <%= admin_config_label :periodic_email_digest %> + <%= admin_config_description Constants::Settings::General::DETAILS[:periodic_email_digest][:description] %> + <%= f.number_field :periodic_email_digest, + class: "crayons-textfield", + value: Settings::General.periodic_email_digest, + placeholder: Constants::Settings::General::DETAILS[:periodic_email_digest][:placeholder] %> +
+ + <%= render "update_setting_button", f: f %> +
- +<% end %> diff --git a/app/views/admin/settings/show.html.erb b/app/views/admin/settings/show.html.erb index c396e0639..487ec1538 100644 --- a/app/views/admin/settings/show.html.erb +++ b/app/views/admin/settings/show.html.erb @@ -34,7 +34,6 @@ <%= render partial: "forms/community" %> <%= render partial: "forms/credits" %> <%= render partial: "forms/emails" %> - <%= render partial: "forms/email_digest_frequency" %> <%= render partial: "forms/google_analytics" %> <%= render partial: "forms/images", locals: { logo_allowed_types: @logo_allowed_types, logo_max_file_size: @logo_max_file_size } %> <%= render partial: "forms/mascot" %> diff --git a/app/views/admin/users/_data_export.html.erb b/app/views/admin/users/_data_export.html.erb index a9c79ddde..9699d16c8 100644 --- a/app/views/admin/users/_data_export.html.erb +++ b/app/views/admin/users/_data_export.html.erb @@ -12,7 +12,7 @@

Exporting the data to your admin account will send it to your contact - admin email (<%= ForemInstance.email %>), + admin email (<%= ForemInstance.contact_email %>), and exporting to the user will send it to their email (<%= @user.email %>).

diff --git a/app/views/credits/new.html.erb b/app/views/credits/new.html.erb index 9926eaf30..31bf24ace 100644 --- a/app/views/credits/new.html.erb +++ b/app/views/credits/new.html.erb @@ -47,7 +47,7 @@

-

Contact <%= email_link(additional_info: { subject: "Custom Bulk Pricing/Partnerships" }) %> for custom bulk pricing and partnerships.

+

Contact <%= contact_link(additional_info: { subject: "Custom Bulk Pricing/Partnerships" }) %> for custom bulk pricing and partnerships.

How many credits does one listing cost? diff --git a/app/views/deep_links/mobile.html.erb b/app/views/deep_links/mobile.html.erb index ac75d6f92..27c1a374a 100644 --- a/app/views/deep_links/mobile.html.erb +++ b/app/views/deep_links/mobile.html.erb @@ -9,7 +9,7 @@ <%= t("views.deep_links.alert.subtitle") %>

- <%= t("views.deep_links.alert.desc_html", email: link_to(ForemInstance.email, href: "mailto:#{ForemInstance.email}")) %> + <%= t("views.deep_links.alert.desc_html", email: link_to(ForemInstance.contact_email, href: "mailto:#{ForemInstance.contact_email}")) %>

diff --git a/app/views/mailers/notify_mailer/account_deleted_email.text.erb b/app/views/mailers/notify_mailer/account_deleted_email.text.erb index f08a69e75..b3c76cc53 100644 --- a/app/views/mailers/notify_mailer/account_deleted_email.text.erb +++ b/app/views/mailers/notify_mailer/account_deleted_email.text.erb @@ -1,6 +1,6 @@ Hi <%= @name %>, your account has been successfully deleted. -Contact us at <%= ForemInstance.email %> if there is anything more we can help with. +Contact us at <%= ForemInstance.contact_email %> if there is anything more we can help with. Thanks, The <%= community_name %> Team diff --git a/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.html.erb b/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.html.erb index 46bdd0e00..32fa4330c 100644 --- a/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.html.erb +++ b/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.html.erb @@ -26,7 +26,7 @@

Tag moderation is something we're continuously iterating on, so you can expect adjustments and expanding features over time as we receive feedback. We regularly send out a biweekly Mod Newsletter to keep mods up to date on these changes, so look out for it! - Of course, don't hesitate to reach out to us at any moment if you have any feedback — feel free to write to <%= email_link %> and share your thoughts. + Of course, don't hesitate to reach out to us at any moment if you have any feedback — feel free to write to <%= contact_link %> and share your thoughts.

diff --git a/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.text.erb b/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.text.erb index cd3c64fa0..9cfa1e97c 100644 --- a/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.text.erb +++ b/app/views/mailers/notify_mailer/tag_moderator_confirmation_email.text.erb @@ -12,7 +12,7 @@ For details on all available features and how to access them, visit our tag mode Tag moderation is something we're continuously iterating on, so you can expect adjustments and expanding features over time as we receive feedback. We regularly send out a biweekly Mod Newsletter to keep mods up to date on these changes, so look out for it! -Of course, don't hesitate to reach out to us at any moment if you have any feedback — feel free to write to <%= ForemInstance.email %> and share your thoughts. +Of course, don't hesitate to reach out to us at any moment if you have any feedback — feel free to write to <%= ForemInstance.contact_email %> and share your thoughts. Thanks so much for volunteering your time to benefit <%= community_name %>. We sincerely appreciate your help! diff --git a/app/views/mailers/notify_mailer/trusted_role_email.html.erb b/app/views/mailers/notify_mailer/trusted_role_email.html.erb index a60c5d323..d650f9c6f 100644 --- a/app/views/mailers/notify_mailer/trusted_role_email.html.erb +++ b/app/views/mailers/notify_mailer/trusted_role_email.html.erb @@ -29,7 +29,7 @@ You may occasionally receive notifications about optional moderation actions; please unsubscribe if you do not want to receive these updates.

- If you have any questions or feedback for us, please write to <%= email_link %> and share your thoughts. + If you have any questions or feedback for us, please write to <%= contact_link %> and share your thoughts.

diff --git a/app/views/mailers/notify_mailer/trusted_role_email.text.erb b/app/views/mailers/notify_mailer/trusted_role_email.text.erb index 7d99eeca2..fbb03f373 100644 --- a/app/views/mailers/notify_mailer/trusted_role_email.text.erb +++ b/app/views/mailers/notify_mailer/trusted_role_email.text.erb @@ -20,7 +20,7 @@ For details on all available features and how to access them, visit our <%= comm You may occasionally receive notifications about optional moderation actions; please unsubscribe (<%= app_url(user_settings_path(:notifications)) %>) if you do not want to receive these updates. -If you have any questions or feedback for us, please write to <%= ForemInstance.email %> and share your thoughts. +If you have any questions or feedback for us, please write to <%= ForemInstance.contact_email %> and share your thoughts. Thanks for being such an awesome member of the community! diff --git a/app/views/moderations/_mod_sidebar_left.html.erb b/app/views/moderations/_mod_sidebar_left.html.erb index aee290657..74c2a030c 100644 --- a/app/views/moderations/_mod_sidebar_left.html.erb +++ b/app/views/moderations/_mod_sidebar_left.html.erb @@ -79,7 +79,7 @@ <%= t("views.moderations.aside.feedback.subtitle") %> - <%= t("views.moderations.aside.feedback.description", email: ForemInstance.email) %> + <%= t("views.moderations.aside.feedback.description", email: ForemInstance.contact_email) %> diff --git a/app/views/moderations/index.html.erb b/app/views/moderations/index.html.erb index f9d45e9d3..bd7530969 100644 --- a/app/views/moderations/index.html.erb +++ b/app/views/moderations/index.html.erb @@ -38,7 +38,7 @@ <%= t("views.moderations.notice.desc2_html", code: link_to(t("views.moderations.notice.code_of_conduct"), code_of_conduct_path), trusted: link_to(t("views.moderations.notice.trusted"), community_moderation_path), tag: link_to(t("views.moderations.notice.tag"), tag_moderation_path)) %>

-

<%= t("views.moderations.notice.desc3_html", email: mail_to(email_link, email_link)) %>

+

<%= t("views.moderations.notice.desc3_html", email: mail_to(contact_link, contact_link)) %>

<% unless user_signed_in? %>

<%= t("views.moderations.notice.desc4") %>

<% end %> diff --git a/app/views/open_search/show.xml.erb b/app/views/open_search/show.xml.erb index 4ee8f613c..2986b8cac 100644 --- a/app/views/open_search/show.xml.erb +++ b/app/views/open_search/show.xml.erb @@ -3,6 +3,6 @@ <%= t("xml.opensearch.short_name", community: helper.community_name) %> <%= t("xml.opensearch.description", community: helper.community_name) %> - <%= ForemInstance.email %> + <%= ForemInstance.contact_email %> ?q={searchTerms}" /> diff --git a/app/views/pages/_coc_text.html.erb b/app/views/pages/_coc_text.html.erb index 0ddac03a6..7a84a7051 100644 --- a/app/views/pages/_coc_text.html.erb +++ b/app/views/pages/_coc_text.html.erb @@ -36,9 +36,9 @@

Enforcement

Violations of the Code of Conduct may be reported by contacting the team via the <% if creator_settings_form? %> - abuse report form or by sending an email to <%= email_link %>. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately. + abuse report form or by sending an email to <%= contact_link %>. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately. <% else %> - ">abuse report form or by sending an email to <%= email_link %>. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately. + ">abuse report form or by sending an email to <%= contact_link %>. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately. <% end %>

Moderators have the right and responsibility to remove comments or other contributions that are not aligned to this Code of Conduct, or to suspend temporarily or permanently any members for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

diff --git a/app/views/pages/_privacy_text.html.erb b/app/views/pages/_privacy_text.html.erb index ad9773afe..b3d66feab 100644 --- a/app/views/pages/_privacy_text.html.erb +++ b/app/views/pages/_privacy_text.html.erb @@ -132,14 +132,14 @@

Deleting Your Personal Information
- You may request deletion of your personal information and account by emailing <%= email_link %>. + You may request deletion of your personal information and account by emailing <%= contact_link %>.

To protect information from accidental or malicious destruction, we may maintain residual copies for a brief time period. But, if you delete your account, your information and content will be unrecoverable after that time.

Data Portability
- If you would like to request a copy of your user data, please email <%= email_link %>.

+ If you would like to request a copy of your user data, please email <%= contact_link %>.

Business Transfers
If we are involved in a merger, acquisition, bankruptcy, reorganization or sale of assets such that your information would be transferred or become subject to a different privacy policy, we’ll notify you in advance of any such change. @@ -150,4 +150,4 @@

Questions
- We welcome feedback about this policy at <%= email_link %>.

+ We welcome feedback about this policy at <%= contact_link %>.

diff --git a/app/views/pages/_terms_text.html.erb b/app/views/pages/_terms_text.html.erb index 0090a2bab..90f4e8c68 100644 --- a/app/views/pages/_terms_text.html.erb +++ b/app/views/pages/_terms_text.html.erb @@ -79,7 +79,7 @@

Users agree and certify that they have rights to share all content that they post on dev.to — including, but not limited to, information posted in articles, discussions, and comments. This rule applies to prose, code snippets, collections of links, etc. Regardless of citation, users may not post copy and pasted content that does not belong to them. Users assume all risk for the content they post, including someone else's reliance on its accuracy, claims relating to intellectual property, or other legal rights. If you believe that a user has plagiarized content, misrepresented their identity, misappropriated work, or otherwise run afoul of DMCA regulations, please email - <%= email_link %>. <%= community_name %> may remove any content users post for any reason. + <%= contact_link %>. <%= community_name %> may remove any content users post for any reason.

@@ -96,7 +96,7 @@

All uses of the <%= community_name %> logo, <%= community_name %> badges, brand slogans, iconography, and the like, may only be used with express permission from <%= community_name %>. - <%= community_name %> reserves all rights, even if certain assets are included in <%= community_name %> open source projects. Please contact <%= email_link %> with any questions or to request permission. + <%= community_name %> reserves all rights, even if certain assets are included in <%= community_name %> open source projects. Please contact <%= contact_link %> with any questions or to request permission.

diff --git a/app/views/pages/contact.html.erb b/app/views/pages/contact.html.erb index be17d51bc..778f802dc 100644 --- a/app/views/pages/contact.html.erb +++ b/app/views/pages/contact.html.erb @@ -27,7 +27,7 @@ <%= community_name %> would love to hear from you!

- Email: <%= email_link %> 😁 + Email: <%= contact_link %> 😁

Twitter: ">@<%= Settings::General.social_media_handles["twitter"] %> 👻 diff --git a/app/views/pages/forbidden.html.erb b/app/views/pages/forbidden.html.erb index 0edaee4e7..5a13c529c 100644 --- a/app/views/pages/forbidden.html.erb +++ b/app/views/pages/forbidden.html.erb @@ -5,4 +5,4 @@ Your ability to post and comment may be limited.

-

For more information, you may send a message to <%= ForemInstance.email %>.

+

For more information, you may send a message to <%= contact_link %>.

diff --git a/app/views/users/_org_admin.html.erb b/app/views/users/_org_admin.html.erb index 31902394f..652c8a310 100644 --- a/app/views/users/_org_admin.html.erb +++ b/app/views/users/_org_admin.html.erb @@ -220,7 +220,7 @@ <% end %>

- <%= t("views.settings.org.admin.delete.questions_html", email: link_to(ForemInstance.email, ForemInstance.email)) %> + <%= t("views.settings.org.admin.delete.questions_html", email: link_to(ForemInstance.contact_email, ForemInstance.contact_email)) %>

diff --git a/app/views/users/confirm_destroy.html.erb b/app/views/users/confirm_destroy.html.erb index 4ff7c7268..191b53eab 100644 --- a/app/views/users/confirm_destroy.html.erb +++ b/app/views/users/confirm_destroy.html.erb @@ -42,7 +42,7 @@ deleteAccountVerificationInput.addEventListener('input', disableDeleteAccountBtn);

- <%= t("views.settings.destroy.ghost_html", ghost: link_to("@ghost", "/ghost"), click: email_link(text: t("views.settings.destroy.click"), additional_info: { subject: "Request Account Deletion", body: @email_body })) %> + <%= t("views.settings.destroy.ghost_html", ghost: link_to("@ghost", "/ghost"), click: contact_link(text: t("views.settings.destroy.click"), additional_info: { subject: "Request Account Deletion", body: @email_body })) %>

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index ccfe77c58..bb7ae929b 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -15,7 +15,7 @@ <% if params[:state] == "previous-registration" %>

<% end %> diff --git a/cypress/integration/seededFlows/adminFlows/config/emailDigestFrequencySection.spec.js b/cypress/integration/seededFlows/adminFlows/config/emailDigestFrequencySection.spec.js index ad99f6943..5f8ae18e8 100644 --- a/cypress/integration/seededFlows/adminFlows/config/emailDigestFrequencySection.spec.js +++ b/cypress/integration/seededFlows/adminFlows/config/emailDigestFrequencySection.spec.js @@ -1,39 +1,46 @@ -describe('Email digest frequency Section', () => { +describe('Emails Section', () => { beforeEach(() => { cy.testSetup(); cy.fixture('users/adminUser.json').as('user'); cy.get('@user').then((user) => { - cy.loginUser(user); + cy.loginAndVisit(user, '/admin/customization/config'); + }); + }); + + describe('contact settings', () => { + it('can update the contact email', () => { + cy.findByTestId('emailForm').as('emailForm'); + + cy.get('@emailForm').within(() => { + cy.findByText('Emails').click(); + cy.findByLabelText('Contact email').clear().type('yo@dev.to'); + cy.findByText('Update Settings').click(); + }); + + cy.url().should('contains', '/admin/customization/config'); + + cy.findByText('Successfully updated settings.').should('be.visible'); + + cy.findByLabelText('Contact email').should('have.value', 'yo@dev.to'); }); }); describe('email digest frequency settings', () => { it('can change the frequency', () => { - cy.get('@user').then(() => { - cy.visit('/admin/customization/config'); - cy.findByTestId('emailDigestSectionForm').as('emailDigestSectionForm'); + cy.findByTestId('emailForm').as('emailForm'); - cy.get('@emailDigestSectionForm') - .findByText('Email digest frequency') - .click(); - - cy.get('@emailDigestSectionForm') - .get('#settings_general_periodic_email_digest') - .clear() - .type('42'); - - cy.get('@emailDigestSectionForm').findByText('Update Settings').click(); - - cy.url().should('contains', '/admin/customization/config'); - - cy.findByText('Successfully updated settings.').should('be.visible'); - - cy.get('#settings_general_periodic_email_digest').should( - 'have.value', - '42', - ); + cy.get('@emailForm').within(() => { + cy.findByText('Emails').click(); + cy.findByLabelText('Periodic email digest').clear().type('42'); + cy.findByText('Update Settings').click(); }); + + cy.url().should('contains', '/admin/customization/config'); + + cy.findByText('Successfully updated settings.').should('be.visible'); + + cy.findByLabelText('Periodic email digest').should('have.value', '42'); }); }); }); diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index d0264c718..51da43c5e 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -238,24 +238,24 @@ RSpec.describe ApplicationHelper, type: :helper do end end - describe "#email_link" do + describe "#contact_link" do let(:default_email) { "hi@dev.to" } before do - allow(ForemInstance).to receive(:email).and_return(default_email) + allow(ForemInstance).to receive(:contact_email).and_return(default_email) end it "returns an 'a' tag" do - expect(helper.email_link).to have_selector("a") + expect(helper.contact_link).to have_selector("a") end it "sets the correct href" do - expect(helper.email_link).to have_link(href: "mailto:#{default_email}") + expect(helper.contact_link).to have_link(href: "mailto:#{default_email}") end it "has the correct text in the a tag" do - expect(helper.email_link(text: "Link Name")).to have_text("Link Name") - expect(helper.email_link).to have_text(default_email) + expect(helper.contact_link(text: "Link Name")).to have_text("Link Name") + expect(helper.contact_link).to have_text(default_email) end it "returns an href with additional_info parameters" do @@ -266,7 +266,7 @@ RSpec.describe ApplicationHelper, type: :helper do link = "text" - expect(email_link(text: "text", additional_info: additional_info)).to eq(link) + expect(contact_link(text: "text", additional_info: additional_info)).to eq(link) end end diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index 449510e21..dbb9fa5ca 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -1404,7 +1404,7 @@ RSpec.describe Article, type: :model do create(:article, body_markdown: body_markdown, feed_source_url: url) another_article = build(:article, body_markdown: body_markdown, feed_source_url: url) error_message = "has already been taken. " \ - "Email #{ForemInstance.email} for further details." + "Email #{ForemInstance.contact_email} for further details." expect(another_article).not_to be_valid expect(another_article.errors.messages[:canonical_url]).to include(error_message) expect(another_article.errors.messages[:feed_source_url]).to include(error_message) diff --git a/spec/models/forem_instance_spec.rb b/spec/models/forem_instance_spec.rb index b8f3a4b74..c368a497e 100644 --- a/spec/models/forem_instance_spec.rb +++ b/spec/models/forem_instance_spec.rb @@ -96,4 +96,16 @@ RSpec.describe ForemInstance, type: :model do ENV["SENDGRID_API_KEY"] = nil end end + + describe ".contact_email" do + let(:email) { "contact@dev.to" } + + before do + allow(Settings::General).to receive(:contact_email).and_return(email) + end + + it "sets the correct email" do + expect(described_class.contact_email).to be(email) + end + end end diff --git a/spec/requests/user/user_settings_spec.rb b/spec/requests/user/user_settings_spec.rb index d22543853..e4d765d4e 100644 --- a/spec/requests/user/user_settings_spec.rb +++ b/spec/requests/user/user_settings_spec.rb @@ -388,7 +388,7 @@ RSpec.describe "UserSettings", type: :request do expect(response).to redirect_to("/settings/account") error = - "An error occurred. Please try again or send an email to: #{ForemInstance.email}" + "An error occurred. Please try again or send an email to: #{ForemInstance.contact_email}" expect(flash[:error]).to eq(error) end @@ -431,7 +431,7 @@ RSpec.describe "UserSettings", type: :request do delete users_remove_identity_path, params: { provider: provider } error = - "An error occurred. Please try again or send an email to: #{ForemInstance.email}" + "An error occurred. Please try again or send an email to: #{ForemInstance.contact_email}" expect(flash[:error]).to eq(error) end diff --git a/spec/system/authentication/user_request_confirmation_spec.rb b/spec/system/authentication/user_request_confirmation_spec.rb index eb82c2409..5bb7442a3 100644 --- a/spec/system/authentication/user_request_confirmation_spec.rb +++ b/spec/system/authentication/user_request_confirmation_spec.rb @@ -7,7 +7,7 @@ RSpec.describe "/confirm-email", type: :system do click_button "Resend" expect(page).to have_current_path(user_confirmation_path) - expected_message = I18n.t("confirmations_controller.email_sent", email: ForemInstance.email) + expected_message = I18n.t("confirmations_controller.email_sent", email: ForemInstance.contact_email) expect(page).to have_content(expected_message) end end