diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-29 09:58:20 +0200 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-05-31 21:56:18 +0200 |
commit | 8a9a62e3294d92f4e70be6f427c17241a2b7a232 (patch) | |
tree | 2337d1455c8fb9ebadbe73e872dbdc388a627315 /spec/serializers | |
parent | 68569584b728ac2dd5100593e9db302f362994f5 (diff) | |
download | gitlab-ce-8a9a62e3294d92f4e70be6f427c17241a2b7a232.tar.gz |
Incorporate review
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/build_artifact_entity_spec.rb | 14 | ||||
-rw-r--r-- | spec/serializers/build_details_entity_spec.rb | 25 | ||||
-rw-r--r-- | spec/serializers/merge_request_entity_spec.rb | 2 | ||||
-rw-r--r-- | spec/serializers/runner_entity_spec.rb | 4 |
4 files changed, 38 insertions, 7 deletions
diff --git a/spec/serializers/build_artifact_entity_spec.rb b/spec/serializers/build_artifact_entity_spec.rb index b4eef20d6a6..a2e24ae1535 100644 --- a/spec/serializers/build_artifact_entity_spec.rb +++ b/spec/serializers/build_artifact_entity_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe BuildArtifactEntity do - let(:job) { create(:ci_build, name: 'test:job') } + let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) } let(:entity) do described_class.new(job, request: double) @@ -14,9 +14,19 @@ describe BuildArtifactEntity do expect(subject[:name]).to eq 'test:job' end - it 'contains path to the artifacts' do + it 'exposes information about expiration of artifacts' do + expect(subject).to include(:expired, :expire_at) + end + + it 'contains paths to the artifacts' do expect(subject[:path]) .to include "jobs/#{job.id}/artifacts/download" + + expect(subject[:keep_path]) + .to include "jobs/#{build.id}/artifacts/keep" + + expect(subject[:browse_path]) + .to include "jobs/#{build.id}/artifacts/browse" end end end diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb index 99829348348..8533cd77d1d 100644 --- a/spec/serializers/build_details_entity_spec.rb +++ b/spec/serializers/build_details_entity_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe BuildDetailsEntity do + set(:user) { create(:admin) } + it 'inherits from BuildEntity' do expect(described_class).to be < BuildEntity end @@ -17,7 +19,6 @@ describe BuildDetailsEntity do end context 'when the user has access to issues and merge requests' do - let(:user) { create(:admin) } let!(:merge_request) do create(:merge_request, source_project: project, source_branch: build.ref) end @@ -29,7 +30,27 @@ describe BuildDetailsEntity do it 'contains the needed key value pairs' do expect(subject).to include(:coverage, :erased_at, :duration) expect(subject).to include(:artifacts, :runner, :pipeline) - expect(subject).to include(:raw_path, :merge_request_path, :new_issue_path) + expect(subject).to include(:raw_path, :merge_request, :new_issue_path) + end + + it 'exposes details of the merge request' do + expect(subject[:merge_request]).to include(:iid, :path) + end + + context 'when the build has been erased' do + let!(:build) { create(:ci_build, :erasable, project: project) } + + it 'exposes the user whom erased the build' do + expect(subject).to include(:erase_path) + end + end + + context 'when the build has been erased' do + let!(:build) { create(:ci_build, erased_at: Time.now, project: project, erased_by: user) } + + it 'exposes the user whom erased the build' do + expect(subject).to include(:erased_by) + end end end diff --git a/spec/serializers/merge_request_entity_spec.rb b/spec/serializers/merge_request_entity_spec.rb index b75c73e78c2..d38433c2365 100644 --- a/spec/serializers/merge_request_entity_spec.rb +++ b/spec/serializers/merge_request_entity_spec.rb @@ -26,7 +26,7 @@ describe MergeRequestEntity do pipeline = build_stubbed(:ci_pipeline) allow(resource).to receive(:head_pipeline).and_return(pipeline) - pipeline_payload = PipelineEntity + pipeline_payload = PipelineDetailsEntity .represent(pipeline, request: req) .as_json diff --git a/spec/serializers/runner_entity_spec.rb b/spec/serializers/runner_entity_spec.rb index 036701eccaa..4f25a8dcfa0 100644 --- a/spec/serializers/runner_entity_spec.rb +++ b/spec/serializers/runner_entity_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe RunnerEntity do - let(:runner) { create(:ci_runner) } + let(:runner) { create(:ci_runner, :specific) } let(:entity) { described_class.new(runner, request: request, current_user: user) } let(:request) { double('request') } let(:project) { create(:empty_project) } @@ -17,7 +17,7 @@ describe RunnerEntity do it 'contains required fields' do expect(subject).to include(:id, :description) - expect(subject).to include(:edit_runner_path) + expect(subject).to include(:edit_path) end end end |