Commit 28553dbc authored by Lin Jen-Shin's avatar Lin Jen-Shin

Update tests due to permission changes

parent 005870d5
...@@ -218,7 +218,7 @@ describe Projects::JobsController do ...@@ -218,7 +218,7 @@ describe Projects::JobsController do
describe 'POST retry' do describe 'POST retry' do
before do before do
project.add_developer(user) project.add_master(user)
sign_in(user) sign_in(user)
post_retry post_retry
...@@ -250,7 +250,7 @@ describe Projects::JobsController do ...@@ -250,7 +250,7 @@ describe Projects::JobsController do
describe 'POST play' do describe 'POST play' do
before do before do
project.add_developer(user) project.add_master(user)
create(:protected_branch, :developers_can_merge, create(:protected_branch, :developers_can_merge,
name: 'master', project: project) name: 'master', project: project)
...@@ -290,7 +290,7 @@ describe Projects::JobsController do ...@@ -290,7 +290,7 @@ describe Projects::JobsController do
describe 'POST cancel' do describe 'POST cancel' do
before do before do
project.add_developer(user) project.add_master(user)
sign_in(user) sign_in(user)
post_cancel post_cancel
...@@ -326,7 +326,7 @@ describe Projects::JobsController do ...@@ -326,7 +326,7 @@ describe Projects::JobsController do
describe 'POST cancel_all' do describe 'POST cancel_all' do
before do before do
project.add_developer(user) project.add_master(user)
sign_in(user) sign_in(user)
end end
...@@ -368,7 +368,7 @@ describe Projects::JobsController do ...@@ -368,7 +368,7 @@ describe Projects::JobsController do
describe 'POST erase' do describe 'POST erase' do
before do before do
project.add_developer(user) project.add_master(user)
sign_in(user) sign_in(user)
post_erase post_erase
......
...@@ -8,7 +8,7 @@ describe Projects::PipelinesController do ...@@ -8,7 +8,7 @@ describe Projects::PipelinesController do
let(:feature) { ProjectFeature::DISABLED } let(:feature) { ProjectFeature::DISABLED }
before do before do
project.add_developer(user) project.add_master(user)
project.project_feature.update( project.project_feature.update(
builds_access_level: feature) builds_access_level: feature)
......
...@@ -48,7 +48,7 @@ describe Gitlab::Ci::Status::Build::Cancelable do ...@@ -48,7 +48,7 @@ describe Gitlab::Ci::Status::Build::Cancelable do
describe '#has_action?' do describe '#has_action?' do
context 'when user is allowed to update build' do context 'when user is allowed to update build' do
before do before do
build.project.team << [user, :developer] build.project.add_master(user)
end end
it { is_expected.to have_action } it { is_expected.to have_action }
......
...@@ -7,7 +7,7 @@ describe Gitlab::Ci::Status::Build::Factory do ...@@ -7,7 +7,7 @@ describe Gitlab::Ci::Status::Build::Factory do
let(:factory) { described_class.new(build, user) } let(:factory) { described_class.new(build, user) }
before do before do
project.team << [user, :developer] project.add_master(user)
end end
context 'when build is successful' do context 'when build is successful' do
...@@ -225,19 +225,20 @@ describe Gitlab::Ci::Status::Build::Factory do ...@@ -225,19 +225,20 @@ describe Gitlab::Ci::Status::Build::Factory do
end end
context 'when user has ability to play action' do context 'when user has ability to play action' do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
name: build.ref, project: project)
end
it 'fabricates status that has action' do it 'fabricates status that has action' do
expect(status).to have_action expect(status).to have_action
end end
end end
context 'when user does not have ability to play action' do context 'when user does not have ability to play action' do
before do
project.team.truncate
project.add_developer(user)
create(:protected_branch, :no_one_can_push,
name: build.ref, project: project)
end
it 'fabricates status that has no action' do it 'fabricates status that has no action' do
expect(status).not_to have_action expect(status).not_to have_action
end end
...@@ -262,6 +263,14 @@ describe Gitlab::Ci::Status::Build::Factory do ...@@ -262,6 +263,14 @@ describe Gitlab::Ci::Status::Build::Factory do
end end
context 'when user is not allowed to execute manual action' do context 'when user is not allowed to execute manual action' do
before do
project.team.truncate
project.add_developer(user)
create(:protected_branch, :no_one_can_push,
name: build.ref, project: project)
end
it 'fabricates status with correct details' do it 'fabricates status with correct details' do
expect(status.text).to eq 'manual' expect(status.text).to eq 'manual'
expect(status.group).to eq 'manual' expect(status.group).to eq 'manual'
......
...@@ -48,7 +48,7 @@ describe Gitlab::Ci::Status::Build::Retryable do ...@@ -48,7 +48,7 @@ describe Gitlab::Ci::Status::Build::Retryable do
describe '#has_action?' do describe '#has_action?' do
context 'when user is allowed to update build' do context 'when user is allowed to update build' do
before do before do
build.project.team << [user, :developer] build.project.add_master(user)
end end
it { is_expected.to have_action } it { is_expected.to have_action }
......
...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Status::Build::Stop do ...@@ -20,7 +20,7 @@ describe Gitlab::Ci::Status::Build::Stop do
describe '#has_action?' do describe '#has_action?' do
context 'when user is allowed to update build' do context 'when user is allowed to update build' do
before do before do
build.project.team << [user, :developer] build.project.add_master(user)
end end
it { is_expected.to have_action } it { is_expected.to have_action }
......
...@@ -832,7 +832,7 @@ describe Ci::Pipeline, models: true do ...@@ -832,7 +832,7 @@ describe Ci::Pipeline, models: true do
context 'on failure and build retry' do context 'on failure and build retry' do
before do before do
build.drop build.drop
project.add_developer(user) project.add_master(user)
Ci::Build.retry(build, user) Ci::Build.retry(build, user)
end end
...@@ -1063,7 +1063,7 @@ describe Ci::Pipeline, models: true do ...@@ -1063,7 +1063,7 @@ describe Ci::Pipeline, models: true do
let(:latest_status) { pipeline.statuses.latest.pluck(:status) } let(:latest_status) { pipeline.statuses.latest.pluck(:status) }
before do before do
project.add_developer(user) project.add_master(user)
end end
context 'when there is a failed build and failed external status' do context 'when there is a failed build and failed external status' do
......
...@@ -8,7 +8,7 @@ describe JobEntity do ...@@ -8,7 +8,7 @@ describe JobEntity do
before do before do
allow(request).to receive(:current_user).and_return(user) allow(request).to receive(:current_user).and_return(user)
project.add_developer(user) project.add_master(user)
end end
let(:entity) do let(:entity) do
...@@ -90,6 +90,10 @@ describe JobEntity do ...@@ -90,6 +90,10 @@ describe JobEntity do
end end
context 'when user is not allowed to trigger action' do context 'when user is not allowed to trigger action' do
before do
project.team.truncate
end
it 'does not contain path to play action' do it 'does not contain path to play action' do
expect(subject).not_to include(:play_path) expect(subject).not_to include(:play_path)
end end
......
...@@ -52,7 +52,7 @@ describe PipelineDetailsEntity do ...@@ -52,7 +52,7 @@ describe PipelineDetailsEntity do
context 'user has ability to retry pipeline' do context 'user has ability to retry pipeline' do
before do before do
project.team << [user, :developer] project.add_master(user)
end end
it 'retryable flag is true' do it 'retryable flag is true' do
...@@ -80,7 +80,7 @@ describe PipelineDetailsEntity do ...@@ -80,7 +80,7 @@ describe PipelineDetailsEntity do
context 'user has ability to cancel pipeline' do context 'user has ability to cancel pipeline' do
before do before do
project.add_developer(user) project.add_master(user)
end end
it 'cancelable flag is true' do it 'cancelable flag is true' do
......
...@@ -52,7 +52,7 @@ describe PipelineEntity do ...@@ -52,7 +52,7 @@ describe PipelineEntity do
context 'user has ability to retry pipeline' do context 'user has ability to retry pipeline' do
before do before do
project.team << [user, :developer] project.add_master(user)
end end
it 'contains retry path' do it 'contains retry path' do
...@@ -80,7 +80,7 @@ describe PipelineEntity do ...@@ -80,7 +80,7 @@ describe PipelineEntity do
context 'user has ability to cancel pipeline' do context 'user has ability to cancel pipeline' do
before do before do
project.add_developer(user) project.add_master(user)
end end
it 'contains cancel path' do it 'contains cancel path' do
......
...@@ -9,7 +9,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do ...@@ -9,7 +9,7 @@ describe Ci::ProcessPipelineService, '#execute', :services do
end end
before do before do
project.add_developer(user) project.add_master(user)
end end
context 'when simple pipeline is defined' do context 'when simple pipeline is defined' do
......
...@@ -85,7 +85,7 @@ describe Ci::RetryBuildService, :services do ...@@ -85,7 +85,7 @@ describe Ci::RetryBuildService, :services do
context 'when user has ability to execute build' do context 'when user has ability to execute build' do
before do before do
project.add_developer(user) project.add_master(user)
end end
it_behaves_like 'build duplication' it_behaves_like 'build duplication'
...@@ -131,7 +131,7 @@ describe Ci::RetryBuildService, :services do ...@@ -131,7 +131,7 @@ describe Ci::RetryBuildService, :services do
context 'when user has ability to execute build' do context 'when user has ability to execute build' do
before do before do
project.add_developer(user) project.add_master(user)
end end
it_behaves_like 'build duplication' it_behaves_like 'build duplication'
......
...@@ -244,13 +244,9 @@ describe Ci::RetryPipelineService, '#execute', :services do ...@@ -244,13 +244,9 @@ describe Ci::RetryPipelineService, '#execute', :services do
create_build('verify', :canceled, 1) create_build('verify', :canceled, 1)
end end
it 'does not reprocess manual action' do it 'raises an error' do
service.execute(pipeline) expect { service.execute(pipeline) }
.to raise_error Gitlab::Access::AccessDeniedError
expect(build('test')).to be_pending
expect(build('deploy')).to be_failed
expect(build('verify')).to be_created
expect(pipeline.reload).to be_running
end end
end end
...@@ -261,13 +257,9 @@ describe Ci::RetryPipelineService, '#execute', :services do ...@@ -261,13 +257,9 @@ describe Ci::RetryPipelineService, '#execute', :services do
create_build('verify', :canceled, 2) create_build('verify', :canceled, 2)
end end
it 'does not reprocess manual action' do it 'raises an error' do
service.execute(pipeline) expect { service.execute(pipeline) }
.to raise_error Gitlab::Access::AccessDeniedError
expect(build('test')).to be_pending
expect(build('deploy')).to be_failed
expect(build('verify')).to be_created
expect(pipeline.reload).to be_running
end end
end end
end end
......
...@@ -244,7 +244,7 @@ describe CreateDeploymentService, services: true do ...@@ -244,7 +244,7 @@ describe CreateDeploymentService, services: true do
context 'when job is retried' do context 'when job is retried' do
it_behaves_like 'creates deployment' do it_behaves_like 'creates deployment' do
before do before do
project.add_developer(user) project.add_master(user)
end end
let(:deployable) { Ci::Build.retry(job, user) } let(:deployable) { Ci::Build.retry(job, user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment