Skip to content

Commit

Permalink
UI to link data files to an observation unit #1961
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Aug 23, 2024
1 parent c686a54 commit bf162ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/views/observation_units/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</div>

<%= render partial: "assets/asset_form_bottom", locals: {show_publications:false, attribution_enable: false, f: f} %>
<%= f.fancy_multiselect :data_files, other_projects_checkbox: true %>
<%= form_submit_buttons(@observation_unit) %>
Expand Down
10 changes: 8 additions & 2 deletions test/functional/observation_units_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,14 @@ def rdf_test_object
test 'update' do
obs_unit = FactoryBot.create(:observation_unit)
emt = FactoryBot.create(:simple_observation_unit_extended_metadata_type)
datafile = FactoryBot.create(:data_file, contributor: obs_unit.contributor)
login_as(obs_unit.contributor)

patch :update, params: { id: obs_unit,
observation_unit:{
title: 'updated title',
description: 'updated description',
data_file_ids: [datafile.id],
extended_metadata_attributes: {
extended_metadata_type_id: emt.id,
data: {
Expand All @@ -115,6 +117,7 @@ def rdf_test_object
assert_equal 'updated name', obs_unit.extended_metadata.get_attribute_value('name')
assert_equal 'updated strain', obs_unit.extended_metadata.get_attribute_value('strain')
assert_equal %w[fish soup], obs_unit.tags.sort
assert_equal [datafile], obs_unit.data_files
end

test 'new' do
Expand All @@ -132,6 +135,7 @@ def rdf_test_object
emt = FactoryBot.create(:simple_observation_unit_extended_metadata_type)
contributor = FactoryBot.create(:person)
study = FactoryBot.create(:study, contributor: contributor)
datafile = FactoryBot.create(:data_file, contributor: contributor)
project = contributor.projects.first
other_person = FactoryBot.create(:person)
creator = FactoryBot.create(:person)
Expand All @@ -141,7 +145,8 @@ def rdf_test_object
title: 'new title',
description: 'new description',
creator_ids: [creator.id],
project_ids: [project],
project_ids: [project.id],
data_file_ids: [datafile.id],
study_id: study,
extended_metadata_attributes: {
extended_metadata_type_id: emt.id,
Expand All @@ -167,8 +172,9 @@ def rdf_test_object
assert_equal 'new strain', obs_unit.extended_metadata.get_attribute_value('strain')
assert_equal %w[fish soup], obs_unit.tags.sort
assert_equal contributor, obs_unit.contributor
assert_equal [project],obs_unit.projects.sort_by(&:id)
assert_equal [project],obs_unit.projects
assert_equal [creator],obs_unit.creators
assert_equal [datafile],obs_unit.data_files
assert_equal Policy::VISIBLE,obs_unit.policy.access_type
assert_equal 1,obs_unit.policy.permissions.count
assert_equal other_person,obs_unit.policy.permissions.first.contributor
Expand Down

0 comments on commit bf162ba

Please sign in to comment.