-
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.
As a Support User, I should be able to invite new Users to a School O…
…rganisation
- Loading branch information
Showing
14 changed files
with
284 additions
and
5 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
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,3 @@ | ||
class Claims::UserDecorator < Draper::Decorator | ||
delegate_all | ||
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,10 @@ | ||
class NotifyMailer < ApplicationMailer | ||
# NotifyMailer.send_school_invite_email.deliver_now | ||
def send_school_invite_email(user, school, sign_in_url) | ||
body = "Dear #{user.full_name} \n\n You have been invited to join the claims service for #{school.name}.\n\n Sign in here #{sign_in_url}" | ||
|
||
mailer_options = { to: user.email, subject: "You have been invited to #{school.name}", body: } | ||
|
||
notify_email(mailer_options) | ||
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
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<%= content_for(:before_content) do %> | ||
<%= govuk_back_link(href: new_claims_support_school_user_path(@school)) %> | ||
<% end %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<%= form_with(model: @user, url: claims_support_school_users_path, method: :post) do |f| %> | ||
<%= f.hidden_field :first_name, value: @user.first_name %> | ||
<%= f.hidden_field :last_name, value: @user.last_name %> | ||
<%= f.hidden_field :email, value: @user.email %> | ||
|
||
<label class="govuk-label govuk-label--l"> | ||
<span class="govuk-caption-l"><%= t(".caption") %></span> | ||
<%= t(".title") %> | ||
</label> | ||
|
||
<dl class="govuk-summary-list"> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"><%= t(".first_name") %></dt> | ||
<dd class="govuk-summary-list__value"> | ||
<p class="govuk-body"><%= @user.first_name %></p> | ||
</dd> | ||
<dd class="govuk-summary-list__actions"> | ||
<ul class="govuk-summary-list__actions-list"> | ||
<li class="govuk-summary-list__actions-list-item"><a class="govuk-link" href="#">Change<span class="govuk-visually-hidden"></span></a></li> | ||
</ul> | ||
</dd> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"><%= t(".last_name") %></dt> | ||
<dd class="govuk-summary-list__value"> | ||
<p class="govuk-body"><%= @user.last_name %></p> | ||
</dd> | ||
<dd class="govuk-summary-list__actions"> | ||
<ul class="govuk-summary-list__actions-list"> | ||
<li class="govuk-summary-list__actions-list-item"><a class="govuk-link" href="#">Change<span class="govuk-visually-hidden"></span></a></li> | ||
</ul> | ||
</dd> | ||
</div> | ||
<div class="govuk-summary-list__row"> | ||
<dt class="govuk-summary-list__key"><%= t(".email") %></dt> | ||
<dd class="govuk-summary-list__value"> | ||
<p class="govuk-body"><%= @user.email %></p> | ||
</dd> | ||
<dd class="govuk-summary-list__actions"> | ||
<ul class="govuk-summary-list__actions-list"> | ||
<li class="govuk-summary-list__actions-list-item"><a class="govuk-link" href="#">Change<span class="govuk-visually-hidden"></span></a></li> | ||
</ul> | ||
</dd> | ||
</div> | ||
</dl> | ||
|
||
<div class="govuk-warning-text"> | ||
<span class="govuk-warning-text__icon" aria-hidden="true">!</span> | ||
<strong class="govuk-warning-text__text"><%= t(".warning", school_name: @school.name) %></strong> | ||
</div> | ||
|
||
<%= f.govuk_submit t(".add_user") %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t(".cancel"), claims_support_school_users_path(@school)) %> | ||
</p> | ||
<% end %> | ||
<div> | ||
<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= content_for(:before_content) do %> | ||
<%= govuk_back_link(href: claims_support_school_users_path(@school)) %> | ||
<% end %> | ||
|
||
<%= form_with(model: @user, url: check_claims_support_school_users_path, method: "get") do |f| %> | ||
<%= f.govuk_error_summary %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<span class="govuk-caption-l"><%= t(".caption") %></span> | ||
<h2 class="govuk-heading-l"><%= t(".title") %></h2> | ||
|
||
<div class="govuk-form-group"> | ||
<%= f.govuk_text_field :first_name, | ||
class: "govuk-input--width-20", | ||
label: { text: t(".attributes.users.first_name"), size: "s" } %> | ||
</div> | ||
|
||
<div class="govuk-form-group"> | ||
<%= f.govuk_text_field :last_name, | ||
class: "govuk-input--width-20", | ||
label: { text: t(".attributes.users.last_name"), size: "s" } %> | ||
</div> | ||
|
||
<div class="govuk-form-group"> | ||
<%= f.govuk_text_field :email, label: { text: t(".attributes.users.email"), size: "s" } %> | ||
</div> | ||
|
||
<%= f.govuk_submit t("continue") %> | ||
|
||
<p class="govuk-body"> | ||
<%= govuk_link_to(t("cancel"), claims_support_school_users_path(@school)) %> | ||
</p> | ||
</div> | ||
</div> | ||
<% 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
Empty file.
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 |
---|---|---|
|
@@ -12,12 +12,22 @@ en: | |
taken: This provider has already been added. Try another provider | ||
blank: Enter a provider name, UKPRN, URN or postcode | ||
school: | ||
attributes: | ||
urn: | ||
attributes: | ||
urn: | ||
taken: This school has already been added. Try another school | ||
blank: Enter a school name, URN or postcode | ||
gias_school: | ||
required: "" | ||
user: | ||
attributes: | ||
first_name: | ||
blank: Enter a first name | ||
last_name: | ||
blank: Enter a last name | ||
email: | ||
blank: Enter an email address | ||
taken: This email address is already in use. Try another email address | ||
invalid: Enter an email address in the correct format, like [email protected] | ||
add_organisation: Add organisation | ||
organisations: Organisations | ||
school: School | ||
|
@@ -83,11 +93,30 @@ en: | |
support: | ||
users: | ||
index: | ||
invite_user: Invite User | ||
heading: Users | ||
attributes: | ||
users: | ||
name: Name | ||
email: Email | ||
new: | ||
attributes: | ||
users: | ||
first_name: First name | ||
last_name: Last name | ||
email: Email | ||
title: Invite a new user | ||
caption: Add user | ||
description: Personal details | ||
check: | ||
title: Check your answers | ||
caption: Add user | ||
add_user: Add user | ||
cancel: Cancel | ||
first_name: First name | ||
last_name: Last name | ||
email: Email | ||
warning: "The user will be sent an email to tell them you’ve added them to %{school_name}." | ||
navigation_bar: | ||
organisation_details: Organisation details | ||
users: Users | ||
|
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Invite a user to a school", type: :system do | ||
before do | ||
setup_school | ||
mailer_double = instance_double(ActionMailer::MessageDelivery, deliver_now: nil) | ||
allow(NotifyMailer).to receive(:send_school_invite_email).and_return(mailer_double) | ||
end | ||
|
||
scenario "I sign in as a support user and invite a user to a school" do | ||
sign_in_as_support_user | ||
visit_claims_support_school_users_page | ||
click_on_invite_user_button | ||
fill_in_user_details | ||
check_user_details | ||
click_on_add_user | ||
verify_user_added | ||
end | ||
|
||
scenario "I sign in as a support user and invalid bad user details" do | ||
sign_in_as_support_user | ||
visit_claims_support_school_users_page | ||
click_on_invite_user_button | ||
fill_in_invalid_user_details | ||
end | ||
|
||
private | ||
|
||
def setup_school | ||
@school = create(:school, :claims, urn: "123456") | ||
end | ||
|
||
def sign_in_as_support_user | ||
create(:persona, :colin, service: "claims") | ||
visit personas_path | ||
click_on "Sign In as Colin" | ||
end | ||
|
||
def visit_claims_support_school_users_page | ||
visit claims_support_school_users_path(@school) | ||
end | ||
|
||
def click_on_invite_user_button | ||
click_on "Invite User" | ||
end | ||
|
||
def fill_in_user_details | ||
fill_in "First name", with: "Barry" | ||
fill_in "Last name", with: "Garlow" | ||
fill_in "Email", with: "[email protected]" | ||
click_on "Continue" | ||
end | ||
|
||
def fill_in_invalid_user_details | ||
fill_in "First name", with: "Barry" | ||
fill_in "Last name", with: "Garlow" | ||
fill_in "Email", with: "not a valid email" | ||
click_on "Continue" | ||
end | ||
|
||
def show_error_messages | ||
expect(page).to have_content("Enter an email address in the correct format, like [email protected]") | ||
end | ||
|
||
def check_user_details | ||
expect(page).to have_content("Barry") | ||
expect(page).to have_content("Garlow") | ||
expect(page).to have_content("[email protected]") | ||
end | ||
|
||
def click_on_add_user | ||
click_on "Add user" | ||
end | ||
|
||
def verify_user_added | ||
visit_claims_support_school_users_page | ||
expect(page).to have_content("Barry Garlow") | ||
expect(page).to have_content("[email protected]") | ||
end | ||
end |