From 4761ac91bd3b48971575260766be997f1fa70393 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Wed, 15 Feb 2017 18:22:02 +0100 Subject: [PATCH] Displays officing booth in layout --- app/controllers/officing/base_controller.rb | 1 + app/controllers/officing/booth_controller.rb | 4 ++-- app/views/layouts/_officing_booth.html.erb | 5 +++++ app/views/layouts/admin.html.erb | 1 + config/locales/en/admin.yml | 2 ++ config/locales/en/officing.yml | 1 - config/locales/es/admin.yml | 2 ++ config/locales/es/officing.yml | 1 - spec/features/officing/booth_spec.rb | 8 ++++++-- 9 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 app/views/layouts/_officing_booth.html.erb diff --git a/app/controllers/officing/base_controller.rb b/app/controllers/officing/base_controller.rb index ff1eb52e7..7d9bf225d 100644 --- a/app/controllers/officing/base_controller.rb +++ b/app/controllers/officing/base_controller.rb @@ -1,5 +1,6 @@ class Officing::BaseController < ApplicationController layout "admin" + helper_method :current_booth before_action :authenticate_user! before_action :verify_officer diff --git a/app/controllers/officing/booth_controller.rb b/app/controllers/officing/booth_controller.rb index 624de8a2b..383154f97 100644 --- a/app/controllers/officing/booth_controller.rb +++ b/app/controllers/officing/booth_controller.rb @@ -7,14 +7,14 @@ class Officing::BoothController < Officing::BaseController if only_one_booth? set_booth(@booths.first) - redirect_to officing_root_path, notice: t("officing.booth.new.success", booth: @booths.first.location) + redirect_to officing_root_path end end def create find_booth set_booth(@booth) - redirect_to officing_root_path, notice: t("officing.booth.new.success", booth: @booth.location) + redirect_to officing_root_path end private diff --git a/app/views/layouts/_officing_booth.html.erb b/app/views/layouts/_officing_booth.html.erb new file mode 100644 index 000000000..aa1bd0f1e --- /dev/null +++ b/app/views/layouts/_officing_booth.html.erb @@ -0,0 +1,5 @@ +<% if current_user.poll_officer? %> +
+ <%= t("admin.officing_booth.title", booth: current_booth.try(:location)) %> +
+<% end %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 4b772f614..6b231ce49 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -33,6 +33,7 @@
<%= render "layouts/flash" %> + <%= render "layouts/officing_booth" %> <%= yield %>
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 156702512..582a1c740 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -14,6 +14,8 @@ en: edit: Edit configure: Configure delete: Delete + officing_booth: + title: "You are officing the booth located at %{booth}. If this is not correct, do not continue and call the help phone number. Thank you." banners: index: title: Banners diff --git a/config/locales/en/officing.yml b/config/locales/en/officing.yml index 9533f6bb8..e377654f0 100644 --- a/config/locales/en/officing.yml +++ b/config/locales/en/officing.yml @@ -19,7 +19,6 @@ en: booth: new: title: "Choose your booth" - success: "You are officing the booth located at %{booth}. If this is not correct, do not continue and call the help phone number. Thank you." results: flash: create: "Results saved" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 456238bcc..9e2f54a62 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -14,6 +14,8 @@ es: edit: Editar configure: Configurar delete: Borrar + officing_booth: + title: "Estás ahora mismo en la mesa ubicada en %{booth}. Si esto no es correcto no sigas adelante y llama al teléfono de incidencias. Gracias." banners: index: title: Banners diff --git a/config/locales/es/officing.yml b/config/locales/es/officing.yml index 1c6bae97b..e25f9cde8 100644 --- a/config/locales/es/officing.yml +++ b/config/locales/es/officing.yml @@ -19,7 +19,6 @@ es: booth: new: title: "Escoge tu urna" - success: "Estás ahora mismo en la mesa ubicada en %{booth}. Si esto no es correcto no sigas adelante y llama al teléfono de incidencias. Gracias." results: flash: create: "Datos guardados" diff --git a/spec/features/officing/booth_spec.rb b/spec/features/officing/booth_spec.rb index 8f0e6cd3d..bbab9f53f 100644 --- a/spec/features/officing/booth_spec.rb +++ b/spec/features/officing/booth_spec.rb @@ -30,7 +30,9 @@ feature "Booth" do login_through_form_as(officer.user) - expect(page).to have_content "You are officing the booth located at #{booth.location}." + within("#officing-booth") do + expect(page).to have_content "You are officing the booth located at #{booth.location}." + end end scenario "Officer with multiple booth assignments today" do @@ -54,7 +56,9 @@ feature "Booth" do select booth2.location, from: "booth_id" click_button "Enter" - expect(page).to have_content "You are officing the booth located at #{booth2.location}." + within("#officing-booth") do + expect(page).to have_content "You are officing the booth located at #{booth2.location}." + end end scenario "Display single booth for any number of polls" do