diff --git a/app/assets/javascripts/repositories/renderers/edit_renderers.js b/app/assets/javascripts/repositories/renderers/edit_renderers.js
index 33993b49f..be87a5cca 100644
--- a/app/assets/javascripts/repositories/renderers/edit_renderers.js
+++ b/app/assets/javascripts/repositories/renderers/edit_renderers.js
@@ -9,7 +9,7 @@ $.fn.dataTable.render.editRowName = function(formId, cell) {
diff --git a/app/assets/javascripts/repositories/renderers/new_renderers.js b/app/assets/javascripts/repositories/renderers/new_renderers.js
index b55359b33..5b8a1568c 100644
--- a/app/assets/javascripts/repositories/renderers/new_renderers.js
+++ b/app/assets/javascripts/repositories/renderers/new_renderers.js
@@ -6,7 +6,7 @@ $.fn.dataTable.render.newRowName = function(formId, $cell) {
diff --git a/app/models/repository_asset_value.rb b/app/models/repository_asset_value.rb
index cda7596a7..dc5fe27d3 100644
--- a/app/models/repository_asset_value.rb
+++ b/app/models/repository_asset_value.rb
@@ -35,11 +35,12 @@ class RepositoryAssetValue < ApplicationRecord
def update_data!(new_data, user)
destroy! && return if new_data == '-1'
- if new_data[:direct_upload_token]
- asset.file.attach(new_data[:direct_upload_token])
- else
+ if new_data.is_a?(Hash) && new_data[:file_data]
asset.file.attach(io: StringIO.new(Base64.decode64(new_data[:file_data].split(',')[1])),
filename: new_data[:filename])
+ else
+ # new_data is direct_upload_token
+ asset.file.attach(new_data)
end
asset.last_modified_by = user
@@ -48,19 +49,18 @@ class RepositoryAssetValue < ApplicationRecord
end
def self.new_with_payload(payload, attributes)
- raise ArgumentError, 'Payload needs to be a hash' unless payload.is_a?(Hash)
-
value = new(attributes)
team = value.repository_cell.repository_column.repository.team
value.asset = Asset.create!(created_by: value.created_by, last_modified_by: value.created_by, team: team)
- if payload[:direct_upload_token]
- value.asset.file.attach(payload[:direct_upload_token])
- elsif payload[:file_data]
+ if payload.is_a?(Hash) && payload[:file_data]
value.asset.file.attach(
io: StringIO.new(Base64.decode64(payload[:file_data].split(',')[1])),
filename: payload[:filename]
)
+ else
+ # payload is direct_upload_token
+ value.asset.file.attach(payload)
end
value.asset.post_process_file(team)
diff --git a/spec/models/repository_asset_value_spec.rb b/spec/models/repository_asset_value_spec.rb
index 868cf228c..d61775b24 100644
--- a/spec/models/repository_asset_value_spec.rb
+++ b/spec/models/repository_asset_value_spec.rb
@@ -58,11 +58,7 @@ describe RepositoryAssetValue, type: :model do
}
end
- let(:new_file_with_direct_upload_token) do
- {
- direct_upload_token: 'someUrl'
- }
- end
+ let(:new_file_with_direct_upload_token) { 'Token' }
context 'when update data' do
# context 'when has direct_upload_token' do
diff --git a/spec/services/repository_rows/update_repository_row_service_spec.rb b/spec/services/repository_rows/update_repository_row_service_spec.rb
index 0da0bd768..c9b7c4581 100644
--- a/spec/services/repository_rows/update_repository_row_service_spec.rb
+++ b/spec/services/repository_rows/update_repository_row_service_spec.rb
@@ -119,9 +119,6 @@ describe RepositoryRows::UpdateRepositoryRowService do
end
context 'when service does not succeed' do
- context 'when cell value update fails' do
- end
-
context 'when updates repository_row and cell, but fails' do
let(:params) do
{