-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mailer previews to support settings
- Loading branch information
1 parent
af87080
commit 4c889b1
Showing
8 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Claims::Support::MailersController < Claims::Support::ApplicationController | ||
before_action :skip_authorization | ||
|
||
def index | ||
@previews = ActionMailer::Preview.all.filter { |preview| preview.preview_name.start_with?("claims/") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% render "claims/support/primary_navigation", current: :settings %> | ||
|
||
<div class="govuk-width-container"> | ||
<h1 class="govuk-heading-l">Email Previews</h1> | ||
|
||
<% @previews.each do |mailer| %> | ||
<h2 class="govuk-heading-m"><%= mailer.preview_name.delete_prefix("claims/").titleize %></h2> | ||
|
||
<% email_links = mailer.emails.map do |email| %> | ||
<% govuk_link_to(email, url_for(controller: "/rails/mailers", action: :preview, path: "#{mailer.preview_name}/#{email}"), no_visited_state: true, new_tab: true) %> | ||
<% end %> | ||
|
||
<%= govuk_list email_links, type: :bullet %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,5 +108,7 @@ | |
end | ||
|
||
get :settings, to: "settings#index" | ||
|
||
resources :mailers, only: :index | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Claims::SupportUserMailerPreview < ActionMailer::Preview | ||
def support_user_invitation | ||
SupportUserMailer.with(service: :claims).support_user_invitation(Claims::SupportUser.first) | ||
end | ||
|
||
def support_user_removal_notification | ||
SupportUserMailer.with(service: :claims).support_user_removal_notification(Claims::SupportUser.first) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Claims::UserMailerPreview < ActionMailer::Preview | ||
def user_membership_created_notification | ||
UserMailer.with(service: :claims).user_membership_created_notification(Claims::User.first, Claims::School.first) | ||
end | ||
|
||
def user_membership_destroyed_notification | ||
UserMailer.with(service: :claims).user_membership_destroyed_notification(Claims::User.first, Claims::School.first) | ||
end | ||
|
||
def claim_submitted_notification | ||
UserMailer.with(service: :claims).claim_submitted_notification(Claims::User.first, Claims::Claim.submitted.first) | ||
end | ||
|
||
def claim_created_support_notification | ||
UserMailer.with(service: :claims).claim_created_support_notification(Claims::Claim.draft.first, Claims::User.first) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "View Emails", service: :claims, type: :system do | ||
let(:support_user) { create(:claims_support_user) } | ||
|
||
before do | ||
user_exists_in_dfe_sign_in(user: support_user) | ||
given_i_sign_in | ||
end | ||
|
||
scenario "User visits the emails page" do | ||
when_i_visit_the_emails_page | ||
then_i_can_see_the_list_of_claims_email_templates | ||
end | ||
|
||
private | ||
|
||
def given_i_sign_in | ||
visit sign_in_path | ||
click_on "Sign in using DfE Sign In" | ||
end | ||
|
||
def when_i_visit_the_emails_page | ||
click_on "Settings" | ||
click_on "Emails" | ||
end | ||
|
||
def then_i_can_see_the_list_of_claims_email_templates | ||
expect(page).to have_content("Support User Mailer") | ||
expect(page).to have_link("support_user_invitation (opens in new tab)", href: "/rails/mailers/claims/support_user_mailer/support_user_invitation") | ||
expect(page).to have_link("support_user_removal_notification (opens in new tab)", href: "/rails/mailers/claims/support_user_mailer/support_user_removal_notification") | ||
|
||
expect(page).to have_content("User Mailer") | ||
expect(page).to have_link("claim_created_support_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/claim_created_support_notification") | ||
expect(page).to have_link("claim_submitted_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/claim_submitted_notification") | ||
expect(page).to have_link("user_membership_created_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/user_membership_created_notification") | ||
expect(page).to have_link("user_membership_destroyed_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/user_membership_destroyed_notification") | ||
end | ||
end |