diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-03-01 13:05:04 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-03-06 12:30:35 +0300 |
commit | 50776d2d298c3b6c98e2531f116ca43ba10dcda4 (patch) | |
tree | 32e9e41dafa65c0ecff65fa941918e09d268f28c /spec/serializers/pipeline_entity_spec.rb | |
parent | c9e5ce8dbd25203484b43c48f0a55a5d7bf396e8 (diff) |
Expose merge request entity for pipelines
Add preload
Fix
ok
Write tests
test only postgresql
ok
add more test
;
Improve wording
Add changelog
Fix
Diffstat (limited to 'spec/serializers/pipeline_entity_spec.rb')
-rw-r--r-- | spec/serializers/pipeline_entity_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb index 774486dcb6d..11040862129 100644 --- a/spec/serializers/pipeline_entity_spec.rb +++ b/spec/serializers/pipeline_entity_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe PipelineEntity do + include Gitlab::Routing + set(:user) { create(:user) } let(:request) { double('request') } @@ -128,5 +130,48 @@ describe PipelineEntity do .to eq 'CI/CD YAML configuration error!' end end + + context 'when pipeline is detached merge request pipeline' do + let(:merge_request) { create(:merge_request, :with_merge_request_pipeline) } + let(:project) { merge_request.target_project } + let(:pipeline) { merge_request.merge_request_pipelines.first } + + it 'makes detached flag true' do + expect(subject[:flags][:detached]).to be_truthy + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it 'has merge request information' do + expect(subject[:merge_request][:iid]).to eq(merge_request.iid) + + expect(project_merge_request_path(project, merge_request)) + .to include(subject[:merge_request][:path]) + + expect(subject[:merge_request][:title]).to eq(merge_request.title) + + expect(subject[:merge_request][:source_branch]) + .to eq(merge_request.source_branch) + + expect(project_branch_path(project, merge_request.source_branch)) + .to include(subject[:merge_request][:source_branch_path]) + + expect(subject[:merge_request][:target_branch]) + .to eq(merge_request.target_branch) + + expect(project_branch_path(project, merge_request.target_branch)) + .to include(subject[:merge_request][:target_branch_path]) + end + end + + context 'when user is an external user' do + it 'has no merge request information' do + expect(subject[:merge_request]).to be_nil + end + end + end end end |