BigW Consortium Gitlab

Commit 910a7d02 by Shinya Maeda

Remove numericality as it's redandant with integer column and validates nil IID

parent 9ccfcf55
......@@ -27,7 +27,7 @@ module AtomicInternalId
module ClassMethods
def has_internal_id(column, scope:, init:, presence: true) # rubocop:disable Naming/PredicateName
before_validation :"ensure_#{scope}_#{column}!", on: :create
validates column, presence: presence, numericality: true
validates column, presence: presence
define_method("ensure_#{scope}_#{column}!") do
scope_value = association(scope).reader
......
......@@ -228,6 +228,7 @@ Ci::Pipeline:
- config_source
- failure_reason
- protected
- iid
Ci::Stage:
- id
- name
......
......@@ -1517,6 +1517,7 @@ describe Ci::Build do
{ key: 'CI_PROJECT_URL', value: project.web_url, public: true },
{ key: 'CI_PROJECT_VISIBILITY', value: 'private', public: true },
{ key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true },
{ key: 'CI_PIPELINE_IID', value: pipeline.iid.to_s, public: true },
{ key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, public: true },
{ key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true },
{ key: 'CI_COMMIT_MESSAGE', value: pipeline.git_commit_message, public: true },
......
......@@ -12,14 +12,13 @@ shared_examples_for 'AtomicInternalId' do
describe 'Validation' do
before do
allow_any_instance_of(described_class).to receive(:ensure_iid!) {}
allow_any_instance_of(described_class).to receive(:"ensure_#{scope_attrs.keys.first}_#{internal_id_attribute}!") {}
end
it 'validates presence' do
instance.valid?
expect(instance.errors[:iid]).to include("can't be blank") if validate_presence
expect(instance.errors[:iid]).to include("is not a number") # numericality
end
end
......
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