Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support settings #821

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/controllers/claims/support/mailers_controller.rb
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
3 changes: 3 additions & 0 deletions app/controllers/claims/support/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Claims::Support::SettingsController < Claims::Support::ApplicationController
before_action :skip_authorization
end
1 change: 1 addition & 0 deletions app/views/claims/support/_primary_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<% component.with_navigation_item t(".organisations"), claims_support_schools_path, current: local_assigns[:current] == :organisations %>
<% component.with_navigation_item t(".claims"), claims_support_claims_path, current: local_assigns[:current] == :claims %>
<% component.with_navigation_item t(".support_users"), claims_support_support_users_path, current: local_assigns[:current] == :users %>
<% component.with_navigation_item t(".settings"), claims_support_settings_path, current: local_assigns[:current] == :settings %>
<% end %>

<% content_for(:no_phase_banner_border, true) %>
Expand Down
15 changes: 15 additions & 0 deletions app/views/claims/support/mailers/index.html.erb
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"><%= t(".heading") %></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>
15 changes: 15 additions & 0 deletions app/views/claims/support/settings/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%# content_for :page_title, t(".heading", records: @pagy.count) %>
<% render "claims/support/primary_navigation", current: :settings %>

<div class="govuk-width-container">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l"><%= t(".heading") %></h1>

<%= govuk_list [
govuk_link_to(t(".background_jobs"), "/good_job", no_visited_state: true, new_tab: true),
govuk_link_to(t(".emails"), claims_support_mailers_path, no_visited_state: true),
], spaced: true %>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Application < Rails::Application
"node_modules/govuk-frontend/dist/govuk/assets",
)

config.action_mailer.show_previews = true
config.action_mailer.preview_paths << Rails.root.join("spec/mailers/previews").to_s

config.view_component.preview_paths << Rails.root.join("spec/components/previews").to_s
config.view_component.default_preview_layout = "component_preview"

Expand Down
6 changes: 6 additions & 0 deletions config/locales/en/claims/support/mailers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
claims:
support:
mailers:
index:
heading: Emails
1 change: 1 addition & 0 deletions config/locales/en/claims/support/primary_navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ en:
claims: Claims
organisations: Organisations
support_users: Support users
settings: Settings
8 changes: 8 additions & 0 deletions config/locales/en/claims/support/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
claims:
support:
settings:
index:
heading: Settings
background_jobs: Background Jobs
emails: Emails
4 changes: 4 additions & 0 deletions config/routes/claims.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,9 @@
end
end
end

get :settings, to: "settings#index"

resources :mailers, only: :index
end
end
9 changes: 9 additions & 0 deletions spec/mailers/previews/claims/support_user_mailer_preview.rb
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
17 changes: 17 additions & 0 deletions spec/mailers/previews/claims/user_mailer_preview.rb
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
39 changes: 39 additions & 0 deletions spec/system/claims/support/view_emails_spec.rb
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