Skip to content

Commit

Permalink
have csv import based on field_name for custom fields not label
Browse files Browse the repository at this point in the history
  • Loading branch information
dnoneill committed Oct 17, 2024
1 parent 3379e3c commit b207588
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/spotlight/resources/upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def sidecar_update_data
end

def custom_fields_data
data.slice(*exhibit.custom_fields.map(&:slug).map(&:to_s)).compact_blank
data.slice(*exhibit.custom_fields.map(&:field).map(&:to_s)).compact_blank
end

def configured_fields_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

it 'can add multivalued fields' do
field = FactoryBot.create(:custom_field, exhibit: exhibit, is_multiple: true)
post :create, params: { exhibit_id: exhibit, resources_upload: { data: { field.slug => %w[1 2 3] } } }
expect(assigns[:resource].sidecar.data).to include(field.slug => %w[1 2 3])
post :create, params: { exhibit_id: exhibit, resources_upload: { data: { field.field => %w[1 2 3] } } }
expect(assigns[:resource].sidecar.data).to include(field.field => %w[1 2 3])
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/spotlight/resources/upload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
end

it 'the sidecar is updated with the appropriate data from custom fields' do
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_1')
FactoryBot.create(:custom_field, exhibit: exhibit, slug: 'custom_field_2')
FactoryBot.create(:custom_field, exhibit: exhibit, field: 'custom_field_1')
FactoryBot.create(:custom_field, exhibit: exhibit, field: 'custom_field_2')

expect(upload.sidecar).to receive(:update).with(
data: hash_including('custom_field_1' => 'Custom Field 1 Data', 'custom_field_2' => 'Custom Field 2 Data')
Expand Down

0 comments on commit b207588

Please sign in to comment.