Skip to content

Commit

Permalink
Jmileham/relax naming validations (#116)
Browse files Browse the repository at this point in the history
* Don't merge feature gate assignments when superseding visitors

* Eliminate naming validations now that clients must run headless
  • Loading branch information
jmileham committed May 5, 2019
1 parent e861ec7 commit 746e14e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
12 changes: 0 additions & 12 deletions app/models/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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?

Expand Down
12 changes: 0 additions & 12 deletions spec/models/split_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/split_upsert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 746e14e

Please sign in to comment.