diff options
| author | Alban Peignier | 2018-02-22 10:56:39 +0100 |
|---|---|---|
| committer | Alban Peignier | 2018-02-22 10:56:39 +0100 |
| commit | 8aab474b8ad555b4d5f8e28c0af2f6c72741e317 (patch) | |
| tree | 99f34fccc7f5705a7df3bc9b7192774546446643 /spec/models | |
| parent | 04f26371e23a116cc7be22bd694010820d469e0c (diff) | |
| download | chouette-core-8aab474b8ad555b4d5f8e28c0af2f6c72741e317.tar.bz2 | |
Keep original slug format (with _). Avoid full numeric slug. Refs #56095609_slug_format
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/referential_spec.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index d07b57f13..2d4649b87 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -10,20 +10,21 @@ describe Referential, :type => :model do it { should validate_presence_of(:objectid_format) } - it "shoul assign slug with a good format" do - - names = %w( - 2018-Hiver-Jezequel-MM-Lyon-Nice - 2018-Hiver-Jezequel-23293MM-Lyon-Nice - -Hiver-Jezequel-MM-Lyon-Nice - Hiver-Jezequel-MM-Lyon-Nice - 20179282 - ) - - names.each do |name| + it "assign slug with a good format" do + time_reference = double(now: 1234567890) + + conditions = { + "2018-Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezequel_mm_lyon_nice_1234567890", + "2018-Hiver-Jezequel-23293MM-Lyon-Nice": "hiver_jezequel_mm_lyon_nice_1234567890", + "-Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezequel_mm_lyon_nice_1234567890", + "Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezequel_mm_lyon_nice_1234567890", + "20179282": "referential_1234567890" + } + + conditions.each do |name, expected_slug| ref = Referential.new name: name - ref.assign_slug - expect(ref.slug).to match(/([a-z][a-z-]+_\d{10}|\d{10})/) + ref.assign_slug time_reference + expect(ref.slug).to eq(expected_slug) end end end @@ -77,7 +78,7 @@ describe Referential, :type => :model do { "organisation_id" => first_organisation.id, "name"=>"Test", - "slug"=>"test_#{Time.now.to_i}", + "slug"=>"test", "prefix"=>"test", "time_zone"=>"American Samoa", "upper_corner"=>"51.1,8.23", |
