diff --git a/test/functional/samples_controller_test.rb b/test/functional/samples_controller_test.rb index 196e4528a2..31e6a849a4 100644 --- a/test/functional/samples_controller_test.rb +++ b/test/functional/samples_controller_test.rb @@ -811,7 +811,7 @@ def rdf_test_object assert_select '.list_item_title a[href=?]', sample_path(linking_sample), text: /#{linking_sample.title}/ end - test 'referring sample id is added to sample type link, if necessary' do + test 'Referring samples show linked sample type if permitted in show page' do person = FactoryBot.create(:person) sample = FactoryBot.create(:sample, policy: FactoryBot.create(:private_policy, @@ -827,7 +827,8 @@ def rdf_test_object get :show, params: { id:sample.id } assert_response :success - assert_select 'a[href=?]', sample_type_path(sample_type, referring_sample_id: sample.id), text: /#{sample_type.title}/ + # Referring samples don't show the link to the sample type because the sample type is not visible + assert_select 'a[href=?]', sample_type_path(sample_type), text: /#{sample_type.title}/, count: 0 sample2 = FactoryBot.create(:sample, policy: FactoryBot.create(:public_policy)) sample_type2 = sample2.sample_type @@ -839,12 +840,12 @@ def rdf_test_object get :show, params: { id: sample2.id } assert_response :success - # no referring sample required + # Referring sample shows the link to the sample type because the sample type is visible assert_select 'a[href=?]', sample_type_path(sample_type2), text: /#{sample_type2.title}/ end - test 'referring sample id is added to sample type links in list items' do + test 'referring samples shows the linked sample type links in list items' do person = FactoryBot.create(:person) sample = FactoryBot.create(:sample, policy: FactoryBot.create(:private_policy, @@ -865,9 +866,10 @@ def rdf_test_object get :index - assert_select 'a[href=?]', sample_type_path(sample_type, referring_sample_id: sample.id), text: /#{sample_type.title}/ + # Since the Sample Type is not visible, the link is not rendered + assert_select 'a[href=?]', sample_type_path(sample_type), text: /#{sample_type.title}/, count: 0 - # no referring sample required, ST is already visible + # The Sample Type is visible, so the link is rendered assert_select 'a[href=?]', sample_type_path(sample_type2), text: /#{sample_type2.title}/ end