Browse Source

scoping out all but support and coord users

pull/648/head
JG 3 years ago
parent
commit
67b25f5b24
  1. 5
      app/controllers/schemes_controller.rb
  2. 14
      spec/requests/schemes_controller_spec.rb

5
app/controllers/schemes_controller.rb

@ -3,6 +3,7 @@ class SchemesController < ApplicationController
include Modules::SearchFilter include Modules::SearchFilter
before_action :authenticate_user! before_action :authenticate_user!
before_action :authenticate_scope!
def index def index
all_schemes = Scheme.all all_schemes = Scheme.all
@ -17,4 +18,8 @@ class SchemesController < ApplicationController
def search_term def search_term
params["search"] params["search"]
end end
def authenticate_scope!
head :unauthorized and return unless current_user.data_coordinator? || current_user.support?
end
end end

14
spec/requests/schemes_controller_spec.rb

@ -15,6 +15,20 @@ RSpec.describe SchemesController, type: :request do
end end
end end
context "when signed in as a data provider user" do
let(:user) { FactoryBot.create(:user) }
before do
sign_in user
get "/supported-housing"
end
it "returns 401 unauthorized" do
request
expect(response).to have_http_status(:unauthorized)
end
end
context "when signed in as a support user" do context "when signed in as a support user" do
before do before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)

Loading…
Cancel
Save