diff options
| author | Xinhui | 2017-08-23 14:28:22 +0200 |
|---|---|---|
| committer | Xinhui | 2017-08-23 14:28:22 +0200 |
| commit | 1d496326ca9177bd1b9b5202eaa5f6137bfd7fa6 (patch) | |
| tree | f40452096e9aa7a96e99bc71534a4a1419cfccf8 /spec | |
| parent | 6ef942b93eaa0a1d0d6203a3e984f95c751e9ea9 (diff) | |
| download | chouette-core-1d496326ca9177bd1b9b5202eaa5f6137bfd7fa6.tar.bz2 | |
API - WorkbenchImport #create action
Refs #4280
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/api/v1/imports_controller_spec.rb | 11 | ||||
| -rw-r--r-- | spec/controllers/api/v1/workbenches_controller_spec.rb | 2 | ||||
| -rw-r--r-- | spec/support/shared_context.rb | 8 |
3 files changed, 21 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/imports_controller_spec.rb b/spec/controllers/api/v1/imports_controller_spec.rb index 52fbf8e9b..f9593df99 100644 --- a/spec/controllers/api/v1/imports_controller_spec.rb +++ b/spec/controllers/api/v1/imports_controller_spec.rb @@ -4,6 +4,8 @@ RSpec.describe Api::V1::ImportsController, type: :controller do let(:workbench) { create :workbench, organisation: organisation } context 'unauthenticated' do + include_context 'iboo wrong authorisation api user' + describe 'GET #index' do it 'should not be successful' do get :index, workbench_id: workbench.id @@ -21,5 +23,14 @@ RSpec.describe Api::V1::ImportsController, type: :controller do expect(response).to be_success end end + + describe 'POST #create' do + let(:file) { fixture_file_upload('multiple_references_import.zip') } + + it 'should be successful' do + post :create, workbench_id: workbench.id, workbench_import: {file: file, creator: 'test'}, format: :json + expect(response).to be_success + end + end end end diff --git a/spec/controllers/api/v1/workbenches_controller_spec.rb b/spec/controllers/api/v1/workbenches_controller_spec.rb index dc05c3926..7780da142 100644 --- a/spec/controllers/api/v1/workbenches_controller_spec.rb +++ b/spec/controllers/api/v1/workbenches_controller_spec.rb @@ -2,6 +2,8 @@ require 'rails_helper' RSpec.describe Api::V1::WorkbenchesController, type: :controller do context 'unauthenticated' do + include_context 'iboo wrong authorisation api user' + describe 'GET #index' do it 'should not be successful' do get :index diff --git a/spec/support/shared_context.rb b/spec/support/shared_context.rb index e7416f2f1..e9b0025a2 100644 --- a/spec/support/shared_context.rb +++ b/spec/support/shared_context.rb @@ -5,3 +5,11 @@ shared_context 'iboo authenticated api user' do request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(api_key.organisation.code, api_key.token) end end + +shared_context 'iboo wrong authorisation api user' do + let(:api_key) { create(:api_key, organisation: organisation) } + + before do + request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials('fake code', api_key.token) + end +end |
