mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 10:14:17 +08:00
Update PermissionEval tests with team check
This commit is contained in:
parent
5de51f9c58
commit
f3e6a35121
1 changed files with 48 additions and 6 deletions
|
@ -5,8 +5,10 @@ describe SmartAnnotations::PermissionEval do
|
||||||
let(:subject) { described_class }
|
let(:subject) { described_class }
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
let(:team) { create :team }
|
let(:team) { create :team }
|
||||||
let(:user_team) { create :user_team, user: user, team: team, role: 2 }
|
let(:another_team) { create :team }
|
||||||
let(:project) { create :project, name: 'my project' }
|
let!(:user_team) { create :user_team, user: user, team: team, role: :admin }
|
||||||
|
let(:project) { create :project, name: 'my project', team: team }
|
||||||
|
let!(:user_project) { create :user_project, :owner, project: project, user: user }
|
||||||
let(:experiment) do
|
let(:experiment) do
|
||||||
create :experiment, name: 'my experiment',
|
create :experiment, name: 'my experiment',
|
||||||
project: project,
|
project: project,
|
||||||
|
@ -19,29 +21,69 @@ describe SmartAnnotations::PermissionEval do
|
||||||
|
|
||||||
describe '#validate_prj_permissions/2' do
|
describe '#validate_prj_permissions/2' do
|
||||||
it 'returns a boolean' do
|
it 'returns a boolean' do
|
||||||
value = subject.send(:validate_prj_permissions, user, team, project)
|
value = subject.__send__(:validate_prj_permissions, user, team, project)
|
||||||
expect(value).to be_in([true, false])
|
expect(value).to be_in([true, false])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false on wrong team' do
|
||||||
|
value = subject.__send__(:validate_prj_permissions, user, another_team, project)
|
||||||
|
expect(value).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true on the same team' do
|
||||||
|
value = subject.__send__(:validate_prj_permissions, user, team, project)
|
||||||
|
expect(value).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#validate_exp_permissions/2' do
|
describe '#validate_exp_permissions/2' do
|
||||||
it 'returns a boolean' do
|
it 'returns a boolean' do
|
||||||
value = subject.send(:validate_exp_permissions, user, team, experiment)
|
value = subject.__send__(:validate_exp_permissions, user, team, experiment)
|
||||||
expect(value).to be_in([true, false])
|
expect(value).to be_in([true, false])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false on wrong team' do
|
||||||
|
value = subject.__send__(:validate_exp_permissions, user, another_team, experiment)
|
||||||
|
expect(value).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true on the same team' do
|
||||||
|
value = subject.__send__(:validate_exp_permissions, user, team, experiment)
|
||||||
|
expect(value).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#validate_tsk_permissions/2' do
|
describe '#validate_tsk_permissions/2' do
|
||||||
it 'returns a boolean' do
|
it 'returns a boolean' do
|
||||||
value = subject.send(:validate_tsk_permissions, user, team, task)
|
value = subject.__send__(:validate_tsk_permissions, user, team, task)
|
||||||
expect(value).to be_in([true, false])
|
expect(value).to be_in([true, false])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false on wrong team' do
|
||||||
|
value = subject.__send__(:validate_tsk_permissions, user, another_team, task)
|
||||||
|
expect(value).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true on the same team' do
|
||||||
|
value = subject.__send__(:validate_tsk_permissions, user, team, task)
|
||||||
|
expect(value).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#validate_rep_item_permissions/2' do
|
describe '#validate_rep_item_permissions/2' do
|
||||||
it 'returns a boolean' do
|
it 'returns a boolean' do
|
||||||
value = subject.send(:validate_rep_item_permissions, user, team, repository_item)
|
value = subject.__send__(:validate_rep_item_permissions, user, team, repository_item)
|
||||||
expect(value).to be_in([true, false])
|
expect(value).to be_in([true, false])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false on wrong team' do
|
||||||
|
value = subject.__send__(:validate_rep_item_permissions, user, another_team, repository_item)
|
||||||
|
expect(value).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true on the same team' do
|
||||||
|
value = subject.__send__(:validate_rep_item_permissions, user, team, repository_item)
|
||||||
|
expect(value).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue