From 5ff85d33d60795c8e122eddf04af8f5bfbb391b3 Mon Sep 17 00:00:00 2001 From: Marko Lovic Date: Wed, 1 Aug 2018 14:36:17 +0200 Subject: [PATCH] Fix submit button text for Admin Notifications admin form In Madrid, the button text didn't change depending on whether the form is for the "new" page or for the "edit" page. In consul, the buttons texts were "create admin notification" and "update admin notification" instead of "create notification" and "update notification". Also change translation key from "submit" to "submit_button" to match other instances. --- app/views/admin/admin_notifications/_form.html.erb | 3 ++- config/i18n-tasks.yml | 1 + config/locales/en/admin.yml | 2 ++ config/locales/es/admin.yml | 2 ++ spec/features/admin/admin_notifications_spec.rb | 10 +++++----- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/views/admin/admin_notifications/_form.html.erb b/app/views/admin/admin_notifications/_form.html.erb index 4053bb66d..a08342f2b 100644 --- a/app/views/admin/admin_notifications/_form.html.erb +++ b/app/views/admin/admin_notifications/_form.html.erb @@ -8,6 +8,7 @@ <%= f.text_area :body %>
- <%= f.submit class: "button success" %> + <%= f.submit t("admin.admin_notifications.#{admin_submit_action(@admin_notification)}.submit_button"), + class: "button success" %>
<% end %> diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index a0fb7110e..b673c2110 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -145,6 +145,7 @@ ignore_unused: - 'admin.settings.index.features.*' - 'admin.polls.*.submit_button' - 'admin.booths.*.submit_button' + - 'admin.admin_notifications.*.submit_button' - 'admin.homepage.*' - 'moderation.comments.index.filter*' - 'moderation.comments.index.order*' diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 0806b68b9..682a87dee 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -658,8 +658,10 @@ en: empty_notifications: There are no notifications to show new: section_title: New notification + submit_button: Create notification edit: section_title: Edit notification + submit_button: Update notification show: section_title: Notification preview send: Send notification diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 3ef8039ae..eabfbc536 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -659,8 +659,10 @@ es: empty_notifications: No hay notificaciones para mostrar new: section_title: Nueva notificación + submit_button: Crear notificación edit: section_title: Editar notificación + submit_button: Actualizar notificación show: section_title: Vista previa de notificación send: Enviar notificación diff --git a/spec/features/admin/admin_notifications_spec.rb b/spec/features/admin/admin_notifications_spec.rb index 9bea144d4..4035c17d0 100644 --- a/spec/features/admin/admin_notifications_spec.rb +++ b/spec/features/admin/admin_notifications_spec.rb @@ -75,7 +75,7 @@ feature "Admin Notifications" do body: 'This is a body', link: 'http://www.dummylink.dev') - click_button "Create Admin notification" + click_button "Create notification" expect(page).to have_content "Notification created successfully" expect(page).to have_content "Proposal authors" @@ -99,7 +99,7 @@ feature "Admin Notifications" do body: 'Other body', link: '') - click_button "Update Admin notification" + click_button "Update notification" expect(page).to have_content "Notification updated successfully" expect(page).to have_content "All users" @@ -171,7 +171,7 @@ feature "Admin Notifications" do scenario 'Errors on create' do visit new_admin_admin_notification_path - click_button "Create Admin notification" + click_button "Create notification" expect(page).to have_content error_message end @@ -181,7 +181,7 @@ feature "Admin Notifications" do visit edit_admin_admin_notification_path(notification) fill_in :admin_notification_title, with: '' - click_button "Update Admin notification" + click_button "Update notification" expect(page).to have_content error_message end @@ -228,7 +228,7 @@ feature "Admin Notifications" do visit new_admin_admin_notification_path fill_in_admin_notification_form(segment_recipient: segment_recipient) - click_button "Create Admin notification" + click_button "Create notification" expect(page).to have_content(I18n.t("admin.segment_recipient.#{user_segment}")) end