Commit c3d24d0b authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move unused consts from retry build service to specs

parent 6f843457
......@@ -3,19 +3,7 @@ module Ci
CLONE_ACCESSORS = %i[pipeline project ref tag options commands name
allow_failure stage stage_idx trigger_request
yaml_variables when environment coverage_regex
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
description tag_list].freeze
def execute(build)
reprocess(build).tap do |new_build|
......
......@@ -10,6 +10,20 @@ describe Ci::RetryBuildService, :services do
described_class.new(project, user)
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
let(:build) do
create(:ci_build, :failed, :artifacts_expired, :erased,
......@@ -18,8 +32,8 @@ describe Ci::RetryBuildService, :services do
description: 'some build', pipeline: pipeline)
end
describe 'clone attributes' do
described_class::CLONE_ACCESSORS.each do |attribute|
describe 'clone accessors' do
CLONE_ACCESSORS.each do |attribute|
it "clones #{attribute} build attribute" do
expect(new_build.send(attribute)).to be_present
expect(new_build.send(attribute)).to eq build.send(attribute)
......@@ -27,8 +41,8 @@ describe Ci::RetryBuildService, :services do
end
end
describe 'reject attributes' do
described_class::REJECT_ACCESSORS.each do |attribute|
describe 'reject acessors' do
REJECT_ACCESSORS.each do |attribute|
it "does not clone #{attribute} build attribute" do
expect(new_build.send(attribute)).not_to eq build.send(attribute)
end
......@@ -36,18 +50,15 @@ describe Ci::RetryBuildService, :services do
end
it 'has correct number of known attributes' do
known_accessors =
described_class::CLONE_ACCESSORS +
described_class::IGNORE_ACCESSORS +
described_class::REJECT_ACCESSORS
known_accessors = CLONE_ACCESSORS + REJECT_ACCESSORS + IGNORE_ACCESSORS
# :tag_list is a special case, this accessor does not exist
# in reflected associations, comes from `act_as_taggable` and
# we use it to copy tags, instead of reusing tags.
#
current_accessors =
build.attribute_names.map.map(&:to_sym) +
build._reflections.map { |assoc| assoc.first.to_sym } +
Ci::Build.attribute_names.map(&:to_sym) +
Ci::Build.reflect_on_all_associations.map(&:name) +
[:tag_list]
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