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

Remove the account page from the placement service #1083

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
<% header.with_product_name(name: service_name) %>

<% if current_user %>
<% header.with_navigation_item(text: t(".your_account"), href: account_path) %>
<% if current_service == :claims %>
JamieCleare2525 marked this conversation as resolved.
Show resolved Hide resolved
<% header.with_navigation_item(text: t(".your_account"), href: account_path) %>
<% end %>
<% header.with_navigation_item(text: t(".sign_out"), href: sign_out_path) %>
<% end %>
<% end %>
Expand Down
8 changes: 7 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ def self.matches?(request)
end
end

class ClaimsOnlyConstraint
def self.matches?(request)
HostingEnvironment.current_service(request) == :claims
end
end
JamieCleare2525 marked this conversation as resolved.
Show resolved Hide resolved

Rails.application.routes.draw do
scope via: :all do
get "/404", to: "errors#not_found", as: :not_found
Expand All @@ -15,7 +21,7 @@ def self.matches?(request)
end

# User Account Details
get "/account", to: "account#show"
get "/account", to: "account#show", constraints: ClaimsOnlyConstraint
get "/sign-in", to: "sessions#new", as: :sign_in

# Persona Sign In
Expand Down
26 changes: 26 additions & 0 deletions spec/requests/account_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require "rails_helper"

RSpec.describe "Account", type: :request do
describe "GET /account" do
context "when the service is claims", service: :claims do
it "returns http success" do
claims_user = create(:claims_user)
sign_in_as claims_user

get "/account"

expect(response).to have_http_status(:success)
expect(response).to render_template("account/show")
end
end

context "when the service is placments", service: :placements do
it "returns http success" do
placements_user = create(:placements_user)
sign_in_as placements_user

expect { get "/account" }.to raise_error(ActionController::RoutingError)
end
end
end
end
47 changes: 11 additions & 36 deletions spec/system/placements/sign_in_as_a_placements_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
when_i_click_sign_in
then_i_dont_get_redirected_to_support_organisations
and_i_see_an_empty_organsations_page

and_i_visit_my_account_page
then_i_see_user_details_for_anne
end

context "when the user is assigned to a school" do
Expand Down Expand Up @@ -59,9 +56,6 @@
when_i_visit_the_sign_in_path
when_i_click_sign_in
then_i_see_a_list_of_organisations

and_i_visit_my_account_page
then_i_see_user_details_for_colin
end

context "when response from dfe sign in is invalid" do
Expand Down Expand Up @@ -111,8 +105,6 @@
when_i_visit_the_sign_in_path
when_i_click_sign_in
then_i_dont_get_redirected_to_support_organisations
and_i_visit_my_account_page
then_i_see_user_details_for_anne
end
end

Expand All @@ -123,9 +115,6 @@
when_i_visit_the_sign_in_path
when_i_click_sign_in
then_i_see_a_list_of_organisations

and_i_visit_my_account_page
then_i_see_user_details_for_colin
end
end
end
Expand Down Expand Up @@ -246,10 +235,10 @@
scenario "I am redirected to the support organisation list page" do
given_there_is_an_existing_support_user_for("Colin")
and_there_are_placement_organisations
and_i_visit_my_account_page
and_i_visit_a_school_show_page
then_i_am_redirected_to_the_sign_in_page
when_i_click_sign_in
then_i_see_user_details_for_colin
then_i_see_school_show_page
when_i_visit_the placements_root_path
and_i_click_on "Start now"
then_i_see_a_list_of_organisations
Expand All @@ -276,6 +265,15 @@ def when_i_visit_the_sign_in_path
visit sign_in_path
end

def and_i_visit_a_school_show_page
visit placements_support_school_path(School.last)
end

def then_i_see_school_show_page
expect(page).to have_current_path placements_support_school_path(School.last), ignore_query: true
JamieCleare2525 marked this conversation as resolved.
Show resolved Hide resolved
expect(page).to have_content("Placement School")
end

def and_there_are_placement_organisations
create(:school, :placements, name: "Placement School")
create(:placements_provider, name: "Provider 1")
Expand All @@ -289,11 +287,6 @@ def and_i_click_on(text)
click_on text
end

def and_i_visit_my_account_page
visit account_path
end
alias_method :when_i_visit_my_account_page, :and_i_visit_my_account_page

def when_i_visit_the(path)
visit path
end
Expand All @@ -308,24 +301,6 @@ def then_i_dont_get_redirected_to_support_organisations
expect(page).to have_no_current_path placements_support_organisations_path, ignore_query: true
end

def then_i_see_user_details_for_anne
expect(page).to have_current_path account_path
page_has_user_content(
first_name: "Anne",
last_name: "Wilson",
email: "[email protected]",
)
end

def then_i_see_user_details_for_colin
expect(page).to have_current_path account_path
page_has_user_content(
first_name: "Colin",
last_name: "Chapman",
email: "[email protected]",
)
end

def page_has_user_content(first_name:, last_name:, email:)
expect(page).to have_content(first_name)
expect(page).to have_content(last_name)
Expand Down