From 44135af103d5d55697109a8d5082299246e0d0cf Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Wed, 16 Dec 2020 20:55:03 +0100 Subject: [PATCH] add ability test for temporary role. #687 --- spec/models/ability_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 8aa1c55e9..e5ec1b7c1 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -325,6 +325,32 @@ it { is_expected.not_to be_able_to(:destroy, doi) } end + context "when is temporary" do + let(:token) { User.generate_token(role_id: "temporary", provider_id: provider.symbol.downcase, client_id: client.symbol.downcase) } + + it { is_expected.to be_able_to(:read, user) } + + it { is_expected.to be_able_to(:read, provider) } + it { is_expected.not_to be_able_to(:create, provider) } + it { is_expected.to be_able_to(:update, provider) } + it { is_expected.not_to be_able_to(:destroy, provider) } + it { is_expected.not_to be_able_to(:read_billing_information, provider) } + it { is_expected.to be_able_to(:read_contact_information, provider) } + + it { is_expected.to be_able_to(:read, client) } + it { is_expected.not_to be_able_to(:create, client) } + it { is_expected.to be_able_to(:update, client) } + it { is_expected.not_to be_able_to(:destroy, client) } + it { is_expected.not_to be_able_to(:transfer, client) } + it { is_expected.to be_able_to(:read_contact_information, client) } + + it { is_expected.to be_able_to(:read, doi) } + it { is_expected.not_to be_able_to(:transfer, doi) } + it { is_expected.not_to be_able_to(:create, doi) } + it { is_expected.not_to be_able_to(:update, doi) } + it { is_expected.not_to be_able_to(:destroy, doi) } + end + context "when is anonymous" do let(:token) { nil }