Skip to content

Commit

Permalink
Fix HTML rendering in WCA ID uniqueness validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 9, 2020
1 parent 481b1e5 commit d3e7741
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion WcaOnRails/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def wca_id_is_unique_or_for_dummy_account
I18n.t('users.errors.unique_html',
used_name: user.name,
used_email: user.email,
used_edit_path: Rails.application.routes.url_helpers.edit_user_path(user)),
used_edit_path: Rails.application.routes.url_helpers.edit_user_path(user)).html_safe,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion WcaOnRails/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ en:
not_found: "not found"
already_assigned: "already assigned to a different user"
dob_incorrect_html: "does not match our database. If you're sure you're providing the correct date in the correct format (YYYY-MM-DD) please contact with WCA Results Team using <a href=\"%{dob_form_path}\">this dedicated form</a>."
unique_html: "is already used by \"%{used_name}\" with %{used_email}. To free up the WCA ID, you can <a href=%{used_edit_path} target='_blank'>edit that account</a> and unassign the WCA ID."
unique_html: "is already used by %{used_name} with %{used_email}. To free up the WCA ID, you can <a href=\"%{used_edit_path}\" target=\"_blank\">edit that account</a> and unassign the WCA ID."
dob_past: "must be in the past"
dob_recent: "must be at least two years old"
already_represented_country: "Cannot change the country to a country the person has already represented in the past."
Expand Down
5 changes: 1 addition & 4 deletions WcaOnRails/spec/features/edit_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ def submit_form
fill_in "WCA ID", with: existing_user.wca_id
submit_form

expect(page).to have_text I18n.t('users.errors.unique_html',
used_name: existing_user.name,
used_email: existing_user.email,
used_edit_path: Rails.application.routes.url_helpers.edit_user_path(existing_user))
expect(page).to have_text "WCA ID is already used by #{existing_user.name}"

# Entering a valid wca id
fill_in "WCA ID", with: new_person.wca_id
Expand Down

0 comments on commit d3e7741

Please sign in to comment.