diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-02 13:51:24 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-02 20:11:12 +0300 |
commit | c3d24d0bdd2559715231eca1cd08986277cb8fc6 (patch) | |
tree | 5d3ad770dfbf5d54788d6e2a2f7b81c2fec3382d /spec | |
parent | 6f84345725ef11493653a888ed59fc6411825779 (diff) |
Move unused consts from retry build service to specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/ci/retry_build_service_spec.rb | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb index bcd89544647..65af4e13118 100644 --- a/spec/services/ci/retry_build_service_spec.rb +++ b/spec/services/ci/retry_build_service_spec.rb @@ -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! |