File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog 1.0.0].
1818## [ unreleased]
1919
2020- add ability to persist procurement, contract and savings data on cases [ #ref] ( https://github.com/DFE-Digital/buy-for-your-school/pull/704 )
21+ - add redirect to case management at login for agents [ #ref] ( https://github.com/DFE-Digital/buy-for-your-school/pull/803 )
2122
2223<!--
2324- value added [#ref](https://github.com/DFE-Digital/buy-for-your-school/commit/<hash>)
Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ def create
1313
1414 case user
1515 when User
16- # TODO: alternative redirect for caseworkers
17- redirect_to entry_path
16+ redirect_to entry_path ( user )
1817 when :invalid
1918 redirect_to root_path , notice : "Access Denied"
2019 when :no_organisation
@@ -76,12 +75,18 @@ def find_framework_entrypoint?
7675 session [ :faf_referer ] . present?
7776 end
7877
79- # Logging whilst seeking support will send the user to their profile page
80- # to confirm the details before proceeding
78+ # Routing logic for users after authentication
8179 #
8280 # @return [String]
83- def entry_path
84- find_framework_entrypoint? ? profile_path : dashboard_path
81+ def entry_path ( user )
82+ if user . internal?
83+ # proc ops / internal team members go to case management
84+ support_root_path
85+ else
86+ # - default to the specify dashboard
87+ # - support request journeys start from the profile page
88+ find_framework_entrypoint? ? profile_path : dashboard_path
89+ end
8590 end
8691
8792 # @return [String]
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ module Support
22 class PagesController < ::Support ::ApplicationController
33 skip_before_action :authenticate_agent!
44
5- def start_page ; end
5+ def start_page
6+ redirect_to support_cases_path if current_agent
7+ end
68 end
79end
Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ def guest?
2323 false
2424 end
2525
26+ # @see [SessionsController]
27+ #
28+ # @return [Boolean] user is an internal team member (or case worker)
29+ def internal?
30+ self . class . internal . include? ( self )
31+ end
32+
2633 # @return [Boolean] user is an analyst
2734 def analyst?
2835 self . class . analysts . include? ( self )
Original file line number Diff line number Diff line change 8181 end
8282
8383 context "when the user is a caseworker" do
84- let ( :user ) { build ( :user , :caseworker ) }
85-
8684 around do |example |
8785 ClimateControl . modify ( PROC_OPS_TEAM : "DSI Caseworkers" ) do
8886 example . run
9492 click_start
9593 end
9694
97- it "takes them to the dashboard" do
98- expect ( page ) . to have_title "Specifications dashboard"
99- expect ( page ) . to have_current_path "/dashboard"
95+ context "when they new to the service" do
96+ let ( :user ) { build ( :user , :caseworker ) }
97+
98+ it "takes them to the agent login page" do
99+ expect ( page ) . to have_title "Supported Buying Case Management"
100+ expect ( page ) . to have_current_path "/support"
101+ end
102+ end
103+
104+ xcontext "when they have logged in before" do
105+ let ( :user ) { create ( :user , :caseworker ) }
106+
107+ before do
108+ create ( :support_agent , dsi_uid : user . dfe_sign_in_uid )
109+ end
110+
111+ it "takes them to the case management dashboard" do
112+ expect ( page ) . to have_current_path "/support/cases"
113+ end
100114 end
101115 end
102116end
Original file line number Diff line number Diff line change 11RSpec . describe User , type : :model do
22 around do |example |
3- ClimateControl . modify ( PROC_OPS_TEAM : "DfE Commercial Procurement Operations" ) { example . run }
3+ ClimateControl . modify ( PROC_OPS_TEAM : "DSI Caseworkers" ) do
4+ example . run
5+ end
46 end
57
6- describe ".internal" do
7- before do
8- create ( :user ,
9- first_name : "test_proc_ops" ,
10- orgs : [
11- {
12- "id" : "23F20E54-79EA-4146-8E39-18197576F023" ,
13- "name" : "DfE Commercial Procurement Operations" ,
14- } ,
15- ] )
16-
17- create ( :user ,
18- first_name : "test_not_proc_ops" ,
19- orgs : [
20- {
21- "id" : "23F20E54-79EA-4146-8E39-18197576F023" ,
22- "name" : "Other organisation" ,
23- } ,
24- ] )
25- end
8+ let! ( :caseworker ) { create ( :user , :caseworker ) }
9+ let! ( :buyer ) { create ( :user , :one_supported_school ) }
2610
11+ describe ".internal" do
2712 it "returns internal users only" do
2813 expect ( described_class . internal . count ) . to eq 1
29- expect ( described_class . internal [ 0 ] . first_name ) . to eq "test_proc_ops"
14+ expect ( described_class . internal [ 0 ] . first_name ) . to eq "Procurement"
15+ end
16+ end
17+
18+ describe "#internal?" do
19+ it "is true for members of the 'Proc Ops' organisation" do
20+ expect ( caseworker . internal? ) . to be true
21+ expect ( buyer . internal? ) . to be false
3022 end
3123 end
3224end
You can’t perform that action at this time.
0 commit comments