diff --git a/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb b/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb index 9c92666..9cec560 100644 --- a/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb +++ b/app/controllers/decidim/direct_verifications/verification/admin/authorizations_controller.rb @@ -22,7 +22,12 @@ def destroy private def collection - Decidim::Authorization.where(name: "direct_verifications").includes(:user) + # Decidim::Verifications::Authorizations Query + Decidim::Verifications::Authorizations.new( + organization: current_organization, + name: "direct_verifications", + granted: true + ).query end def authorization diff --git a/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb b/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb index 3ca8563..fa6a778 100644 --- a/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb +++ b/spec/system/decidim/direct_verifications/admin/admin_manages_imported_authorizations_spec.rb @@ -5,8 +5,10 @@ describe "Admin manages imported authorizations", type: :system do let(:organization) { create(:organization) } let(:user) { create(:user, :admin, :confirmed, organization: organization) } + let(:out_of_scope_user) { create(:user, :confirmed) } - let!(:authorization) { create(:authorization, :direct_verification) } + let!(:authorization) { create(:authorization, :direct_verification, user: user) } + let!(:out_of_scope_authorization) { create(:authorization, :direct_verification, user: out_of_scope_user) } let!(:non_direct_authorization) { create(:authorization) } let(:scope) { "decidim.direct_verifications.verification.admin" } @@ -36,6 +38,7 @@ end expect(page).not_to have_content(non_direct_authorization.name) + expect(page).not_to have_content(out_of_scope_authorization.user.name) end it "lets users navigate to stats and new import" do