Skip to content

Commit

Permalink
fixed tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Janell-Huyck committed Dec 7, 2023
1 parent 3809b28 commit 6334c42
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 15 additions & 2 deletions spec/controllers/concerns/admin_only_access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ def dummy_action
end
end

context 'as a non-admin user' do
before { session[:admin] = false }
context 'as a submitter' do
before do
session[:admin] = false
session[:submitter_id] = FactoryBot.create(:submitter).id
end

it 'denies access to the action' do
get :dummy_action
expect(response).to have_http_status(:not_found)
end
end

context 'as a non-admin user' do
before { session[:admin] = false }

it 'redirects the user to log in' do
get :dummy_action
expect(response).to have_http_status(302)
expect(response).to redirect_to(root_path)
end
end
end
end
6 changes: 5 additions & 1 deletion spec/support/shared_examples/allowed_access.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
instance_var = instance_variable_get("@#{controller.controller_name.singularize}")
expect(response).to redirect_to(instance_var)
when 'destroy'
expect(response).to redirect_to(publications_url)
if controller.controller_name == 'colleges'
expect(response).to redirect_to(colleges_url)
else
expect(response).to redirect_to(publications_url)
end
when 'new', 'edit', 'show'
expect(response).to be_successful
when 'index'
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples/restricts_non_admin_acces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
actions.each do |action, method|
describe "#{method.upcase} ##{action}" do
context 'when non-admin and non-submitter user' do
include_examples 'restricted access', action, method, :none
include_examples 'redirect to root', action, method, :none
end

context 'when submitter user' do
Expand Down

0 comments on commit 6334c42

Please sign in to comment.