diff options
| author | Robert | 2017-07-20 11:45:30 +0200 |
|---|---|---|
| committer | Robert | 2017-07-20 11:45:30 +0200 |
| commit | 327c27559a955782b70dff46aeca1c58dcf95836 (patch) | |
| tree | d3a975cbfc87846bc1109eb44ed986b1340ccd53 | |
| parent | 2de0d63c148218c983a30117ee277ef9307906c8 (diff) | |
| download | chouette-core-327c27559a955782b70dff46aeca1c58dcf95836.tar.bz2 | |
Fixes: #3506@0.5h
* CR refacts (netex_import req spec)
* Dead Code Elimination (mount in Import subclasses)
| -rw-r--r-- | app/models/netex_import.rb | 1 | ||||
| -rw-r--r-- | spec/requests/api/v1/netex_import_spec.rb | 28 |
2 files changed, 14 insertions, 15 deletions
diff --git a/app/models/netex_import.rb b/app/models/netex_import.rb index 4a1c6f1e5..0cf4d0a7c 100644 --- a/app/models/netex_import.rb +++ b/app/models/netex_import.rb @@ -1,6 +1,5 @@ require 'net/http' class NetexImport < Import - mount_uploader :file, ImportUploader after_commit :launch_java_import def launch_java_import diff --git a/spec/requests/api/v1/netex_import_spec.rb b/spec/requests/api/v1/netex_import_spec.rb index de281aa66..9fbf8f801 100644 --- a/spec/requests/api/v1/netex_import_spec.rb +++ b/spec/requests/api/v1/netex_import_spec.rb @@ -15,30 +15,30 @@ RSpec.describe "NetexImport", type: :request do end end - let( :legal_attributes ){ { - netex_import: { + let( :legal_attributes ) do + { name: 'hello world', file: file, - referential_id: referential.id} - } } + referential_id: referential.id + } + end - let( :illegal_attributes ){ { - netex_import: { - referential_id: referential.id} - } } + let( :illegal_attributes ) do + { referential_id: referential.id } + end context 'with correct credentials and correct request' do let( :authorization ){ authorization_token_header( get_api_key.token ) } it 'succeeds' do - post_request.(legal_attributes) + post_request.(netex_import: legal_attributes) expect( response ).to be_success expect( json_response_body ).to eq({'id' => NetexImport.last.id, 'type' => 'NetexImport'}) end it 'creates a NetexImport object in the DB' do - expect{ post_request.(legal_attributes) }.to change{NetexImport.count}.by(1) + expect{ post_request.(netex_import: legal_attributes) }.to change{NetexImport.count}.by(1) end end @@ -46,12 +46,12 @@ RSpec.describe "NetexImport", type: :request do let( :authorization ){ authorization_token_header( "#{referential.id}-incorrect_token") } it 'does not succeed' do - post_request.(legal_attributes) + post_request.(netex_import: legal_attributes) expect( response.status ).to eq(401) end it 'does not create an Import object' do - expect{ post_request.(legal_attributes) }.not_to change{Import.count} + expect{ post_request.(netex_import: legal_attributes) }.not_to change{Import.count} end end @@ -59,13 +59,13 @@ RSpec.describe "NetexImport", type: :request do let( :authorization ){ authorization_token_header( get_api_key.token ) } it 'does not succeed' do - post_request.(illegal_attributes) + post_request.(netex_import: illegal_attributes) expect( response.status ).to eq(406) expect( json_response_body['errors']['file'] ).not_to be_empty end it 'does not create an Import object' do - expect{ post_request.(illegal_attributes) }.not_to change{Import.count} + expect{ post_request.(netex_import: illegal_attributes) }.not_to change{Import.count} end end end |
