diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-02-08 15:53:35 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-02-08 15:53:35 +0300 |
commit | 6b99848be3b444d015519a9a0b4ac9fa76cdd8e1 (patch) | |
tree | 1025523a32a09ebffc527280604f24aae120ee26 /spec/serializers/deployment_entity_spec.rb | |
parent | acb939d7e9009b178d29fbcd4b286dadec547acb (diff) |
Move permission check of manual actions of deployments
Diffstat (limited to 'spec/serializers/deployment_entity_spec.rb')
-rw-r--r-- | spec/serializers/deployment_entity_spec.rb | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index cfa5414b40f..894fd7a0a12 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -1,14 +1,22 @@ require 'spec_helper' describe DeploymentEntity do - let(:user) { create(:user) } + let(:user) { developer } + let(:developer) { create(:user) } + let(:reporter) { create(:user) } + let(:project) { create(:project) } let(:request) { double('request') } - let(:deployment) { create(:deployment) } + let(:deployment) { create(:deployment, deployable: build, project: project) } + let(:build) { create(:ci_build, :manual, pipeline: pipeline) } + let(:pipeline) { create(:ci_pipeline, project: project, user: user) } let(:entity) { described_class.new(deployment, request: request) } subject { entity.as_json } before do + project.add_developer(developer) + project.add_reporter(reporter) allow(request).to receive(:current_user).and_return(user) + allow(request).to receive(:project).and_return(project) end it 'exposes internal deployment id' do @@ -23,6 +31,24 @@ describe DeploymentEntity do expect(subject).to include(:created_at) end + context 'when the pipeline has another manual action' do + let(:other_build) { create(:ci_build, :manual, name: 'another deploy', pipeline: pipeline) } + let!(:other_deployment) { create(:deployment, deployable: other_build) } + + it 'returns another manual action' do + expect(subject[:manual_actions].count).to eq(1) + expect(subject[:manual_actions].first[:name]).to eq('another deploy') + end + + context 'when user is a reporter' do + let(:user) { reporter } + + it 'returns another manual action' do + expect(subject[:manual_actions]).not_to be_present + end + end + end + describe 'scheduled_actions' do let(:project) { create(:project, :repository) } let(:pipeline) { create(:ci_pipeline, project: project, user: user) } |