Skip to content

Commit

Permalink
Redirect to the next item when clicking on the QA widget
Browse files Browse the repository at this point in the history
  • Loading branch information
aapomm committed Feb 3, 2025
1 parent 59dfe38 commit d365314
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[v#.#.#] ([month] [YYYY])
- Hera: Add new layout with redesigned navigation
- QA: Add View History link when viewing Issues/Content blocks
- QA:
- Add View History link when viewing Issues/Content blocks
- Redirect to the next item after reviewing
- Upgraded gems:
- [gem]
- Bugs fixes:
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/qa/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def edit
def update
if @issue.update(state: @state, updated_at: Time.now)
track_state_change(@issue)
redirect_to project_qa_issues_path(current_project), notice: 'State updated successfully.'

redirect_to_next_issue_or_index
else
render :show, alert: @issue.errors.full_messages.join('; ')
end
Expand Down Expand Up @@ -62,6 +63,17 @@ def liquid_resource_assigns
{ 'issue' => IssueDrop.new(@issue) }
end

def redirect_to_next_issue_or_index
notice = 'State updated successfully.'
next_issue = current_project.issues.ready_for_review.first

if next_issue
redirect_to project_qa_issue_path(current_project, next_issue), notice: notice
else
redirect_to project_qa_issues_path(current_project), notice: notice
end
end

def set_issue
@issue = @issues.find(params[:id])
end
Expand Down
9 changes: 8 additions & 1 deletion spec/support/qa_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,16 @@

expect { click_button state }.to have_enqueued_job(ActivityTrackingJob).with(job_params(record))

expect(current_path).to eq polymorphic_path([current_project, :qa, item_type.to_s.pluralize.to_sym])
expect(page).to have_selector('.alert-success', text: 'State updated successfully.')
expect(record.reload.state).to eq state.downcase.gsub(' ', '_')

next_item = model.where(state: 'ready_for_review').first

if next_item
expect(current_path).to eq polymorphic_path([current_project, :qa, next_item])
else
expect(current_path).to eq polymorphic_path([current_project, :qa, item_type.to_s.pluralize.to_sym])
end
end
end
end
Expand Down

0 comments on commit d365314

Please sign in to comment.