|
|
@ -5,10 +5,25 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
let(:unauthorised_organisation) { FactoryBot.create(:organisation) } |
|
|
|
let(:unauthorised_organisation) { FactoryBot.create(:organisation) } |
|
|
|
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) } |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "a not signed in user" do |
|
|
|
|
|
|
|
it "does not let you see organisation details" do |
|
|
|
|
|
|
|
get "/organisations/#{organisation.id}", headers: headers, params: {} |
|
|
|
|
|
|
|
expect(response).to redirect_to("/users/sign-in") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get "/organisations/#{organisation.id}/details", headers: headers, params: {} |
|
|
|
|
|
|
|
expect(response).to redirect_to("/users/sign-in") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not let you see organisation users" do |
|
|
|
|
|
|
|
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
|
|
|
|
|
|
|
expect(response).to redirect_to("/users/sign-in") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "a signed in user" do |
|
|
|
|
|
|
|
describe "#show" do |
|
|
|
context "organisation that the user belongs to" do |
|
|
|
context "organisation that the user belongs to" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
@ -26,15 +41,13 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
get "/organisations/#{unauthorised_organisation.id}", headers: headers, params: {} |
|
|
|
get "/organisations/#{unauthorised_organisation.id}", headers: headers, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns unauthorised from org route" do |
|
|
|
it "returns not found 404 from org route" do |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:not_found) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "As a data coordinator user" do |
|
|
|
context "As a data coordinator user" do |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "details tab" do |
|
|
|
context "details tab" do |
|
|
|
context "organisation that the user belongs to" do |
|
|
|
context "organisation that the user belongs to" do |
|
|
|
before do |
|
|
|
before do |
|
|
@ -65,8 +78,8 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns unauthorised from org details route" do |
|
|
|
it "returns not found 404 from org details route" do |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:not_found) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -105,8 +118,8 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/users", headers: headers, params: {} |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/users", headers: headers, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns unauthorised from users page" do |
|
|
|
it "returns not found 404 from users page" do |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:not_found) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -145,8 +158,8 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} |
|
|
|
get "/organisations/#{unauthorised_organisation.id}/details", headers: headers, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns unauthorised" do |
|
|
|
it "returns not found 404" do |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:not_found) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -157,9 +170,10 @@ RSpec.describe OrganisationsController, type: :request do |
|
|
|
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
|
|
|
get "/organisations/#{organisation.id}/users", headers: headers, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "should return unauthorised 401" do |
|
|
|
it "should return unauthorized 401" do |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|