Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6792: fix logic to account for the fact that language_params can be blank #4988

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/languages_controller.rb
Original file line number Diff line number Diff line change
@@ -31,13 +31,13 @@ def update
@language = Language.find_by(short: params[:id])
authorize @language

if !policy(@language).can_edit_non_abuse_fields? && (@language.name != language_params[:name] || @language.short != language_params[:short] || @language.sortable_name != language_params[:sortable_name] || @language.support_available != (language_params[:support_available] == "1"))
if !policy(@language).can_edit_non_abuse_fields? && ((language_params[:name].present? && language_params[:name] != @language.name) || (language_params[:short].present? && @language.short != language_params[:short]) || (language_params[:sortable_name].present? && @language.sortable_name != language_params[:sortable_name]) || (language_params[:support_available].present? && @language.support_available != (language_params[:support_available] == "1")))
flash[:error] = t("languages.update.non_abuse_field_error")
redirect_to languages_path
return
end

if !policy(@language).can_edit_abuse_fields? && (@language.abuse_support_available != (language_params[:abuse_support_available] == "1"))
if !policy(@language).can_edit_abuse_fields? && language_params[:abuse_support_available].present? && (@language.abuse_support_available != (language_params[:abuse_support_available] == "1"))
flash[:error] = t("languages.update.abuse_field_error")
redirect_to languages_path
return
4 changes: 2 additions & 2 deletions features/admins/admin_languages.feature
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ Scenario: Adding Abuse support for a language
| name | short |
| Arabic | ar |
| Espanol | es |
When I am logged in as a "translation" admin
When I am logged in as a "policy_and_abuse" admin
And I go to the languages page
# Languages are sorted by short name, so the first "Edit" is for Arabic
And I follow "Edit"
@@ -39,7 +39,7 @@ Scenario: Adding a language to the Support form
| name | short |
| Sindarin | sj |
| Klingon | tlh |
When I am logged in as a "translation" admin
When I am logged in as a "support" admin
And I go to the languages page
# Languages are sorted by short name, so the first "Edit" is for Sindarin
And I follow "Edit"