Skip to content

Commit

Permalink
add ability test for temporary role. #687
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 16, 2020
1 parent bd254a3 commit 44135af
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/models/ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit 44135af

Please sign in to comment.