Browse Source

write test for organisations support user page

pull/557/head
Ted 3 years ago committed by Kat
parent
commit
bc162cfb43
  1. 1
      spec/features/user_spec.rb
  2. 14
      spec/requests/organisations_controller_spec.rb

1
spec/features/user_spec.rb

@ -584,6 +584,7 @@ RSpec.describe "User Features" do
it "they can click on an organisation to see their logs page" do it "they can click on an organisation to see their logs page" do
visit("/organisations") visit("/organisations")
click_link("Test3") click_link("Test3")
expect(page).to have_content("1 total logs")
expect(page).to have_selector("a", text: "#{case_log.id}") expect(page).to have_selector("a", text: "#{case_log.id}")
visit("/organisations") visit("/organisations")
click_link("Test5") click_link("Test5")

14
spec/requests/organisations_controller_spec.rb

@ -2,7 +2,7 @@ require "rails_helper"
RSpec.describe OrganisationsController, type: :request do RSpec.describe OrganisationsController, type: :request do
let(:organisation) { user.organisation } let(:organisation) { user.organisation }
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) }
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
@ -299,5 +299,17 @@ RSpec.describe OrganisationsController, type: :request do
end end
end end
end end
context "with a data provider user" do
let(:user) { FactoryBot.create(:user, :support) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
get "/organisations"
end
it "shows all organisations" do
expect(page).to have_content("2 total organisations")
end
end
end end
end end

Loading…
Cancel
Save