aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/referentials.rb2
-rw-r--r--spec/models/referential_spec.rb19
-rw-r--r--spec/support/referential.rb4
3 files changed, 21 insertions, 4 deletions
diff --git a/spec/factories/referentials.rb b/spec/factories/referentials.rb
index 0276a47be..a9f1f972a 100644
--- a/spec/factories/referentials.rb
+++ b/spec/factories/referentials.rb
@@ -1,7 +1,7 @@
FactoryGirl.define do
factory :referential do
sequence(:name) { |n| "Test #{n}" }
- sequence(:slug) { |n| "test_#{n}" }
+ sequence(:slug) { |n| "test-#{n}_#{Time.now.to_i}" }
sequence(:prefix) { |n| "test_#{n}" }
association :line_referential
association :stop_area_referential
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index 6d699f759..d07b57f13 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -9,6 +9,23 @@ describe Referential, :type => :model do
subject { build_stubbed(:referential) }
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|
+ ref = Referential.new name: name
+ ref.assign_slug
+ expect(ref.slug).to match(/([a-z][a-z-]+_\d{10}|\d{10})/)
+ end
+ end
end
context ".referential_ids_in_periode" do
@@ -60,7 +77,7 @@ describe Referential, :type => :model do
{
"organisation_id" => first_organisation.id,
"name"=>"Test",
- "slug"=>"test",
+ "slug"=>"test_#{Time.now.to_i}",
"prefix"=>"test",
"time_zone"=>"American Samoa",
"upper_corner"=>"51.1,8.23",
diff --git a/spec/support/referential.rb b/spec/support/referential.rb
index 9acdce73a..19590191a 100644
--- a/spec/support/referential.rb
+++ b/spec/support/referential.rb
@@ -1,7 +1,7 @@
module ReferentialHelper
def first_referential
- Referential.find_by!(:slug => "first")
+ Referential.find_by!(:name => "first")
end
def first_organisation
@@ -64,7 +64,7 @@ RSpec.configure do |config|
:referential,
prefix: "first",
name: "first",
- slug: "first",
+ slug: "first_#{Time.now.to_i}",
organisation: organisation,
workbench: workbench,
objectid_format: "stif_netex"