aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinhui Xu2017-07-25 12:30:07 +0200
committerGitHub2017-07-25 12:30:07 +0200
commitadeb7109bb4ea64c8c10233cd61a63b154384f43 (patch)
treeba85ae3019e651d3833e288e19971d40bfd06d8a
parent3fd2c1d4456b88ad9cf55a950be65ddce0d70349 (diff)
downloadchouette-core-adeb7109bb4ea64c8c10233cd61a63b154384f43.tar.bz2
Revert "StifCodifligneAttributesSupport for Line objectid"
-rw-r--r--app/models/chouette/line.rb2
-rw-r--r--app/models/chouette/stif_codifligne_objectid.rb18
-rw-r--r--app/models/concerns/stif_codifligne_attributes_support.rb11
-rw-r--r--spec/models/chouette/line_spec.rb11
4 files changed, 9 insertions, 33 deletions
diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb
index 63d2d1606..33a2fbb00 100644
--- a/app/models/chouette/line.rb
+++ b/app/models/chouette/line.rb
@@ -1,5 +1,5 @@
class Chouette::Line < Chouette::ActiveRecord
- include StifCodifligneAttributesSupport
+ include DefaultNetexAttributesSupport
include LineRestrictions
include LineReferentialSupport
include StifTransportModeEnumerations
diff --git a/app/models/chouette/stif_codifligne_objectid.rb b/app/models/chouette/stif_codifligne_objectid.rb
deleted file mode 100644
index 46109e24f..000000000
--- a/app/models/chouette/stif_codifligne_objectid.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class Chouette::StifCodifligneObjectid < String
-
- @@format = /^([A-Za-z_]+):([A-Za-z]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/
- cattr_reader :format
-
- def parts
- match(format).try(:captures)
- end
-
- def object_type
- parts.try(:third)
- end
-
- def local_id
- parts.try(:fourth)
- end
-
-end
diff --git a/app/models/concerns/stif_codifligne_attributes_support.rb b/app/models/concerns/stif_codifligne_attributes_support.rb
deleted file mode 100644
index 4d18b89e0..000000000
--- a/app/models/concerns/stif_codifligne_attributes_support.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-module StifCodifligneAttributesSupport
- extend ActiveSupport::Concern
-
- included do
- validates_presence_of :objectid
- end
-
- def objectid
- Chouette::StifCodifligneObjectid.new read_attribute(:objectid)
- end
-end
diff --git a/spec/models/chouette/line_spec.rb b/spec/models/chouette/line_spec.rb
index 2e5882012..5a339e7ed 100644
--- a/spec/models/chouette/line_spec.rb
+++ b/spec/models/chouette/line_spec.rb
@@ -1,12 +1,17 @@
require 'spec_helper'
describe Chouette::Line, :type => :model do
+
subject { create(:line) }
+ it { is_expected.to belong_to(:line_referential) }
- it { should belong_to(:line_referential) }
# it { is_expected.to validate_presence_of :network }
# it { is_expected.to validate_presence_of :company }
- it { should validate_presence_of :name }
+
+ it { is_expected.to validate_presence_of :name }
+
+ # it { should validate_presence_of :objectid }
+ it { is_expected.to validate_uniqueness_of :objectid }
describe '#display_name' do
it 'should display local_id, number, name and company name' do
@@ -17,7 +22,7 @@ describe Chouette::Line, :type => :model do
describe '#objectid' do
subject { super().objectid }
- it { is_expected.to be_kind_of(Chouette::StifCodifligneObjectid) }
+ it { is_expected.to be_kind_of(Chouette::NetexObjectId) }
end
# it { should validate_numericality_of :objectversion }