aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorZog2018-05-30 18:04:10 +0200
committerZog2018-05-30 18:04:10 +0200
commite400ea5d0d481420052caa080b9dbc4e9acf8406 (patch)
tree23ffa9e6fb1760ba72bd47c86b7827915644d480 /spec
parent971b267958c3bf78abea332e0af4c46a23679b61 (diff)
downloadchouette-core-7231-rationalize-iev-api.tar.bz2
Refs #7231; Rationalize imports API7231-rationalize-iev-api
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/api/v1/internals/netex_imports_controller_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb b/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb
index b53ee3f05..4af7e51cb 100644
--- a/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb
+++ b/spec/controllers/api/v1/internals/netex_imports_controller_spec.rb
@@ -1,6 +1,39 @@
RSpec.describe Api::V1::Internals::NetexImportsController, type: :controller do
let(:import_1) { create :netex_import }
let(:import_2) { create :netex_import, status: "successful" }
+ let(:workbench) { create :workbench, organisation: organisation }
+
+ describe 'POST #create' do
+ let(:file) { fixture_file_upload('multiple_references_import.zip') }
+ let(:attributes){{
+ name: "Nom",
+ file: file,
+ workbench_id: workbench.id,
+ parent_id: import_1.id,
+ parent_type: import_1.class.name,
+ }}
+
+ context 'unauthenticated' do
+ include_context 'iboo wrong authorisation internal api'
+
+ it 'should not be successful' do
+ post :create, format: :json, netex_import: attributes
+ expect(response).to have_http_status 401
+ end
+ end
+
+ context 'authenticated' do
+ include_context 'iboo authenticated internal api'
+
+ it 'should be successful' do
+ import_1
+ expect {
+ post :create, format: :json, netex_import: attributes
+ }.to change{Import::Netex.count}.by(1)
+ expect(response).to be_success
+ end
+ end
+ end
describe "GET #notify_parent" do
context 'unauthenticated' do