Skip to content

Commit

Permalink
associate samples via the fancy-multiselect #1961
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Aug 16, 2024
1 parent b591593 commit 52efdb7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 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 @@ -26,6 +26,7 @@

<%= render partial: "assets/asset_form_bottom", locals: {show_publications:false, attribution_enable: false, f: f} %>
<%= f.fancy_multiselect :data_files, other_projects_checkbox: true %>
<%= f.fancy_multiselect :samples, other_projects_checkbox: true %>
<%= form_submit_buttons(@observation_unit) %>
Expand Down
6 changes: 6 additions & 0 deletions test/functional/observation_units_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def rdf_test_object
obs_unit = FactoryBot.create(:observation_unit)
emt = FactoryBot.create(:simple_observation_unit_extended_metadata_type)
datafile = FactoryBot.create(:data_file, contributor: obs_unit.contributor)
sample = FactoryBot.create(:sample, 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],
sample_ids: [sample.id],
extended_metadata_attributes: {
extended_metadata_type_id: emt.id,
data: {
Expand All @@ -118,6 +120,7 @@ def rdf_test_object
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
assert_equal [sample], obs_unit.samples
end

test 'new' do
Expand All @@ -136,6 +139,7 @@ def rdf_test_object
contributor = FactoryBot.create(:person)
study = FactoryBot.create(:study, contributor: contributor)
datafile = FactoryBot.create(:data_file, contributor: contributor)
sample = FactoryBot.create(:sample, contributor: contributor)
project = contributor.projects.first
other_person = FactoryBot.create(:person)
creator = FactoryBot.create(:person)
Expand All @@ -147,6 +151,7 @@ def rdf_test_object
creator_ids: [creator.id],
project_ids: [project.id],
data_file_ids: [datafile.id],
sample_ids: [sample.id],
study_id: study,
extended_metadata_attributes: {
extended_metadata_type_id: emt.id,
Expand Down Expand Up @@ -175,6 +180,7 @@ def rdf_test_object
assert_equal [project],obs_unit.projects
assert_equal [creator],obs_unit.creators
assert_equal [datafile],obs_unit.data_files
assert_equal [sample],obs_unit.samples
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 52efdb7

Please sign in to comment.