Skip to content

Commit

Permalink
Update update_status failed render paths
Browse files Browse the repository at this point in the history
Updates the page to be rendered based on the
attempted status update (i.e. if a denial failed,
render the deny page)
  • Loading branch information
Jonathan Young committed Sep 7, 2023
1 parent b1b36bf commit 1977961
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/controllers/annual_leave_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def update_status
helpers.send_approved_request_email(@annual_leave_request)
redirect_to_status_update_confirmation_page
else
render "approve"
render "approve" if annual_leave_request_params[:status] == "approved"
render "deny" if annual_leave_request_params[:status] == "denied"
end
end

Expand Down
15 changes: 14 additions & 1 deletion spec/controllers/annual_leave_requests_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,30 @@
sign_in line_manager
end

it "renders the approve page if status update is unsuccessful" do
it "renders the approve page if a status update to 'approved' is unsuccessful" do
patch :update_status, params: {
annual_leave_request_id: leave_request.id,
annual_leave_request: {
confirm_approval: "unconfirmed",
status: "approved",
},
}

expect(response).to render_template(:approve)
end

it "renders the deny page if a status update to 'denied' is unsuccessful" do
patch :update_status, params: {
annual_leave_request_id: leave_request.id,
annual_leave_request: {
denial_reason: "",
status: "denied",
},
}

expect(response).to render_template(:deny)
end

it "sends an email to the line report when status is updated to approved" do
approved_request_email_hash = {
email_address: user.email,
Expand Down

0 comments on commit 1977961

Please sign in to comment.