Browse Source

Redirect organisation show to details

pull/138/head
baarkerlounger 4 years ago
parent
commit
63d3771bb1
  1. 8
      app/controllers/organisations_controller.rb
  2. 2
      config/routes.rb
  3. 17
      spec/requests/organisations_controller_spec.rb

8
app/controllers/organisations_controller.rb

@ -2,6 +2,10 @@ class OrganisationsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :find_organisation before_action :find_organisation
def show
redirect_to details_organisation_path(@organisation)
end
def users def users
if current_user.data_coordinator? if current_user.data_coordinator?
render "users" render "users"
@ -10,6 +14,10 @@ class OrganisationsController < ApplicationController
end end
end end
def details
render "show"
end
private private
def find_organisation def find_organisation

2
config/routes.rb

@ -22,7 +22,7 @@ Rails.application.routes.draw do
resources :organisations do resources :organisations do
member do member do
get "details", to: "organisations#show" get "details", to: "organisations#details"
get "users", to: "organisations#users" get "users", to: "organisations#users"
get "users/invite", to: "users/account#new" get "users/invite", to: "users/account#new"
end end

17
spec/requests/organisations_controller_spec.rb

@ -5,13 +5,26 @@ RSpec.describe OrganisationsController, type: :request do
let(:headers) { { "Accept" => "text/html" } } let(:headers) { { "Accept" => "text/html" } }
let(:page) { Capybara::Node::Simple.new(response.body) } 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 context "As a data coordinator user" do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
context "details tab" do context "details tab" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}", headers: headers, params: {} get "/organisations/#{organisation.id}/details", headers: headers, params: {}
end end
it "shows the tab navigation" do it "shows the tab navigation" do
@ -65,7 +78,7 @@ RSpec.describe OrganisationsController, type: :request do
context "details tab" do context "details tab" do
before do before do
sign_in user sign_in user
get "/organisations/#{organisation.id}", headers: headers, params: {} get "/organisations/#{organisation.id}/details", headers: headers, params: {}
end end
it "shows the tab navigation" do it "shows the tab navigation" do

Loading…
Cancel
Save