diff options
| -rw-r--r-- | app/models/referential.rb | 3 | ||||
| -rw-r--r-- | spec/models/referential_spec.rb | 8 | 
2 files changed, 5 insertions, 6 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 78b719fab..0522d72c0 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -242,7 +242,6 @@ class Referential < ApplicationModel    def self.new_from(from, organisation)      Referential.new(        name: I18n.t("activerecord.copy", name: from.name), -      slug: "#{from.slug}_clone",        prefix: from.prefix,        time_zone: from.time_zone,        bounds: from.bounds, @@ -434,7 +433,7 @@ class Referential < ApplicationModel    def assign_slug(time_reference = Time)      self.slug ||= begin -      prefix = name.parameterize.gsub('-','_').gsub(/[^a-zA-Z_]/,'').gsub(/^_/,'') +      prefix = name.parameterize.gsub('-','_').gsub(/[^a-zA-Z_]/,'').gsub(/^_/,'')[0..12]        prefix = "referential" if prefix.blank?        "#{prefix}_#{time_reference.now.to_i}"      end if name diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index ca2caf57f..5dfab5348 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -14,10 +14,10 @@ describe Referential, :type => :model 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", +        "2018-Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezeque_1234567890", +        "2018-Hiver-Jezequel-23293MM-Lyon-Nice": "hiver_jezeque_1234567890", +        "-Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezeque_1234567890", +        "Hiver-Jezequel-MM-Lyon-Nice": "hiver_jezeque_1234567890",          "20179282": "referential_1234567890"        } | 
