2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-21 04:48:07 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::CycleAnalytics::Permissions do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, public_builds: false) }
|
2016-11-21 04:48:07 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
subject { described_class.get(user: user, project: project) }
|
|
|
|
|
|
|
|
context 'user with no relation to the project' do
|
|
|
|
it 'has no permissions to issue stage' do
|
|
|
|
expect(subject[:issue]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to test stage' do
|
|
|
|
expect(subject[:test]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to staging stage' do
|
|
|
|
expect(subject[:staging]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to production stage' do
|
|
|
|
expect(subject[:production]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to code stage' do
|
|
|
|
expect(subject[:code]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to review stage' do
|
|
|
|
expect(subject[:review]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to plan stage' do
|
|
|
|
expect(subject[:plan]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-11 10:36:08 -04:00
|
|
|
context 'user is maintainer' do
|
2016-11-21 04:48:07 -05:00
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2016-11-21 04:48:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to issue stage' do
|
|
|
|
expect(subject[:issue]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to test stage' do
|
|
|
|
expect(subject[:test]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to staging stage' do
|
|
|
|
expect(subject[:staging]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to production stage' do
|
|
|
|
expect(subject[:production]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to code stage' do
|
|
|
|
expect(subject[:code]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to review stage' do
|
|
|
|
expect(subject[:review]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to plan stage' do
|
|
|
|
expect(subject[:plan]).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has no build permissions' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_guest(user)
|
2016-11-21 04:48:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to issue stage' do
|
|
|
|
expect(subject[:issue]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to test stage' do
|
|
|
|
expect(subject[:test]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to staging stage' do
|
|
|
|
expect(subject[:staging]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has no merge request permissions' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_guest(user)
|
2016-11-21 04:48:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to issue stage' do
|
|
|
|
expect(subject[:issue]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to code stage' do
|
|
|
|
expect(subject[:code]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to review stage' do
|
|
|
|
expect(subject[:review]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user has no issue permissions' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2016-11-21 04:48:07 -05:00
|
|
|
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has permissions to code stage' do
|
|
|
|
expect(subject[:code]).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to issue stage' do
|
|
|
|
expect(subject[:issue]).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has no permissions to production stage' do
|
|
|
|
expect(subject[:production]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|