Skip to content

Commit

Permalink
Written test for deleting an ISA compliant study with linked sample t…
Browse files Browse the repository at this point in the history
…ypes in Single Page.
  • Loading branch information
Kevin De Pelseneer committed Aug 22, 2023
1 parent d6bd99d commit 10eee7f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/functional/studies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class StudiesControllerTest < ActionController::TestCase
def setup
login_as FactoryBot.create(:admin).user
end

test 'should get index' do
FactoryBot.create :study, policy: FactoryBot.create(:public_policy)
get :index
Expand Down Expand Up @@ -1229,7 +1229,7 @@ def test_should_show_investigation_tab
policy: FactoryBot.create(:public_policy),
contributor: person)
get :show, params: { id: study.id }

assert_response :success
assert_select 'a[href=?]',
order_assays_study_path(study), count: 0
Expand Down Expand Up @@ -1394,4 +1394,22 @@ def test_should_show_investigation_tab
assert_equal 'my_tag', assigns(:study).tags_as_text_array.first
end

test 'should delete empty study with linked sample type' do
person = FactoryBot.create(:person)
study_source_sample_type = FactoryBot.create :linked_sample_type
study_sample_sample_type = FactoryBot.create :linked_sample_type
study = FactoryBot.create(:study,
policy:FactoryBot.create(:private_policy, permissions:[FactoryBot.create(:permission,contributor: person, access_type:Policy::EDITING)]),
sample_types: [study_source_sample_type, study_sample_sample_type],
contributor: person)

login_as(person)

assert_difference('SampleType.count', -2) do
assert_difference('Study.count', -1) do
delete :destroy, params: { id: study.id, return_to: '/single_pages/' }
end
end
end

end

0 comments on commit 10eee7f

Please sign in to comment.