summaryrefslogtreecommitdiff
path: root/spec/serializers
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-10-05 10:13:06 +0900
committerShinya Maeda <shinya@gitlab.com>2018-10-05 10:13:06 +0900
commitaf2c51d7ca73e16cdb9a11fff6d097116c7c5324 (patch)
treecd7f07f36e09a357902a262cbb932f25d254a16c /spec/serializers
parentacfe7ec65c75f65f2f87bf3e8598c1725c9150f4 (diff)
parentf71c497f5da791a35876206255e342a9bb5e49c5 (diff)
downloadgitlab-ce-af2c51d7ca73e16cdb9a11fff6d097116c7c5324.tar.gz
Merge branch 'master-ce' into scheduled-manual-jobs
Diffstat (limited to 'spec/serializers')
-rw-r--r--spec/serializers/commit_entity_spec.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/serializers/commit_entity_spec.rb b/spec/serializers/commit_entity_spec.rb
index 35215e06f5f..b9995818e98 100644
--- a/spec/serializers/commit_entity_spec.rb
+++ b/spec/serializers/commit_entity_spec.rb
@@ -1,10 +1,11 @@
require 'spec_helper'
describe CommitEntity do
+ SIGNATURE_HTML = 'TEST'.freeze
+
let(:entity) do
described_class.new(commit, request: request)
end
-
let(:request) { double('request') }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
@@ -12,7 +13,11 @@ describe CommitEntity do
subject { entity.as_json }
before do
+ render = double('render')
+ allow(render).to receive(:call).and_return(SIGNATURE_HTML)
+
allow(request).to receive(:project).and_return(project)
+ allow(request).to receive(:render).and_return(render)
end
context 'when commit author is a user' do
@@ -61,7 +66,7 @@ describe CommitEntity do
context 'when type is "full"' do
let(:entity) do
- described_class.new(commit, request: request, type: :full)
+ described_class.new(commit, request: request, type: :full, pipeline_ref: project.default_branch, pipeline_project: project)
end
it 'exposes extra properties' do
@@ -70,6 +75,25 @@ describe CommitEntity do
expect(subject.fetch(:description_html)).not_to be_nil
expect(subject.fetch(:title_html)).not_to be_nil
end
+
+ context 'when commit has signature' do
+ let(:commit) { project.commit(TestEnv::BRANCH_SHA['signed-commits']) }
+
+ it 'exposes "signature_html"' do
+ expect(request.render).to receive(:call)
+ expect(subject.fetch(:signature_html)).to be SIGNATURE_HTML
+ end
+ end
+
+ context 'when commit has pipeline' do
+ before do
+ create(:ci_pipeline, project: project, sha: commit.id)
+ end
+
+ it 'exposes "pipeline_status_path"' do
+ expect(subject.fetch(:pipeline_status_path)).not_to be_nil
+ end
+ end
end
context 'when commit_url_params is set' do