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

Fix nav highlights in admin area #28

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions app/components/navigation/primary_navigation_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
15 changes: 6 additions & 9 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/requests/admin/appropriate_bodies/index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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

context "with an authenticated non-DfE user" do
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
Expand All @@ -22,15 +22,15 @@
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")
end

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")
Expand Down
25 changes: 2 additions & 23 deletions spec/requests/admin/root_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 0 additions & 29 deletions spec/requests/admin_spec.rb

This file was deleted.

Loading