Commit c3d24d0b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move unused consts from retry build service to specs

parent 6f843457
...@@ -5,18 +5,6 @@ module Ci ...@@ -5,18 +5,6 @@ module Ci
yaml_variables when environment coverage_regex yaml_variables when environment coverage_regex
description tag_list].freeze description tag_list].freeze
REJECT_ACCESSORS = %i[id status user token coverage trace runner
artifacts_expire_at artifacts_file
artifacts_metadata artifacts_size
created_at updated_at started_at finished_at
queued_at erased_by erased_at].freeze
IGNORE_ACCESSORS = %i[type lock_version target_url gl_project_id
deploy job_id base_tags commit_id deployments
erased_by_id last_deployment project_id runner_id
tag_taggings taggings tags trigger_request_id
user_id].freeze
def execute(build) def execute(build)
reprocess(build).tap do |new_build| reprocess(build).tap do |new_build|
build.pipeline.mark_as_processable_after_stage(build.stage_idx) build.pipeline.mark_as_processable_after_stage(build.stage_idx)
......
...@@ -10,6 +10,20 @@ describe Ci::RetryBuildService, :services do ...@@ -10,6 +10,20 @@ describe Ci::RetryBuildService, :services do
described_class.new(project, user) described_class.new(project, user)
end end
CLONE_ACCESSORS = described_class::CLONE_ACCESSORS
REJECT_ACCESSORS =
%i[id status user token coverage trace runner artifacts_expire_at
artifacts_file artifacts_metadata artifacts_size created_at
updated_at started_at finished_at queued_at erased_by
erased_at].freeze
IGNORE_ACCESSORS =
%i[type lock_version target_url gl_project_id deploy job_id base_tags
commit_id deployments erased_by_id last_deployment project_id
runner_id tag_taggings taggings tags trigger_request_id
user_id].freeze
shared_examples 'build duplication' do shared_examples 'build duplication' do
let(:build) do let(:build) do
create(:ci_build, :failed, :artifacts_expired, :erased, create(:ci_build, :failed, :artifacts_expired, :erased,
...@@ -18,8 +32,8 @@ describe Ci::RetryBuildService, :services do ...@@ -18,8 +32,8 @@ describe Ci::RetryBuildService, :services do
description: 'some build', pipeline: pipeline) description: 'some build', pipeline: pipeline)
end end
describe 'clone attributes' do describe 'clone accessors' do
described_class::CLONE_ACCESSORS.each do |attribute| CLONE_ACCESSORS.each do |attribute|
it "clones #{attribute} build attribute" do it "clones #{attribute} build attribute" do
expect(new_build.send(attribute)).to be_present expect(new_build.send(attribute)).to be_present
expect(new_build.send(attribute)).to eq build.send(attribute) expect(new_build.send(attribute)).to eq build.send(attribute)
...@@ -27,8 +41,8 @@ describe Ci::RetryBuildService, :services do ...@@ -27,8 +41,8 @@ describe Ci::RetryBuildService, :services do
end end
end end
describe 'reject attributes' do describe 'reject acessors' do
described_class::REJECT_ACCESSORS.each do |attribute| REJECT_ACCESSORS.each do |attribute|
it "does not clone #{attribute} build attribute" do it "does not clone #{attribute} build attribute" do
expect(new_build.send(attribute)).not_to eq build.send(attribute) expect(new_build.send(attribute)).not_to eq build.send(attribute)
end end
...@@ -36,18 +50,15 @@ describe Ci::RetryBuildService, :services do ...@@ -36,18 +50,15 @@ describe Ci::RetryBuildService, :services do
end end
it 'has correct number of known attributes' do it 'has correct number of known attributes' do
known_accessors = known_accessors = CLONE_ACCESSORS + REJECT_ACCESSORS + IGNORE_ACCESSORS
described_class::CLONE_ACCESSORS +
described_class::IGNORE_ACCESSORS +
described_class::REJECT_ACCESSORS
# :tag_list is a special case, this accessor does not exist # :tag_list is a special case, this accessor does not exist
# in reflected associations, comes from `act_as_taggable` and # in reflected associations, comes from `act_as_taggable` and
# we use it to copy tags, instead of reusing tags. # we use it to copy tags, instead of reusing tags.
# #
current_accessors = current_accessors =
build.attribute_names.map.map(&:to_sym) + Ci::Build.attribute_names.map(&:to_sym) +
build._reflections.map { |assoc| assoc.first.to_sym } + Ci::Build.reflect_on_all_associations.map(&:name) +
[:tag_list] [:tag_list]
current_accessors.uniq! current_accessors.uniq!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment