mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-14 17:14:54 +08:00
Fix failing tests [SCI-2773]
This commit is contained in:
parent
30885e060d
commit
23ee4760ae
8 changed files with 34 additions and 47 deletions
|
@ -87,11 +87,8 @@ module Api
|
|||
raise IDMismatchError
|
||||
end
|
||||
if inventory_column_params[:attributes].include?(:data_type)
|
||||
return render_error(
|
||||
I18n.t('api.core.errors.inventory_column_type.title'),
|
||||
I18n.t('api.core.errors.inventory_column_type.detail'),
|
||||
:bad_request
|
||||
)
|
||||
raise ActiveRecord::RecordInvalid,
|
||||
I18n.t('api.core.errors.inventory_column_type.detail')
|
||||
end
|
||||
inventory_column_params[:attributes]
|
||||
end
|
||||
|
|
|
@ -22,7 +22,6 @@ module Api
|
|||
|
||||
def create
|
||||
create_text_result if result_text_params.present?
|
||||
throw ActionController::ParameterMissing unless @result
|
||||
render jsonapi: @result,
|
||||
serializer: ResultSerializer,
|
||||
include: %i(text table file),
|
||||
|
@ -54,11 +53,8 @@ module Api
|
|||
image_params = t[:attributes]
|
||||
token = image_params[:file_token]
|
||||
unless result_text.text["[~tiny_mce_id:#{token}]"]
|
||||
return render_error(
|
||||
I18n.t('api.core.errors.result_wrong_tinymce.title'),
|
||||
I18n.t('api.core.errors.result_wrong_tinymce.detail'),
|
||||
:bad_request
|
||||
)
|
||||
raise ActiveRecord::RecordInvalid,
|
||||
I18n.t('api.core.errors.result_wrong_tinymce.detail')
|
||||
end
|
||||
image = Paperclip.io_adapters.for(image_params[:file_data])
|
||||
image.original_filename = image_params[:file_name]
|
||||
|
@ -102,11 +98,8 @@ module Api
|
|||
/\[~tiny_mce_id:(\w+)\]/
|
||||
).flatten.each do |token|
|
||||
unless file_tokens.include?(token)
|
||||
return render_error(
|
||||
I18n.t('api.core.errors.result_missing_tinymce.title'),
|
||||
I18n.t('api.core.errors.result_missing_tinymce.detail'),
|
||||
:bad_request
|
||||
)
|
||||
raise ActiveRecord::RecordInvalid,
|
||||
I18n.t('api.core.errors.result_missing_tinymce.detail')
|
||||
end
|
||||
end
|
||||
prms
|
||||
|
|
|
@ -7,7 +7,7 @@ module Api
|
|||
attributes :name, :visibility, :start_date, :archived
|
||||
|
||||
def start_date
|
||||
object.created_at
|
||||
I18n.l(object.created_at, format: :full)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1970,13 +1970,10 @@ en:
|
|||
title: "Wrong type"
|
||||
detail: "Wrong object type within parameters"
|
||||
inventory_column_type:
|
||||
title: "Not allowed"
|
||||
detail: "Update of data_type attribute is not allowed"
|
||||
result_missing_tinymce:
|
||||
title: "Error"
|
||||
detail: "Text contains reference to nonexisting TinyMCE image"
|
||||
result_wrong_tinymce:
|
||||
title: "Error"
|
||||
detail: "Image reference not found in the text"
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
project_id: @valid_project), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, user in not member of the team' do
|
||||
|
@ -52,7 +52,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
project_id: @unaccessible_project), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing project' do
|
||||
|
@ -61,7 +61,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
project_id: -1), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing experiment' do
|
||||
|
@ -99,7 +99,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, experiment from another project' do
|
||||
|
@ -111,7 +111,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, experiment from unaccessible project' do
|
||||
|
@ -123,7 +123,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ RSpec.describe "Api::V1::ProjectsController", type: :request do
|
|||
headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing team' do
|
||||
|
@ -52,7 +52,7 @@ RSpec.describe "Api::V1::ProjectsController", type: :request do
|
|||
get api_v1_team_projects_path(team_id: -1), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,7 +78,7 @@ RSpec.describe "Api::V1::ProjectsController", type: :request do
|
|||
headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing project' do
|
||||
|
@ -87,7 +87,7 @@ RSpec.describe "Api::V1::ProjectsController", type: :request do
|
|||
headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, project from another team' do
|
||||
|
@ -97,7 +97,7 @@ RSpec.describe "Api::V1::ProjectsController", type: :request do
|
|||
headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,7 +85,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, user in not member of the team' do
|
||||
|
@ -98,7 +98,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing task' do
|
||||
|
@ -111,7 +111,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -221,7 +221,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), params: @valid_text_hash_body.to_json, headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, user in not member of the team' do
|
||||
|
@ -234,7 +234,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), params: @valid_text_hash_body.to_json, headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, task from another experiment' do
|
||||
|
@ -247,7 +247,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), params: @valid_text_hash_body.to_json, headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -280,7 +280,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing result' do
|
||||
|
@ -294,7 +294,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, result from unaccessible task' do
|
||||
|
@ -308,7 +308,7 @@ RSpec.describe "Api::V1::ResultsController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, user in not member of the team' do
|
||||
|
@ -66,7 +66,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing experiment' do
|
||||
|
@ -78,7 +78,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,7 +110,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(403)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
it 'When invalid request, non existing task' do
|
||||
|
@ -123,7 +123,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
it 'When invalid request, task from unaccessible experiment' do
|
||||
|
@ -136,7 +136,7 @@ RSpec.describe "Api::V1::TasksController", type: :request do
|
|||
), headers: @valid_headers
|
||||
expect(response).to have_http_status(404)
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue