diff options
Diffstat (limited to 'spec/requests')
| -rw-r--r-- | spec/requests/api/v1/netex_import_spec.rb | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb index 3246cd00f..70a41256e 100644 --- a/spec/requests/api/v1/netex_import_spec.rb +++ b/spec/requests/api/v1/netex_import_spec.rb @@ -4,7 +4,7 @@ RSpec.describe "NetexImport", type: :request do let( :referential ){ create :referential } let( :workbench ){ referential.workbench } - + let( :workbench_import ){ create :workbench_import } let( :file_path ){ fixtures_path 'single_reference_import.zip' } let( :file ){ fixture_file_upload( file_path ) } @@ -21,7 +21,9 @@ RSpec.describe "NetexImport", type: :request do { name: 'offre1', file: file, - workbench_id: workbench.id + workbench_id: workbench.id, + parent_id: workbench_import.id, + parent_type: workbench_import.class.name } end @@ -52,6 +54,9 @@ RSpec.describe "NetexImport", type: :request do end it 'creates a correct Referential' do + create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00108') + create(:line, objectid: 'STIF:CODIFLIGNE:Line:C00109') + legal_attributes # force object creation for correct to change behavior expect{post_request.(netex_import: legal_attributes)}.to change{Referential.count}.by(1) Referential.last.tap do | ref | @@ -76,7 +81,7 @@ RSpec.describe "NetexImport", type: :request do context 'with correct credentials and incorrect request' do let( :authorization ){ authorization_token_header( get_api_key.token ) } - shared_examples_for 'illegal attributes' do |bad_attribute, illegal_value=nil, referential_count: 0| + shared_examples_for 'illegal attributes' do |bad_attribute, illegal_value=nil| context "missing #{bad_attribute}" do let!( :illegal_attributes ){ legal_attributes.merge( bad_attribute => illegal_value ) } it 'does not succeed' do @@ -93,20 +98,22 @@ RSpec.describe "NetexImport", type: :request do expect{ post_request.(netex_import: illegal_attributes) }.not_to change{Import.count} end - it 'might create a referential' do - expect{ post_request.(netex_import: illegal_attributes) }.to change{Referential.count}.by(referential_count) + it 'might not create a referential' do + expect{ post_request.(netex_import: illegal_attributes) }.not_to change{Referential.count} end end end - it_behaves_like 'illegal attributes', :file, referential_count: 1 + it_behaves_like 'illegal attributes', :file it_behaves_like 'illegal attributes', :workbench_id - context 'name already taken' do - before do - create :referential, name: 'already taken' - end - it_behaves_like 'illegal attributes', :name, 'already taken' - end + + # TODO Create a specific test when referential is not created + # context 'name already taken' do + # before do + # create :referential, name: 'already taken' + # end + # it_behaves_like 'illegal attributes', name: 'already taken' + # end end end end |
