diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 0d18b0246..3f9682a60 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -45,7 +45,7 @@ private end def authenticate_scope! - head :not_found if current_user.organisation != @organisation + render_not_found if current_user.organisation != @organisation end def find_resource diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 33f23e41a..8274b93e7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -74,6 +74,6 @@ private end def authenticate_scope! - head :not_found if current_user != @user + render_not_found if current_user != @user end end diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index ee1cb29ed..c15845c9b 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -50,6 +50,10 @@ RSpec.describe OrganisationsController, type: :request do it "returns not found 404 from org route" do expect(response).to have_http_status(:not_found) end + + it "shows the 404 view" do + expect(page).to have_content("Page not found") + end end end diff --git a/spec/requests/user_controller_spec.rb b/spec/requests/user_controller_spec.rb index 05746aba5..5dea28dfd 100644 --- a/spec/requests/user_controller_spec.rb +++ b/spec/requests/user_controller_spec.rb @@ -87,6 +87,10 @@ RSpec.describe UsersController, type: :request do it "returns not found 404" do expect(response).to have_http_status(:not_found) end + + it "shows the 404 view" do + expect(page).to have_content("Page not found") + end end end