diff --git a/app/controllers/works_wizard_controller.rb b/app/controllers/works_wizard_controller.rb index 3608912ef..e4f7df599 100644 --- a/app/controllers/works_wizard_controller.rb +++ b/app/controllers/works_wizard_controller.rb @@ -84,10 +84,8 @@ def attachment_selected if params[:save_only] == "true" render :attachment_select - elsif @work.files_location == "file_upload" - redirect_to work_file_upload_url(@work) else - redirect_to work_file_other_url(@work) + redirect_to file_location_url end end @@ -168,6 +166,11 @@ def readme_uploaded end end + def file_location_url + WorkMetadataService.file_location_url(@work) + end + helper_method :file_location_url + private def load_work diff --git a/app/services/work_metadata_service.rb b/app/services/work_metadata_service.rb index 321878a94..64b62d4ab 100644 --- a/app/services/work_metadata_service.rb +++ b/app/services/work_metadata_service.rb @@ -25,6 +25,14 @@ def new_submission end end + def self.file_location_url(work) + if work.files_location == "file_upload" + Rails.application.routes.url_helpers.work_file_upload_path(work) + else + Rails.application.routes.url_helpers.work_file_other_path(work) + end + end + private def update_work diff --git a/app/views/works_wizard/readme_select.html.erb b/app/views/works_wizard/readme_select.html.erb index c42736db8..0d0fb3b57 100644 --- a/app/views/works_wizard/readme_select.html.erb +++ b/app/views/works_wizard/readme_select.html.erb @@ -25,7 +25,7 @@
- <%= link_to t('works.form.readme_upload.go_back'), edit_work_path(@work, wizard: true), class: "btn btn-secondary" %> + <%= link_to t('works.form.readme_upload.go_back'), edit_work_wizard_path(@work), class: "btn btn-secondary" %> <%= f.submit(t('works.form.readme_upload.continue'), class: "btn btn-primary wizard-next-button", id: 'readme-upload', disabled: @readme.blank?) %>
<% end %> diff --git a/app/views/works_wizard/review.html.erb b/app/views/works_wizard/review.html.erb index 273ced444..ef9c3ad14 100644 --- a/app/views/works_wizard/review.html.erb +++ b/app/views/works_wizard/review.html.erb @@ -10,7 +10,7 @@
- <%= link_to "Go Back", work_attachment_select_url(@work, wizard: true), class: "btn btn-secondary" %> + <%= link_to "Go Back", file_location_url , class: "btn btn-secondary" %> <%= submit_tag "Grant License and Complete", class: "btn btn-primary wizard-next-button" %>
<% end %> diff --git a/spec/system/work_wizard_reverse_spec.rb b/spec/system/work_wizard_reverse_spec.rb new file mode 100644 index 000000000..49465f69f --- /dev/null +++ b/spec/system/work_wizard_reverse_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true +require "rails_helper" + +describe "walk the wizard in reverse", type: :system, js: true do + it "follow the same path in reverse or forward" do + work = FactoryBot.create :draft_work, files_location: "file_upload" + stub_s3 data: [FactoryBot.build(:s3_readme, work:)] + sign_in work.created_by_user + visit work_review_path(work) + + expect(page).to have_content "Data curators will review" + click_on "Go Back" + + expect(page).to have_content "Once you have uploaded" + click_on "Go Back" + + expect(page).to have_content "Begin the process to upload your submission" + click_on "Go Back" + + expect(page).to have_content "Please upload the README" + click_on "Go Back" + + expect(page).to have_content "By initiating this new submission" + click_on "Save Work" + + expect(page).to have_content "Please upload the README" + click_on "Continue" + + expect(page).to have_content "Begin the process to upload your submission" + click_on "Continue" + + expect(page).to have_content "Once you have uploaded" + click_on "Continue" + + expect(page).to have_content "Data curators will review" + end +end