From 9aaae6d60f7537f55f862f4d61de7a0d3a3b6bc2 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 25 Jul 2018 21:25:57 +0900 Subject: Fix spec file name - build_runner_presenter_spec.rb --- lib/api/runner.rb | 4 +- spec/presenters/ci/build_runner_presenter_spec.rb | 86 ++++++++++++++++++++++ spec/presenters/ci/builds/runner_presenter_spec.rb | 86 ---------------------- 3 files changed, 88 insertions(+), 88 deletions(-) create mode 100644 spec/presenters/ci/build_runner_presenter_spec.rb delete mode 100644 spec/presenters/ci/builds/runner_presenter_spec.rb diff --git a/lib/api/runner.rb b/lib/api/runner.rb index dca1b208dad..fd4bb163c77 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -110,7 +110,7 @@ module API if result.build Gitlab::Metrics.add_event(:build_found, project: result.build.project.full_path) - present Ci::Builds::RunnerPresenter.new(result.build), with: Entities::JobRequest::Response + present Ci::BuildRunnerPresenter.new(result.build), with: Entities::JobRequest::Response else Gitlab::Metrics.add_event(:build_not_found) header 'X-GitLab-Last-Update', new_update @@ -282,7 +282,7 @@ module API end if job.update(artifacts_expire_in: expire_in) - present Ci::Builds::RunnerPresenter.new(job), with: Entities::JobRequest::Response + present Ci::BuildRunnerPresenter.new(job), with: Entities::JobRequest::Response else render_validation_error!(job) end diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb new file mode 100644 index 00000000000..e7019b990dd --- /dev/null +++ b/spec/presenters/ci/build_runner_presenter_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +describe Ci::BuildRunnerPresenter do + let(:presenter) { described_class.new(build) } + let(:archive) { { paths: ['sample.txt'] } } + let(:junit) { { junit: ['junit.xml'] } } + + let(:archive_expectation) do + { + artifact_type: :archive, + artifact_format: :zip, + paths: archive[:paths], + untracked: archive[:untracked] + } + end + + let(:junit_expectation) do + { + name: 'junit.xml', + artifact_type: :junit, + artifact_format: :gzip, + paths: ['junit.xml'], + when: 'always' + } + end + + describe '#artifacts' do + context "when option contains archive-type artifacts" do + let(:build) { create(:ci_build, options: { artifacts: archive } ) } + + it 'presents correct hash' do + expect(presenter.artifacts.first).to include(archive_expectation) + end + + context "when untracked is specified" do + let(:archive) { { untracked: true } } + + it 'presents correct hash' do + expect(presenter.artifacts.first).to include(archive_expectation) + end + end + + context "when untracked and paths are missing" do + let(:archive) { { when: 'always' } } + + it 'does not present hash' do + expect(presenter.artifacts).to be_empty + end + end + end + + context "when option has 'junit' keyword" do + let(:build) { create(:ci_build, options: { artifacts: { reports: junit } } ) } + + it 'presents correct hash' do + expect(presenter.artifacts.first).to include(junit_expectation) + end + end + + context "when option has both archive and reports specification" do + let(:build) { create(:ci_build, options: { script: 'echo', artifacts: { **archive, reports: junit } } ) } + + it 'presents correct hash' do + expect(presenter.artifacts.first).to include(archive_expectation) + expect(presenter.artifacts.second).to include(junit_expectation) + end + + context "when archive specifies 'expire_in' keyword" do + let(:archive) { { paths: ['sample.txt'], expire_in: '3 mins 4 sec' } } + + it 'inherits expire_in from archive' do + expect(presenter.artifacts.first).to include({ **archive_expectation, expire_in: '3 mins 4 sec' }) + expect(presenter.artifacts.second).to include({ **junit_expectation, expire_in: '3 mins 4 sec' }) + end + end + end + + context "when option has no artifact keywords" do + let(:build) { create(:ci_build, :no_options) } + + it 'does not present hash' do + expect(presenter.artifacts).to be_nil + end + end + end +end diff --git a/spec/presenters/ci/builds/runner_presenter_spec.rb b/spec/presenters/ci/builds/runner_presenter_spec.rb deleted file mode 100644 index e7019b990dd..00000000000 --- a/spec/presenters/ci/builds/runner_presenter_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require 'spec_helper' - -describe Ci::BuildRunnerPresenter do - let(:presenter) { described_class.new(build) } - let(:archive) { { paths: ['sample.txt'] } } - let(:junit) { { junit: ['junit.xml'] } } - - let(:archive_expectation) do - { - artifact_type: :archive, - artifact_format: :zip, - paths: archive[:paths], - untracked: archive[:untracked] - } - end - - let(:junit_expectation) do - { - name: 'junit.xml', - artifact_type: :junit, - artifact_format: :gzip, - paths: ['junit.xml'], - when: 'always' - } - end - - describe '#artifacts' do - context "when option contains archive-type artifacts" do - let(:build) { create(:ci_build, options: { artifacts: archive } ) } - - it 'presents correct hash' do - expect(presenter.artifacts.first).to include(archive_expectation) - end - - context "when untracked is specified" do - let(:archive) { { untracked: true } } - - it 'presents correct hash' do - expect(presenter.artifacts.first).to include(archive_expectation) - end - end - - context "when untracked and paths are missing" do - let(:archive) { { when: 'always' } } - - it 'does not present hash' do - expect(presenter.artifacts).to be_empty - end - end - end - - context "when option has 'junit' keyword" do - let(:build) { create(:ci_build, options: { artifacts: { reports: junit } } ) } - - it 'presents correct hash' do - expect(presenter.artifacts.first).to include(junit_expectation) - end - end - - context "when option has both archive and reports specification" do - let(:build) { create(:ci_build, options: { script: 'echo', artifacts: { **archive, reports: junit } } ) } - - it 'presents correct hash' do - expect(presenter.artifacts.first).to include(archive_expectation) - expect(presenter.artifacts.second).to include(junit_expectation) - end - - context "when archive specifies 'expire_in' keyword" do - let(:archive) { { paths: ['sample.txt'], expire_in: '3 mins 4 sec' } } - - it 'inherits expire_in from archive' do - expect(presenter.artifacts.first).to include({ **archive_expectation, expire_in: '3 mins 4 sec' }) - expect(presenter.artifacts.second).to include({ **junit_expectation, expire_in: '3 mins 4 sec' }) - end - end - end - - context "when option has no artifact keywords" do - let(:build) { create(:ci_build, :no_options) } - - it 'does not present hash' do - expect(presenter.artifacts).to be_nil - end - end - end -end -- cgit v1.2.1