diff options
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | app/models/concerns/objectid_formatter_support.rb | 7 | ||||
| -rw-r--r-- | app/models/referential.rb | 2 | ||||
| -rw-r--r-- | spec/models/referential/referential_oid_format_from_wkbch_spec.rb | 6 | ||||
| -rw-r--r-- | spec/models/referential_spec.rb | 6 |
5 files changed, 11 insertions, 11 deletions
@@ -1,4 +1,3 @@ -# coding: utf-8 source 'https://rubygems.org' # Use https for github diff --git a/app/models/concerns/objectid_formatter_support.rb b/app/models/concerns/objectid_formatter_support.rb index 3ef45334c..edc7704b4 100644 --- a/app/models/concerns/objectid_formatter_support.rb +++ b/app/models/concerns/objectid_formatter_support.rb @@ -1,14 +1,9 @@ module ObjectidFormatterSupport extend ActiveSupport::Concern - def self.legal_formats - %w(netex stif_netex stif_reflex stif_codifligne) - end - - included do extend Enumerize - enumerize :objectid_format, in: ObjectidFormatterSupport.legal_formats + enumerize :objectid_format, in: %w(netex stif_netex stif_reflex stif_codifligne) validates_presence_of :objectid_format def objectid_formatter diff --git a/app/models/referential.rb b/app/models/referential.rb index e8fb2888e..ca20c639f 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -131,7 +131,7 @@ class Referential < ActiveRecord::Base def define_default_attributes self.time_zone ||= Time.zone.name - self.objectid_format ||= workbench.try(:objectid_format) || ObjectidFormatterSupport.legal_formats.first + self.objectid_format ||= workbench.objectid_format if workbench end def switch diff --git a/spec/models/referential/referential_oid_format_from_wkbch_spec.rb b/spec/models/referential/referential_oid_format_from_wkbch_spec.rb index b0d78fcf2..b3ee68be3 100644 --- a/spec/models/referential/referential_oid_format_from_wkbch_spec.rb +++ b/spec/models/referential/referential_oid_format_from_wkbch_spec.rb @@ -1,6 +1,6 @@ RSpec.describe Referential do - let( :legal_formats ){ ObjectidFormatterSupport.legal_formats } + let( :legal_formats ){ described_class.objectid_format.values } describe 'default attributes' do @@ -15,9 +15,9 @@ RSpec.describe Referential do expect( referential.objectid_format ).to eq(workbench.objectid_format) end - xit 'and w/o a workbench will take the default objectid_format' do + it 'and w/o a workbench will take the default objectid_format' do referential.define_default_attributes - expect( referential.objectid_format ).to eq(some_value_to_be_defined) + expect( referential.objectid_format ).to be_nil end end diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index ad9c43010..d0b1d6447 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -12,6 +12,12 @@ describe Referential, :type => :model do it { should belong_to(:workbench) } it { should belong_to(:referential_suite) } + context "validation" do + subject { build_stubbed(:referential) } + + it { should validate_presence_of(:objectid_format) } + end + context ".referential_ids_in_periode" do it 'should retrieve referential id in periode range' do range = ref.metadatas.first.periodes.sample |
