From b488a1d064bc3d108c4b942326a5f91a6aab31d5 Mon Sep 17 00:00:00 2001 From: Sergio Mira Date: Mon, 26 Jan 2026 12:02:23 +0100 Subject: [PATCH] 4941 Remove unused and broken shared not signed auth specs --- .../donation_sites_controller_spec.rb | 11 ----- spec/controllers/items_controller_spec.rb | 11 ----- spec/controllers/transfers_controller_spec.rb | 17 ------- spec/requests/barcode_items_requests_spec.rb | 5 --- spec/requests/distributions_requests_spec.rb | 7 --- spec/requests/events_requests_spec.rb | 9 ---- spec/requests/partner_groups_requests_spec.rb | 6 --- ...roduct_drive_participants_requests_spec.rb | 11 ----- spec/requests/requests_requests_spec.rb | 6 --- .../storage_locations_requests_spec.rb | 11 ----- spec/requests/transfers_requests_spec.rb | 17 ------- spec/requests/vendors_requests_spec.rb | 11 ----- spec/support/authorization_specs.rb | 45 ------------------- 13 files changed, 167 deletions(-) diff --git a/spec/controllers/donation_sites_controller_spec.rb b/spec/controllers/donation_sites_controller_spec.rb index 9b27d8e214..9702ba89e9 100644 --- a/spec/controllers/donation_sites_controller_spec.rb +++ b/spec/controllers/donation_sites_controller_spec.rb @@ -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 diff --git a/spec/controllers/items_controller_spec.rb b/spec/controllers/items_controller_spec.rb index 96fad6b4bc..489643bf7f 100644 --- a/spec/controllers/items_controller_spec.rb +++ b/spec/controllers/items_controller_spec.rb @@ -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) } @@ -220,10 +215,4 @@ end end end - - context "While not signed in" do - let(:object) { create(:item) } - - include_examples "requiring authorization" - end end diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb index da1ef2d6ff..1a1478fb68 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -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 diff --git a/spec/requests/barcode_items_requests_spec.rb b/spec/requests/barcode_items_requests_spec.rb index 7522a082fe..eea49438ac 100644 --- a/spec/requests/barcode_items_requests_spec.rb +++ b/spec/requests/barcode_items_requests_spec.rb @@ -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 diff --git a/spec/requests/distributions_requests_spec.rb b/spec/requests/distributions_requests_spec.rb index 639684d2b7..6da8da99bd 100644 --- a/spec/requests/distributions_requests_spec.rb +++ b/spec/requests/distributions_requests_spec.rb @@ -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" } @@ -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 diff --git a/spec/requests/events_requests_spec.rb b/spec/requests/events_requests_spec.rb index 5533e36059..0125fb03f3 100644 --- a/spec/requests/events_requests_spec.rb +++ b/spec/requests/events_requests_spec.rb @@ -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 diff --git a/spec/requests/partner_groups_requests_spec.rb b/spec/requests/partner_groups_requests_spec.rb index e6ffdc1a19..6b4623648a 100644 --- a/spec/requests/partner_groups_requests_spec.rb +++ b/spec/requests/partner_groups_requests_spec.rb @@ -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 diff --git a/spec/requests/product_drive_participants_requests_spec.rb b/spec/requests/product_drive_participants_requests_spec.rb index b55e84b7a7..54b17fccee 100644 --- a/spec/requests/product_drive_participants_requests_spec.rb +++ b/spec/requests/product_drive_participants_requests_spec.rb @@ -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 diff --git a/spec/requests/requests_requests_spec.rb b/spec/requests/requests_requests_spec.rb index 8ad8c05403..1bf52876bf 100644 --- a/spec/requests/requests_requests_spec.rb +++ b/spec/requests/requests_requests_spec.rb @@ -170,10 +170,4 @@ end end end - - context 'When not signed' do - let(:object) { create(:request) } - - include_examples 'requiring authorization' - end end diff --git a/spec/requests/storage_locations_requests_spec.rb b/spec/requests/storage_locations_requests_spec.rb index 80e141273e..ae58c6b947 100644 --- a/spec/requests/storage_locations_requests_spec.rb +++ b/spec/requests/storage_locations_requests_spec.rb @@ -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 diff --git a/spec/requests/transfers_requests_spec.rb b/spec/requests/transfers_requests_spec.rb index c0f891bbb7..7575ef54e1 100644 --- a/spec/requests/transfers_requests_spec.rb +++ b/spec/requests/transfers_requests_spec.rb @@ -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 diff --git a/spec/requests/vendors_requests_spec.rb b/spec/requests/vendors_requests_spec.rb index e87c2906c1..79263b44cf 100644 --- a/spec/requests/vendors_requests_spec.rb +++ b/spec/requests/vendors_requests_spec.rb @@ -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') @@ -212,10 +207,4 @@ end end end - - context "While not signed in" do - let(:object) { create(:vendor) } - - include_examples "requiring authorization" - end end diff --git a/spec/support/authorization_specs.rb b/spec/support/authorization_specs.rb index 6fbd61f8f9..9868af2f05 100644 --- a/spec/support/authorization_specs.rb +++ b/spec/support/authorization_specs.rb @@ -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