mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-09 06:35:37 +08:00
Remove file deletion manually
This commit is contained in:
parent
cc9d987321
commit
8b5e346770
3 changed files with 32 additions and 1 deletions
|
@ -113,7 +113,6 @@ module Api
|
|||
old_checksum, new_checksum = nil
|
||||
Result.transaction do
|
||||
old_checksum = @result.asset.file.blob.checksum
|
||||
@result.asset.file.purge
|
||||
@result.asset.file.attach(result_file_params[:file])
|
||||
new_checksum = @result.asset.file.blob.checksum
|
||||
end
|
||||
|
|
BIN
spec/fixtures/files/apple.jpg
vendored
Normal file
BIN
spec/fixtures/files/apple.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
|
@ -371,6 +371,7 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
|
|||
context 'when resultType is file' do
|
||||
let(:result_file) { @valid_task.results.last }
|
||||
let(:file) { fixture_file_upload('files/test.jpg', 'image/jpg') }
|
||||
let(:second_file) { fixture_file_upload('files/apple.jpg', 'image/jpg') }
|
||||
let(:request_body) do
|
||||
{
|
||||
data: {
|
||||
|
@ -411,6 +412,37 @@ RSpec.describe 'Api::V1::ResultsController', type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when has new image for update' do
|
||||
let(:request_body_with_same_name_new_file) do
|
||||
{
|
||||
data: {
|
||||
type: 'results',
|
||||
attributes: {
|
||||
name: result_file.reload.name
|
||||
}
|
||||
},
|
||||
included: [
|
||||
{ type: 'result_files',
|
||||
attributes: {
|
||||
file: second_file
|
||||
} }
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns status 200' do
|
||||
put(api_v1_team_project_experiment_task_result_path(
|
||||
team_id: @teams.first.id,
|
||||
project_id: @valid_project,
|
||||
experiment_id: @valid_experiment,
|
||||
task_id: @valid_task,
|
||||
id: result_file.id
|
||||
), params: request_body_with_same_name_new_file, headers: @valid_headers)
|
||||
|
||||
expect(response).to have_http_status 200
|
||||
end
|
||||
end
|
||||
|
||||
context 'when there is nothing to update' do
|
||||
let(:request_body_with_same_name) do
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue