diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 28d17eff6..dcf1aa34a 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -2,6 +2,10 @@ class OrganisationsController < ApplicationController before_action :authenticate_user! before_action :find_organisation + def show + redirect_to details_organisation_path(@organisation) + end + def users if current_user.data_coordinator? render "users" @@ -10,6 +14,10 @@ class OrganisationsController < ApplicationController end end + def details + render "show" + end + private def find_organisation diff --git a/config/routes.rb b/config/routes.rb index c7be56592..72e1ef208 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,7 +22,7 @@ Rails.application.routes.draw do resources :organisations do member do - get "details", to: "organisations#show" + get "details", to: "organisations#details" get "users", to: "organisations#users" get "users/invite", to: "users/account#new" end diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 6081c625a..be49b8c9d 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -5,13 +5,26 @@ RSpec.describe OrganisationsController, type: :request do let(:headers) { { "Accept" => "text/html" } } let(:page) { Capybara::Node::Simple.new(response.body) } + describe "#show" do + let(:user) { FactoryBot.create(:user, :data_coordinator) } + + before do + sign_in user + get "/organisations/#{organisation.id}", headers: headers, params: {} + end + + it "redirects to details" do + expect(response).to have_http_status(:redirect) + end + end + context "As a data coordinator user" do let(:user) { FactoryBot.create(:user, :data_coordinator) } context "details tab" do before do sign_in user - get "/organisations/#{organisation.id}", headers: headers, params: {} + get "/organisations/#{organisation.id}/details", headers: headers, params: {} end it "shows the tab navigation" do @@ -65,7 +78,7 @@ RSpec.describe OrganisationsController, type: :request do context "details tab" do before do sign_in user - get "/organisations/#{organisation.id}", headers: headers, params: {} + get "/organisations/#{organisation.id}/details", headers: headers, params: {} end it "shows the tab navigation" do