Browse Source

controller test for locations

pull/662/head
JG 3 years ago
parent
commit
177dafc799
  1. 2
      spec/features/schemes_spec.rb
  2. 15
      spec/requests/schemes_controller_spec.rb

2
spec/features/schemes_spec.rb

@ -133,8 +133,8 @@ RSpec.describe "Schemes scheme Features" do
context "when there are locations that belong to the selected scheme" do
let!(:schemes) { FactoryBot.create_list(:scheme, 5) }
let!(:locations) { FactoryBot.create_list(:location, 3, scheme: scheme) }
let(:scheme) { schemes.first }
let!(:locations) { FactoryBot.create_list(:location, 3, scheme: scheme) }
before do
visit("schemes")

15
spec/requests/schemes_controller_spec.rb

@ -270,5 +270,20 @@ RSpec.describe SchemesController, type: :request do
expect(response).to have_http_status(:unauthorized)
end
end
context "when signed in as a data coordinator user" do
let(:user) { FactoryBot.create(:user, :data_coordinator) }
let!(:scheme) { FactoryBot.create(:scheme, organisation: user.organisation) }
let!(:location) { FactoryBot.create(:location, scheme: scheme) }
before do
sign_in user
get "/schemes/#{scheme.id}/locations"
end
it "shows scheme" do
expect(page).to have_content(location.location_code)
end
end
end
end

Loading…
Cancel
Save