report user_role when submitting error form
We have a shared error form partial that we use for various response codes that we handle in the Canvas app. Support wanted to mimic our already existing behavior found in our Help Dialog. This change includes the user's current roles in the POST to generate an ErrorReport; if there is a current user session. We give the opportunity to submit comments for things like 404 or 500 errors that the app handles and that's where this change comes into play. closes FOO-490 flag = none test plan: * The easiest way to test this commit out is to trigger a handled 500 error. I twiddled with some account settings code to make it happen. * You should get a spiffy image of a spacecraft and something along the lines of "Page Error", "Something broke unexpectedly" * There will be a "Click here to tell us what happened link" * Open up DevTools and head on over to the Network tab * Fill out the input and click the "Send Comments" button to submit the form * Inspect your network traffic and find the request to error_reports * Verify the Form Data includes the param "error[user_roles]" and it includes a comma seperated list of user roles * Find the associated ErrorReport for that submission /error_reports * Ensure it includes an optional data key for `user_roles:` below `type`, with the same comma seperated values that you inspected above Change-Id: I5e014b599e481e27e9a66683d038e6270fa50b1d Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242809 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> QA-Review: Ahmad Amireh <ahmad@instructure.com> Product-Review: Ahmad Amireh <ahmad@instructure.com> Reviewed-by: Charley Kline <ckline@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
86580e3f5e
commit
abab1d680a
|
@ -26,6 +26,7 @@
|
|||
<%= text_area :error, :comments, :style => "width: 100%; height: 100px; border: 1px solid #888;" %>
|
||||
<% if @current_user %>
|
||||
<%= before_label('email_optional', %{Email (optional)}) %>
|
||||
<%= hidden_field :error, :user_roles, :value => @current_user.try(:roles, @domain_root_account).join(',') %>
|
||||
<% else %>
|
||||
<%= before_label('email_required', %{Email (required)}) %>
|
||||
<% end %>
|
||||
|
|
|
@ -46,11 +46,13 @@ describe ErrorsController do
|
|||
error: {
|
||||
url: "someurl",
|
||||
message: "BigError",
|
||||
email: "testerrors42@example.com"
|
||||
email: "testerrors42@example.com",
|
||||
user_roles: "user,student"
|
||||
}
|
||||
}
|
||||
assert_recorded_error
|
||||
expect(ErrorReport.last.email).to eq("testerrors42@example.com")
|
||||
expect(ErrorReport.last.data["user_roles"]).to eq("user,student")
|
||||
end
|
||||
|
||||
it "doesnt need authentication" do
|
||||
|
|
|
@ -25,6 +25,7 @@ describe "/shared/errors/_error_form" do
|
|||
view_context
|
||||
render :partial => "shared/errors/error_form"
|
||||
expect(response).not_to be_nil
|
||||
expect(response).to include("error[user_roles]")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue