diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 29ed632e749da7939f64a2952bd10d89867c2aeb..664facb7b2827946c76558712220d358a86af720 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -626,7 +626,7 @@ def triggered_pipelines_with_preloads def valid_commit_sha if Gitlab::Git.blank_ref?(self.sha) - self.errors.add(:sha, " cant be 00000000 (branch removal)") + self.errors.add(:sha, "can't be 00000000 (branch removal)") end end diff --git a/app/validators/cluster_name_validator.rb b/app/validators/cluster_name_validator.rb index 527116ba69b92af7970815c092463e30a4b77b1c..56d3904ba2df7cbb9d673b225f9c16725f5661b4 100644 --- a/app/validators/cluster_name_validator.rb +++ b/app/validators/cluster_name_validator.rb @@ -6,14 +6,14 @@ class ClusterNameValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if record.provided_by_user? - record.errors.add(attribute, " has to be present") unless value.present? + record.errors.add(attribute, 'has to be present') unless value.present? else if record.persisted? && record.name_changed? - record.errors.add(attribute, " can not be changed because it's synchronized with provider") + record.errors.add(attribute, "can not be changed because it's synchronized with provider") end unless value.length >= 1 && value.length <= 63 - record.errors.add(attribute, " is invalid syntax") + record.errors.add(attribute, 'syntax is invalid') end unless Gitlab::Regex.kubernetes_namespace_regex.match(value) diff --git a/app/validators/cron_freeze_period_timezone_validator.rb b/app/validators/cron_freeze_period_timezone_validator.rb index 143a02621363f3c580964b179dc7056c49f2c0ea..2381811dc6fcfa93592a096f2266f78445237396 100644 --- a/app/validators/cron_freeze_period_timezone_validator.rb +++ b/app/validators/cron_freeze_period_timezone_validator.rb @@ -8,6 +8,6 @@ def validate_each(record, attribute, value) freeze_start_parser = Gitlab::Ci::CronParser.new(record.freeze_start, record.cron_timezone) freeze_end_parser = Gitlab::Ci::CronParser.new(record.freeze_end, record.cron_timezone) - record.errors.add(attribute, " is invalid syntax") unless freeze_start_parser.cron_timezone_valid? && freeze_end_parser.cron_timezone_valid? + record.errors.add(attribute, 'syntax is invalid') unless freeze_start_parser.cron_timezone_valid? && freeze_end_parser.cron_timezone_valid? end end diff --git a/app/validators/cron_timezone_validator.rb b/app/validators/cron_timezone_validator.rb index c5f51d6506071650aaad06b18550a668e496191f..d52271b072b3445aa178ced2ee5c28d39db35bae 100644 --- a/app/validators/cron_timezone_validator.rb +++ b/app/validators/cron_timezone_validator.rb @@ -6,6 +6,6 @@ class CronTimezoneValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) cron_parser = Gitlab::Ci::CronParser.new(record.cron, record.cron_timezone) - record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_timezone_valid? + record.errors.add(attribute, 'syntax is invalid') unless cron_parser.cron_timezone_valid? end end diff --git a/app/validators/cron_validator.rb b/app/validators/cron_validator.rb index c12b29410d4ff32fb80dc85a3ede995bf87297e0..59c40ba67fe94a7ce0cf644a85e4d4fb7912a774 100644 --- a/app/validators/cron_validator.rb +++ b/app/validators/cron_validator.rb @@ -8,7 +8,7 @@ class CronValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if ATTRIBUTE_ALLOWLIST.include?(attribute) cron_parser = Gitlab::Ci::CronParser.new(record.public_send(attribute), record.cron_timezone) # rubocop:disable GitlabSecurity/PublicSend - record.errors.add(attribute, " is invalid syntax") unless cron_parser.cron_valid? + record.errors.add(attribute, 'syntax is invalid') unless cron_parser.cron_valid? else raise NonAllowlistedAttributeError, "Non-allowlisted attribute" end diff --git a/spec/requests/api/freeze_periods_spec.rb b/spec/requests/api/freeze_periods_spec.rb index b582c2e0f4edb8e9dfa95a2c444c7a2d0ff5e9b4..580bedde30cfa518cc5230a9eca17d6185e79f93 100644 --- a/spec/requests/api/freeze_periods_spec.rb +++ b/spec/requests/api/freeze_periods_spec.rb @@ -283,7 +283,7 @@ subject expect(response).to have_gitlab_http_status(:bad_request) - expect(json_response['message']['freeze_end']).to eq([" is invalid syntax"]) + expect(json_response['message']['freeze_end']).to eq(['syntax is invalid']) end end end @@ -385,7 +385,7 @@ subject expect(response).to have_gitlab_http_status(:bad_request) - expect(json_response['message']['freeze_start']).to eq([" is invalid syntax"]) + expect(json_response['message']['freeze_start']).to eq(['syntax is invalid']) end end end diff --git a/spec/requests/api/graphql/mutations/ci/pipeline_schedule/create_spec.rb b/spec/requests/api/graphql/mutations/ci/pipeline_schedule/create_spec.rb index df56d1fbc4400614f592635dcac9b7d7e2251269..7108e05a20342958c6d2e4f3e39d7a918de3ffa0 100644 --- a/spec/requests/api/graphql/mutations/ci/pipeline_schedule/create_spec.rb +++ b/spec/requests/api/graphql/mutations/ci/pipeline_schedule/create_spec.rb @@ -108,8 +108,8 @@ expect(mutation_response['errors']) .to match_array( [ - "Cron is invalid syntax", - "Cron timezone is invalid syntax", + "Cron syntax is invalid", + "Cron timezone syntax is invalid", "Ref is ambiguous" ] ) diff --git a/spec/requests/api/graphql/mutations/ci/pipeline_schedule/update_spec.rb b/spec/requests/api/graphql/mutations/ci/pipeline_schedule/update_spec.rb index aeb03d91d97b5f11ad360c9a8a12265846f46689..21485e7928e6444fcb7895222f58fcb0c7509ebd 100644 --- a/spec/requests/api/graphql/mutations/ci/pipeline_schedule/update_spec.rb +++ b/spec/requests/api/graphql/mutations/ci/pipeline_schedule/update_spec.rb @@ -157,8 +157,8 @@ expect(mutation_response['errors']) .to match_array( [ - "Cron is invalid syntax", - "Cron timezone is invalid syntax", + "Cron syntax is invalid", + "Cron timezone syntax is invalid", "Ref can't be blank", "Description can't be blank", "Ref is ambiguous" @@ -175,8 +175,8 @@ expect(mutation_response['errors']) .to match_array( [ - "Cron is invalid syntax", - "Cron timezone is invalid syntax", + "Cron syntax is invalid", + "Cron timezone syntax is invalid", "Ref can't be blank", "Description can't be blank" ]