diff --git a/app/components/navigation/primary_navigation_component.rb b/app/components/navigation/primary_navigation_component.rb index 4b836e92..d248a258 100644 --- a/app/components/navigation/primary_navigation_component.rb +++ b/app/components/navigation/primary_navigation_component.rb @@ -33,8 +33,8 @@ def navigation_items { appropriate_body_user: [], dfe_staff_user: [ - { text: "Teachers", href: admin_teachers_path }, - { text: "Organisations", href: admin_organisations_path }, + { text: "Teachers", href: admin_teachers_path, active_when: '/admin/teachers' }, + { text: "Organisations", href: admin_organisations_path, active_when: '/admin/organisations' }, { text: "Admin users", href: "#" }, ], school_user: [ diff --git a/config/routes.rb b/config/routes.rb index ff580bf7..0a07d4e4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,23 +30,20 @@ post 'auth/:provider/callback', to: 'sessions#create' - get '/admin', to: 'admin/teachers#index' + get '/admin', to: redirect('admin/teachers') namespace :admin do constraints -> { Rails.application.config.enable_blazer } do mount Blazer::Engine, at: "blazer" end - resources :users, only: %i[index] do - end + resources :users, only: %i[index] resources :organisations, only: %i[index] do - end - - resources :appropriate_bodies, only: %i[index], path: 'appropriate-bodies' do - end - - resources :schools, only: %i[index show], param: :urn do + collection do + resources :appropriate_bodies, only: %i[index], path: 'appropriate-bodies' + resources :schools, only: %i[index show], param: :urn + end end resources :teachers, only: %i[index show] do diff --git a/spec/requests/admin/appropriate_bodies/index_spec.rb b/spec/requests/admin/appropriate_bodies/index_spec.rb index ced3d805..419531e4 100644 --- a/spec/requests/admin/appropriate_bodies/index_spec.rb +++ b/spec/requests/admin/appropriate_bodies/index_spec.rb @@ -1,7 +1,7 @@ RSpec.describe "Viewing the appropriate bodies index", type: :request do describe "GET /admin/appropriate-bodies" do it "redirects to sign-in" do - get "/admin/appropriate-bodies" + get "/admin/organisations/appropriate-bodies" expect(response).to redirect_to(sign_in_path) end @@ -9,7 +9,7 @@ include_context 'sign in as non-DfE user' it "requires authorisation" do - get "/admin/appropriate-bodies" + get "/admin/organisations/appropriate-bodies" expect(response.status).to eq(401) end @@ -22,7 +22,7 @@ let!(:appropriate_body2) { FactoryBot.create(:appropriate_body, name: "Captain Hook") } it "display appropriate bodies" do - get "/admin/appropriate-bodies" + get "/admin/organisations/appropriate-bodies" expect(response.status).to eq(200) expect(response.body).to include("Captain Scrummy", "Captain Hook") @@ -30,7 +30,7 @@ context "when searching for appropriate bodies" do it "displays search results" do - get "/admin/appropriate-bodies?q=Hook" + get "/admin/organisations/appropriate-bodies?q=Hook" expect(response.status).to eq(200) expect(response.body).to include("Captain Hook") diff --git a/spec/requests/admin/root_spec.rb b/spec/requests/admin/root_spec.rb index e20eb084..c726aa98 100644 --- a/spec/requests/admin/root_spec.rb +++ b/spec/requests/admin/root_spec.rb @@ -2,30 +2,9 @@ RSpec.describe "Admin root", type: :request do describe "GET /admin" do - it "redirects to sign-in" do + it "redirects to teachers path" do get "/admin" - expect(response).to redirect_to(sign_in_path) - end - - context "with an authenticated non-DfE user" do - include_context 'sign in as non-DfE user' - - it "requires authorisation" do - get "/admin" - expect(response.status).to eq(401) - end - end - - context "with an authenticated DfE user" do - include_context 'sign in as DfE user' - - it "shows the teachers search page" do - get "/admin" - expect(response.status).to eq(200) - - expect(response.body).to include("Early career teachers") - expect(response.body).to include("Search by name or TRN") - end + expect(response).to redirect_to(admin_teachers_path) end end end diff --git a/spec/requests/admin_spec.rb b/spec/requests/admin_spec.rb deleted file mode 100644 index 6cc8cd91..00000000 --- a/spec/requests/admin_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -RSpec.describe "Admin", type: :request do - describe "GET /admin" do - it "redirects to sign-in" do - get "/admin" - expect(response).to redirect_to(sign_in_path) - end - - context "with an authenticated user" do - include_context 'sign in as non-DfE user' - - context "when the user isn't a DfE user" do - it "requires authorisation" do - get "/admin" - - expect(response.status).to eq(401) - end - end - - context 'when the user is a DfE user' do - include_context 'sign in as DfE user' - - it "allows access to DfE users" do - get "/admin" - expect(response.status).to eq(200) - end - end - end - end -end