Skip to content

Commit

Permalink
Redirect ISA-JSON compliant studies
Browse files Browse the repository at this point in the history
Study gets redirected to the `edit_isa_assay` path if it's ISA-JSON
compliant.
  • Loading branch information
kdp-cloud committed Oct 9, 2024
1 parent 2f73d9b commit 8407808
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/studies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ def new_object_based_on_existing_one

def edit
@study = Study.find(params[:id])
respond_to do |format|
format.html
if @study.is_isa_json_compliant?
redirect_to edit_isa_study_path(@study)
else
respond_to do |format|
format.html
end
end
end

Expand Down
12 changes: 12 additions & 0 deletions test/functional/studies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2099,4 +2099,16 @@ def test_should_show_investigation_tab
assert_select 'a', text: /Add new #{I18n.t('assay')}/i, count: 0
end
end

test 'should redirect isa json compliant study to isa study edit page' do
with_config_value(:isa_json_compliance_enabled, true) do
person = FactoryBot.create(:person)
login_as(person)
investigation = FactoryBot.create(:investigation, contributor: person, is_isa_json_compliant: true)
study = FactoryBot.create(:isa_json_compliant_study, contributor: person, investigation: investigation)

get :edit, params: { id: study }
assert_redirected_to edit_isa_study_path(study)
end
end
end

0 comments on commit 8407808

Please sign in to comment.