diff options
| author | cedricnjanga | 2017-11-23 17:14:05 +0100 |
|---|---|---|
| committer | cedricnjanga | 2017-11-23 17:14:05 +0100 |
| commit | 0a9b5cd19dc52e00c9516e2a4cf204580d889862 (patch) | |
| tree | 265d7db92bd9d2b560c0856b9c9f2f5b5b8ae81d /spec | |
| parent | cf72b3c73db85b1a5b7c2381c3afddd98290691d (diff) | |
| download | chouette-core-0a9b5cd19dc52e00c9516e2a4cf204580d889862.tar.bz2 | |
Add spec for stif_netex objectid_format
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories/chouette_lines.rb | 5 | ||||
| -rw-r--r-- | spec/factories/chouette_routes.rb | 7 | ||||
| -rw-r--r-- | spec/models/concerns/objectid_support_spec.rb | 88 |
3 files changed, 100 insertions, 0 deletions
diff --git a/spec/factories/chouette_lines.rb b/spec/factories/chouette_lines.rb index f6542bf82..95f760174 100644 --- a/spec/factories/chouette_lines.rb +++ b/spec/factories/chouette_lines.rb @@ -44,6 +44,11 @@ FactoryGirl.define do end + factory :line_with_after_commit do |line| + line.run_callbacks(:commit) + + end + end end diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb index 4986ab70e..4e20059fe 100644 --- a/spec/factories/chouette_routes.rb +++ b/spec/factories/chouette_routes.rb @@ -33,6 +33,13 @@ FactoryGirl.define do end end + factory :route_with_after_commit do + sequence(:objectid) {nil} + after(:create) do |route| + route.run_callbacks(:commit) + end + end + end end diff --git a/spec/models/concerns/objectid_support_spec.rb b/spec/models/concerns/objectid_support_spec.rb new file mode 100644 index 000000000..656e42d8e --- /dev/null +++ b/spec/models/concerns/objectid_support_spec.rb @@ -0,0 +1,88 @@ +RSpec.describe ObjectidSupport do + + context 'when referential has an objectid format of stif_netex' do + let(:route) { create(:route_with_after_commit, objectid: nil) } + + context "#objectid_format" do + it "should be stif_netex" do + expect(route.objectid_format).to eq('stif_netex') + end + + it "should be the same as the referential" do + expect(route.objectid_format).to eq(route.referential.objectid_format) + end + end + + context "#get_objectid" do + let(:objectid) { route.get_objectid } + it "should be valid" do + expect(objectid).to be_valid + end + + it "should have the same local id than the object" do + expect(objectid.local_id).to eq(route.local_id) + end + + it "should be a Chouette::Objectid::StifNetex" do + expect(objectid).to be_kind_of(Chouette::Objectid::StifNetex) + end + + context "#to_s" do + it "should return a string" do + expect(objectid.to_s).to be_kind_of(String) + end + + it "should be the same as the db attribute" do + expect(objectid.to_s).to eq(route.read_attribute(:objectid)) + expect(objectid.to_s).to eq(route.objectid) + end + end + end + end + + # context 'when referential has an objectid format of netex' do + # let(:line) { create(:route_with_after_commit, objectid: nil) } + + # before(:all) do + # binding.pry + # route.referential.objectid_format = 'netex' + # end + + # context "#objectid_format" do + # it "should be netex" do + # expect(route.objectid_format).to eq('netex') + # end + # it "should be the same as the referential" do + # expect(route.objectid_format).to eq(route.referential.objectid_format) + # end + # end + + # context "#get_objectid" do + # let(:objectid) { route.get_objectid } + # it "should be valid" do + # expect(objectid).to be_valid + # end + + # it "should have the same local id than the object" do + # expect(objectid.local_id).to eq(route.local_id) + # end + + # it "should be a Chouette::Objectid::Netex" do + # expect(objectid).to be_kind_of(Chouette::Objectid::Netex) + # end + + # context "#to_s" do + # it "should return a string" do + # expect(objectid.to_s).to be_kind_of(String) + # end + + # it "should be the same as the db attribute" do + # expect(objectid.to_s).to eq(route.read_attribute(:objectid)) + # expect(objectid.to_s).to eq(route.objectid) + # end + # end + # end + # end + + +end
\ No newline at end of file |
