diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-12-01 11:26:51 -0200 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-12-05 12:54:10 -0200 |
commit | 5cf3ff27c8f955e701837529d72a070697a41a04 (patch) | |
tree | 77fe5f9413941353b87157fc0a55323844fd3c22 /spec/serializers | |
parent | f586dc0735545d96d73dd26ff182ddf2d50dd715 (diff) | |
download | gitlab-ce-5cf3ff27c8f955e701837529d72a070697a41a04.tar.gz |
Use actual head pipeline on merge request serializer
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/merge_request_entity_spec.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/spec/serializers/merge_request_entity_spec.rb b/spec/serializers/merge_request_entity_spec.rb index f9285049c0d..1ad672fd355 100644 --- a/spec/serializers/merge_request_entity_spec.rb +++ b/spec/serializers/merge_request_entity_spec.rb @@ -5,22 +5,34 @@ describe MergeRequestEntity do let(:resource) { create(:merge_request, source_project: project, target_project: project) } let(:user) { create(:user) } - let(:request) { double('request', current_user: user) } + let(:request) { double('request', current_user: user, project: project) } subject do described_class.new(resource, request: request).as_json end - it 'includes pipeline' do - req = double('request', current_user: user) - pipeline = build_stubbed(:ci_pipeline) - allow(resource).to receive(:head_pipeline).and_return(pipeline) + describe 'pipeline' do + let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: resource.source_branch, sha: resource.source_branch_sha, head_pipeline_of: resource) } - pipeline_payload = PipelineDetailsEntity - .represent(pipeline, request: req) - .as_json + context 'when is up to date' do + let(:req) { double('request', current_user: user, project: project) } - expect(subject[:pipeline]).to eq(pipeline_payload) + it 'returns pipeline' do + pipeline_payload = PipelineDetailsEntity + .represent(pipeline, request: req) + .as_json + + expect(subject[:pipeline]).to eq(pipeline_payload) + end + end + + context 'when is not up to date' do + it 'returns nil' do + pipeline.update(sha: "not up to date") + + expect(subject[:pipeline]).to be_nil + end + end end it 'includes issues_links' do |