From 746e14eb1c5df9e4d0d2f243c675e8c383f9b59e Mon Sep 17 00:00:00 2001 From: John Mileham Date: Sun, 5 May 2019 17:13:22 -0400 Subject: [PATCH] Jmileham/relax naming validations (#116) * Don't merge feature gate assignments when superseding visitors * Eliminate naming validations now that clients must run headless --- app/models/split.rb | 12 ------------ spec/models/split_spec.rb | 12 ------------ spec/models/split_upsert_spec.rb | 4 ++-- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/app/models/split.rb b/app/models/split.rb index 77aabfe0..f4905b51 100644 --- a/app/models/split.rb +++ b/app/models/split.rb @@ -10,8 +10,6 @@ class Split < ActiveRecord::Base validates :registry, presence: true validate :name_must_be_snake_case - validate :name_must_not_include_new - validate :name_must_not_end_with_test validate :name_must_only_be_prefixed_with_app_name validate :variants_must_be_snake_case validate :registry_weights_must_sum_to_100 @@ -178,16 +176,6 @@ def name_must_be_snake_case errors.add(:name, "must be snake_case: #{name.inspect}") if name_not_underscored? end - def name_must_not_include_new - errors.add(:name, <<-ERROR_MESSAGE) if name_contains_new? - should not contain the ambiguous word 'new'. If expressing timing, refer to absolute time like 'late_2015'. If expressing creation use 'create'. - ERROR_MESSAGE - end - - def name_must_not_end_with_test - errors.add(:name, "should not end with 'test', as it is redundant. All splits are testable.") if name_ends_with_test? - end - def name_must_only_be_prefixed_with_app_name return if name.nil? || !name_changed? diff --git a/spec/models/split_spec.rb b/spec/models/split_spec.rb index dd2fccfb..19dae867 100644 --- a/spec/models/split_spec.rb +++ b/spec/models/split_spec.rb @@ -38,18 +38,6 @@ expect(subject.errors[:name].first).to include("snake_case") end - it "rejects new" do - subject.name = 'my_new_foo' - expect(subject).not_to be_valid - expect(subject.errors[:name].first).to include("absolute time") - end - - it "rejects ending in test" do - subject.name = 'my_foo_test' - expect(subject).not_to be_valid - expect(subject.errors[:name].first).to include("redundant") - end - it "rejects prefixed with other-than-app-name" do subject.name = 'bla.baz' expect(subject).not_to be_valid diff --git a/spec/models/split_upsert_spec.rb b/spec/models/split_upsert_spec.rb index fb91970f..30c21bae 100644 --- a/spec/models/split_upsert_spec.rb +++ b/spec/models/split_upsert_spec.rb @@ -55,9 +55,9 @@ end it 'delegates validation errors to split' do - split_upsert = described_class.new(app: default_app, name: "bad_test", weighting_registry: { badBadBad: 100 }) + split_upsert = described_class.new(app: default_app, name: "bump.bad_extremely_bad", weighting_registry: { badBadBad: 100 }) expect(split_upsert.save).to eq false - expect(split_upsert.errors[:name].first).to include("redundant") + expect(split_upsert.errors[:name].first).to include("prefixed") expect(split_upsert.errors[:weighting_registry].first).to include("snake_case") end