aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui2018-01-16 15:02:13 +0100
committerXinhui2018-01-16 15:02:13 +0100
commit1ccde4934474a67d31261e3abbe5eacdbc04d834 (patch)
tree7d3cbbb9f3a5c6d6918191968effcd0ec960aa38
parentb1c55750bb43736c2cb6f9619bddc453cfadb1aa (diff)
downloadchouette-core-5609_referential_slug.tar.bz2
Edit referential slug validation format5609_referential_slug
Refs #5609
-rw-r--r--app/models/referential.rb2
-rw-r--r--spec/models/referential_spec.rb10
2 files changed, 11 insertions, 1 deletions
diff --git a/app/models/referential.rb b/app/models/referential.rb
index 92931564d..c820ad9e5 100644
--- a/app/models/referential.rb
+++ b/app/models/referential.rb
@@ -13,7 +13,7 @@ class Referential < ActiveRecord::Base
validates_uniqueness_of :slug
- validates_format_of :slug, with: %r{\A[a-z][0-9a-z_]+\Z}
+ validates_format_of :slug, with: %r{\A[a-z0-9a-zÀ-ÿ_-]+\Z}
validates_format_of :prefix, with: %r{\A[0-9a-zA-Z_]+\Z}
validates_format_of :upper_corner, with: %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z}
validates_format_of :lower_corner, with: %r{\A-?[0-9]+\.?[0-9]*\,-?[0-9]+\.?[0-9]*\Z}
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 6d699f759..5758d8235 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -9,6 +9,16 @@ describe Referential, :type => :model do
subject { build_stubbed(:referential) }
it { should validate_presence_of(:objectid_format) }
+
+ it 'should authorize slug with nummerical value' do
+ subject.slug = '2018-hiver-jezequel-mm-lyon-nice'
+ expect(subject).to be_valid
+ end
+
+ it 'should authorize slug with accents' do
+ subject.slug = 'écolê-été-hiver-lyon-nice'
+ expect(subject).to be_valid
+ end
end
context ".referential_ids_in_periode" do