summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-11 12:01:35 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-11 12:05:04 +0200
commit1d087e073660130c81bf0917a6fa395886b6e2dc (patch)
treeb51ee85871f41c33804d3770e53047cd8d86315c
parent6e9924a2245004c6b6adb34028880a46fd5471df (diff)
downloadgitlab-ce-1d087e073660130c81bf0917a6fa395886b6e2dc.tar.gz
Freeze mutable constants in stages migration code
-rw-r--r--app/models/concerns/has_status.rb2
-rw-r--r--lib/gitlab/background_migration/migrate_stage_status.rb2
-rw-r--r--spec/migrations/migrate_stages_statuses_spec.rb5
-rw-r--r--spec/models/commit_status_spec.rb1
4 files changed, 4 insertions, 6 deletions
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index 8ea5a007f76..a94226bb735 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -9,7 +9,7 @@ module HasStatus
COMPLETED_STATUSES = %w[success failed canceled skipped].freeze
ORDERED_STATUSES = %w[failed pending running manual canceled success skipped created].freeze
STATUSES_ENUM = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7 }
+ failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze
class_methods do
def enumerated_status!
diff --git a/lib/gitlab/background_migration/migrate_stage_status.rb b/lib/gitlab/background_migration/migrate_stage_status.rb
index 3c9744d1607..b1ff0900709 100644
--- a/lib/gitlab/background_migration/migrate_stage_status.rb
+++ b/lib/gitlab/background_migration/migrate_stage_status.rb
@@ -2,7 +2,7 @@ module Gitlab
module BackgroundMigration
class MigrateStageStatus
STATUSES = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7 }
+ failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze
class Build < ActiveRecord::Base
self.table_name = 'ci_builds'
diff --git a/spec/migrations/migrate_stages_statuses_spec.rb b/spec/migrations/migrate_stages_statuses_spec.rb
index 1769b1e256b..7a424bdaedb 100644
--- a/spec/migrations/migrate_stages_statuses_spec.rb
+++ b/spec/migrations/migrate_stages_statuses_spec.rb
@@ -8,7 +8,7 @@ describe MigrateStagesStatuses, :migration do
let(:projects) { table(:projects) }
STATUSES = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7 }
+ failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze
before do
stub_const("#{described_class.name}::BATCH_SIZE", 2)
@@ -59,9 +59,8 @@ describe MigrateStagesStatuses, :migration do
end
end
-
def create_job(project:, pipeline:, stage:, status:, **opts)
- stages = { test: 1, build: 2, deploy: 3}
+ stages = { test: 1, build: 2, deploy: 3 }
jobs.create!(project_id: project, commit_id: pipeline,
stage_idx: stages[stage.to_sym], stage: stage,
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index c0cbf0b2f95..c7651ce9b46 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -419,7 +419,6 @@ describe CommitStatus, :models do
end
end
-
describe '#locking_enabled?' do
before do
commit_status.lock_version = 100