aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/single_reference_import.zipbin220 -> 5446 bytes
-rw-r--r--spec/lib/stif/netex_file_spec.rb27
-rw-r--r--spec/requests/api/v1/netex_import_spec.rb14
3 files changed, 33 insertions, 8 deletions
diff --git a/spec/fixtures/single_reference_import.zip b/spec/fixtures/single_reference_import.zip
index 4aee23614..37a516f69 100644
--- a/spec/fixtures/single_reference_import.zip
+++ b/spec/fixtures/single_reference_import.zip
Binary files differ
diff --git a/spec/lib/stif/netex_file_spec.rb b/spec/lib/stif/netex_file_spec.rb
new file mode 100644
index 000000000..d84807fe5
--- /dev/null
+++ b/spec/lib/stif/netex_file_spec.rb
@@ -0,0 +1,27 @@
+require "rails_helper"
+
+RSpec.describe STIF::NetexFile do
+
+ let( :zip_file ){ fixtures_path 'OFFRE_TRANSDEV_2017030112251.zip' }
+
+ let(:frames) { STIF::NetexFile.new(zip_file).frames }
+
+ it "should return a frame for each sub directory" do
+ expect(frames.size).to eq(2)
+ end
+
+ def period(from, to)
+ Range.new(Date.parse(from), Date.parse(to))
+ end
+
+
+ context "each frame" do
+ it "should return the line identifiers defined in frame" do
+ expect(frames.map(&:line_refs)).to eq([%w{C00109 C00108}]*2)
+ end
+ it "should return periods defined in frame calendars" do
+ expect(frames.map(&:periods)).to eq([[period("2017-04-01", "2017-12-31")], [period("2017-03-01","2017-03-31")]])
+ end
+ end
+
+end
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb
index 70a41256e..06ff76e14 100644
--- a/spec/requests/api/v1/netex_import_spec.rb
+++ b/spec/requests/api/v1/netex_import_spec.rb
@@ -32,9 +32,8 @@ RSpec.describe "NetexImport", type: :request do
let( :authorization ){ authorization_token_header( get_api_key.token ) }
it 'succeeds' do
- # TODO: Handle better when `ReferentialMetadataKludge` is reworked
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108')
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109')
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
post_request.(netex_import: legal_attributes)
expect( response ).to be_success
@@ -46,16 +45,15 @@ RSpec.describe "NetexImport", type: :request do
end
it 'creates a NetexImport object in the DB' do
- # TODO: Handle better when `ReferentialMetadataKludge` is reworked
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108')
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109')
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
expect{ post_request.(netex_import: legal_attributes) }.to change{NetexImport.count}.by(1)
end
it 'creates a correct Referential' do
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108')
- create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109')
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108', line_referential: workbench.line_referential)
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109', line_referential: workbench.line_referential)
legal_attributes # force object creation for correct to change behavior
expect{post_request.(netex_import: legal_attributes)}.to change{Referential.count}.by(1)