aboutsummaryrefslogtreecommitdiffstats
path: root/spec/requests/api
diff options
context:
space:
mode:
authorTeddy Wing2017-08-25 18:13:55 +0200
committerTeddy Wing2017-08-25 18:13:55 +0200
commita8a04ac132a11cf33df90a7f82c9e53880bc164f (patch)
treed75ead8409f65d0b078a6b47426efc6617ece585 /spec/requests/api
parent9e4616f8dd82545aa2101aee96ca08615343c28e (diff)
downloadchouette-core-a8a04ac132a11cf33df90a7f82c9e53880bc164f.tar.bz2
NetexImportsController spec: Fix failing tests caused by Kludge
The `ReferentialMetadataKludge` expects a couple of `Chouette::Line`s to already exist in the database in order to successfully create a `ReferentialMetadata` record. In tests, this is not the case. As a kludge to the kludge, create the expected line records in the tests that fail because of it, with the proviso that these additions should be removed or changed once we have real `ReferentialMetadata` handling for imports.
Diffstat (limited to 'spec/requests/api')
-rw-r--r--spec/requests/api/v1/netex_import_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb
index 8f6eb8523..fae8b0adc 100644
--- a/spec/requests/api/v1/netex_import_spec.rb
+++ b/spec/requests/api/v1/netex_import_spec.rb
@@ -30,6 +30,10 @@ 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')
+
post_request.(netex_import: legal_attributes)
expect( response ).to be_success
expect( json_response_body ).to eq(
@@ -40,6 +44,10 @@ 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')
+
expect{ post_request.(netex_import: legal_attributes) }.to change{NetexImport.count}.by(1)
end
@@ -72,6 +80,10 @@ RSpec.describe "NetexImport", type: :request do
context "missing #{bad_attribute}" do
let!( :illegal_attributes ){ legal_attributes.merge( bad_attribute => illegal_value ) }
it 'does not succeed' do
+ # TODO: Handle better when `ReferentialMetadataKludge` is reworked
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108')
+ create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109')
+
post_request.(netex_import: illegal_attributes)
expect( response.status ).to eq(406)
expect( json_response_body['errors'][bad_attribute.to_s] ).not_to be_empty