Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions spec/controllers/donation_sites_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,5 @@
expect(subject).to be_successful
end
end

context "Looking at a different organization" do
let(:object) { create(:donation_site, organization: create(:organization)) }
include_examples "requiring authorization"
end
end

context "While not signed in" do
let(:object) { create(:donation_site) }

include_examples "requiring authorization"
end
end
11 changes: 0 additions & 11 deletions spec/controllers/items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@
end
end

context "Looking at a different organization" do
let(:object) { create(:item, organization: create(:organization)) }
include_examples "requiring authorization"
end

describe "PATCH #remove_category" do
let(:item_category) { create(:item_category) }
let!(:item) { create(:item, item_category: item_category) }
Expand All @@ -220,10 +215,4 @@
end
end
end

context "While not signed in" do
let(:object) { create(:item) }

include_examples "requiring authorization"
end
end
17 changes: 0 additions & 17 deletions spec/controllers/transfers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,5 @@
end
end
end

context "Looking at a different organization" do
let(:object) do
org = create(:organization)
create(:transfer,
to: create(:storage_location, organization: org),
from: create(:storage_location, organization: org),
organization: org)
end
include_examples "requiring authorization", except: %i(edit update destroy)
end
end

context "While not signed in" do
let(:object) { create(:transfer) }

include_examples "requiring authorization", except: %i(edit update destroy)
end
end
5 changes: 0 additions & 5 deletions spec/requests/barcode_items_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@
expect(subject).to redirect_to(barcode_items_path)
end
end

context "Looking at a different organization" do
let(:object) { create(:barcode_item, organization: create(:organization)) }
include_examples "requiring authorization"
end
end

context 'while signed in as organization admin' do
Expand Down
7 changes: 0 additions & 7 deletions spec/requests/distributions_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,6 @@
include_examples "restricts access to organization users/admins"
end

context "Looking at a different organization" do
let(:object) { create(:distribution, organization: create(:organization)) }
include_examples "requiring authorization"
end

describe "PATCH #update" do
subject { patch distribution_path(distribution_params) }
let(:partner_name) { "Patrick" }
Expand Down Expand Up @@ -939,8 +934,6 @@
context "While not signed in" do
let(:object) { create(:distribution) }

include_examples "requiring authorization"

# calendar does not need signin
describe 'GET #calendar' do
before(:each) do
Expand Down
9 changes: 0 additions & 9 deletions spec/requests/events_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,4 @@
end
end
end

context "When not signed in" do
let(:object) do
donation = create(:donation)
DonationEvent.publish(donation)
end

include_examples "requiring authorization"
end
end
6 changes: 0 additions & 6 deletions spec/requests/partner_groups_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,4 @@
end
end
end

context "While not signed in" do
let(:object) { create(:partner_group, organization: organization) }

include_examples "requiring authorization"
end
end
11 changes: 0 additions & 11 deletions spec/requests/product_drive_participants_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,5 @@
expect(response).to have_error(/try again/i)
end
end

context "Looking at a different organization" do
let(:object) { create(:product_drive_participant, organization: create(:organization)) }
include_examples "requiring authorization"
end
end

context "While not signed in" do
let(:object) { create(:product_drive_participant) }

include_examples "requiring authorization"
end
end
6 changes: 0 additions & 6 deletions spec/requests/requests_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,4 @@
end
end
end

context 'When not signed' do
let(:object) { create(:request) }

include_examples 'requiring authorization'
end
end
11 changes: 0 additions & 11 deletions spec/requests/storage_locations_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,5 @@ def item_to_h(view_item)
expect(response.body).to include("Square footage must be greater than or equal to 0")
end
end

context "Looking at a different organization" do
let(:object) { create(:storage_location, organization: create(:organization)) }
include_examples "requiring authorization"
end
end

context "While not signed in" do
let(:object) { create(:storage_location) }

include_examples "requiring authorization"
end
end
17 changes: 0 additions & 17 deletions spec/requests/transfers_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,5 @@
end
end
end

context "Looking at a different organization" do
let(:object) do
org = create(:organization)
create(:transfer,
to: create(:storage_location, organization: org),
from: create(:storage_location, organization: org),
organization: org)
end
include_examples "requiring authorization", except: %i(edit update)
end
end

context "While not signed in" do
let(:object) { create(:transfer) }

include_examples "requiring authorization", except: %i(edit update)
end
end
11 changes: 0 additions & 11 deletions spec/requests/vendors_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@
end
end

context "Looking at a different organization" do
let(:object) { create(:vendor, organization: create(:organization)) }
include_examples "requiring authorization"
end

describe "when on vendors index page" do
it "has the correct import type" do
get vendors_path(format: 'html')
Expand All @@ -212,10 +207,4 @@
end
end
end

context "While not signed in" do
let(:object) { create(:vendor) }

include_examples "requiring authorization"
end
end
45 changes: 0 additions & 45 deletions spec/support/authorization_specs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,3 @@
end
end
end

RSpec.shared_examples "requiring authorization" do |constraints|
it "redirects the user to the sign-in page for CRUD actions" do
member_params = { organization_id: object.organization.to_param, id: object.id }
collection_params = { organization_id: object.organization.to_param }

(constraints ||= {}).merge!(except: [], only: [])
skip_these = constraints[:except] + (%i(index new create show edit update destroy) - constraints[:only])

unless skip_these.include?(:index)
get :index, params: collection_params
expect(response).to be_redirect
end

unless skip_these.include?(:new)
get :new, params: collection_params
expect(response).to be_redirect
end

unless skip_these.include?(:create)
post :create, params: collection_params
expect(response).to be_redirect
end

unless skip_these.include?(:show)
get :show, params: member_params
expect(response).to be_redirect
end

unless skip_these.include?(:edit)
get :edit, params: member_params
expect(response).to be_redirect
end

unless skip_these.include?(:update)
get :update, params: member_params
expect(response).to be_redirect
end

unless skip_these.include?(:destroy)
delete :destroy, params: member_params
expect(response).to be_redirect
end
end
end