diff --git a/app/assets/fonts/icons.eot b/app/assets/fonts/icons.eot index 5564a5c62..53439b281 100644 Binary files a/app/assets/fonts/icons.eot and b/app/assets/fonts/icons.eot differ diff --git a/app/assets/fonts/icons.svg b/app/assets/fonts/icons.svg index 0d94e5751..a0c854397 100644 --- a/app/assets/fonts/icons.svg +++ b/app/assets/fonts/icons.svg @@ -65,4 +65,9 @@ + + + + + diff --git a/app/assets/fonts/icons.ttf b/app/assets/fonts/icons.ttf index 6af0797fb..3bd8e9dec 100644 Binary files a/app/assets/fonts/icons.ttf and b/app/assets/fonts/icons.ttf differ diff --git a/app/assets/fonts/icons.woff b/app/assets/fonts/icons.woff index 7f8f3c95e..0ac7f8f19 100644 Binary files a/app/assets/fonts/icons.woff and b/app/assets/fonts/icons.woff differ diff --git a/app/assets/images/help/help_icon_budgets.png b/app/assets/images/help/help_icon_budgets.png index fc5e3022f..f986a939c 100644 Binary files a/app/assets/images/help/help_icon_budgets.png and b/app/assets/images/help/help_icon_budgets.png differ diff --git a/app/assets/images/help/help_icon_polls.png b/app/assets/images/help/help_icon_polls.png index b7f7cf479..f13363934 100644 Binary files a/app/assets/images/help/help_icon_polls.png and b/app/assets/images/help/help_icon_polls.png differ diff --git a/app/assets/javascripts/polls.js.coffee b/app/assets/javascripts/polls.js.coffee index 5cf792ce2..ac2c759ba 100644 --- a/app/assets/javascripts/polls.js.coffee +++ b/app/assets/javascripts/polls.js.coffee @@ -26,3 +26,19 @@ App.Polls = token_message.html(token_message.html() + "
" + @token + ""); token_message.show() false + + $(".zoom-link").on "click", (event) -> + element = event.target + answer = $(element).closest('div.answer') + + if $(answer).hasClass('medium-6') + $(answer).removeClass("medium-6"); + $(answer).addClass("answer-divider"); + unless $(answer).hasClass('first') + $(answer).insertBefore($(answer).prev('div.answer')); + else + $(answer).addClass("medium-6"); + $(answer).removeClass("answer-divider"); + unless $(answer).hasClass('first') + $(answer).insertAfter($(answer).next('div.answer')); + diff --git a/app/assets/stylesheets/icons.scss b/app/assets/stylesheets/icons.scss index 96eb10a0d..b9f2735b4 100644 --- a/app/assets/stylesheets/icons.scss +++ b/app/assets/stylesheets/icons.scss @@ -268,3 +268,23 @@ .icon-search-minus::before { content: '\35'; } + +.icon-calculator::before { + content: '\36'; +} + +.icon-map-marker::before { + content: '\37'; +} + +.icon-user-plus::before { + content: '\38'; +} + +.icon-file-text-o::before { + content: '\39'; +} + +.icon-file-text::before { + content: '\21'; +} diff --git a/app/controllers/admin/poll/officer_assignments_controller.rb b/app/controllers/admin/poll/officer_assignments_controller.rb index fd62df8b3..7532362a7 100644 --- a/app/controllers/admin/poll/officer_assignments_controller.rb +++ b/app/controllers/admin/poll/officer_assignments_controller.rb @@ -25,7 +25,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::Poll::BaseController def search_officers load_search - @officers = User.joins(:poll_officer).search(@search).order(username: :asc) + + poll_officers = User.where(id: @poll.officers.pluck(:user_id)) + @officers = poll_officers.search(@search).order(username: :asc) respond_to do |format| format.js diff --git a/app/helpers/shifts_helper.rb b/app/helpers/shifts_helper.rb index 5c99bad66..3773014ac 100644 --- a/app/helpers/shifts_helper.rb +++ b/app/helpers/shifts_helper.rb @@ -1,7 +1,7 @@ module ShiftsHelper def shift_vote_collection_dates(polls) - date_options((start_date(polls)..end_date(polls))) + date_options((start_date(polls)..end_date(polls)), Poll::Shift.tasks[:vote_collection]) end def shift_recount_scrutiny_dates(polls) @@ -9,11 +9,15 @@ module ShiftsHelper initial_date = date < Date.current ? Date.current : date total << (initial_date..date + Poll::RECOUNT_DURATION).to_a end - date_options(dates.flatten.uniq) + date_options(dates.flatten.uniq, Poll::Shift.tasks[:recount_scrutiny]) end - def date_options(dates) - dates.map { |date| [l(date, format: :long), l(date)] } + def date_options(dates, task_id) + valid_dates(dates, task_id).map { |date| [l(date, format: :long), l(date)] } + end + + def valid_dates(dates, task_id) + dates.reject { |date| officer_shifts(task_id).include?(date) } end def start_date(polls) @@ -29,4 +33,9 @@ module ShiftsHelper officers.collect { |officer| [officer.name, officer.id] } end + private + + def officer_shifts(task_id) + @officer.shifts.where(task: task_id).map(&:date) + end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 9f8c8c13e..fe1c5f450 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -55,8 +55,4 @@ module WelcomeHelper end end - def highlight_background - (feature?("user.recommendations") && current_user) ? "highlight" : "" - end - end diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 21dc7cffb..f2af2c116 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -136,7 +136,7 @@ <% if feature?(:legislation) %>
  • "> <%= link_to admin_legislation_processes_path do %> - + <%= t("admin.menu.legislation") %> <% end %>
  • @@ -156,7 +156,7 @@
  • - + <%= t("admin.menu.title_site_customization") %>
      "> <%= link_to admin_geozones_path do %> + <%= t('admin.menu.geozones') %> <% end %> @@ -185,6 +186,7 @@ <% if feature?(:signature_sheets) %>
    • "> <%= link_to admin_signature_sheets_path do %> + <%= t("admin.menu.signature_sheets") %> <% end %>
    • diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb index 75493857c..e07487bcf 100644 --- a/app/views/admin/comments/index.html.erb +++ b/app/views/admin/comments/index.html.erb @@ -2,34 +2,46 @@ <%= render 'shared/filter_subnav', i18n_namespace: "admin.comments.index" %> -

      <%= page_entries_info @comments %>

      +<% if @comments.any? %> +

      <%= page_entries_info @comments %>

      - - <% @comments.each do |comment| %> - - - + + <% end %> + +
      - <%= text_with_links comment.body %>
      - <% if comment.commentable.hidden? %> - (<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>) - <% else %> - <%= link_to comment.commentable.title, comment.commentable %> - <% end %> -
      - <%= link_to t("admin.actions.restore"), - restore_admin_comment_path(comment, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow on-hover-block" %> - <% unless comment.confirmed_hide? %> - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_comment_path(comment, request.query_parameters), + + + + + + + <% @comments.each do |comment| %> + + + - - <% end %> -
      <%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
      + <%= text_with_links comment.body %>
      + <% if comment.commentable.hidden? %> + (<%= t("admin.comments.index.hidden_#{comment.commentable_type.downcase}") %>: <%= comment.commentable.title %>) + <% else %> + <%= link_to comment.commentable.title, comment.commentable %> + <% end %> +
      + <%= link_to t("admin.actions.restore"), + restore_admin_comment_path(comment, request.query_parameters), method: :put, - class: "button hollow warning on-hover-block" %> - <% end %> -
      + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> + <% unless comment.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_comment_path(comment, request.query_parameters), + method: :put, + class: "button" %> + <% end %> +
      -<%= paginate @comments %> + <%= paginate @comments %> +<% else %> +
      + <%= t("admin.comments.index.no_hidden_comments") %> +
      +<% end %> diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb index 987aa6e72..7715e1032 100644 --- a/app/views/admin/debates/index.html.erb +++ b/app/views/admin/debates/index.html.erb @@ -2,33 +2,47 @@ <%= render 'shared/filter_subnav', i18n_namespace: "admin.debates.index" %> -

      <%= page_entries_info @debates %>

      +<% if @debates.any? %> +

      <%= page_entries_info @debates %>

      - - <% @debates.each do |debate| %> - - - + + <% end %> + +
      - <%= debate.title %> -
      -
      - <%= debate.description %> -
      -
      - <%= link_to t("admin.actions.restore"), - restore_admin_debate_path(debate, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow on-hover" %> - <% unless debate.confirmed_hide? %> - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_debate_path(debate, request.query_parameters), + + + + + + + + <% @debates.each do |debate| %> + + + + - - <% end %> -
      <%= t("admin.shared.title") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
      + <%= debate.title %> + +
      + <%= debate.description %> +
      +
      + <%= link_to t("admin.actions.restore"), + restore_admin_debate_path(debate, request.query_parameters), method: :put, - class: "button hollow warning on-hover" %> - <% end %> -
      + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> + <% unless debate.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_debate_path(debate, request.query_parameters), + method: :put, + class: "button" %> + <% end %> +
      -<%= paginate @debates %> + <%= paginate @debates %> +<% else %> +
      + <%= t("admin.debates.index.no_hidden_debates") %> +
      +<% end %> diff --git a/app/views/admin/hidden_users/index.html.erb b/app/views/admin/hidden_users/index.html.erb index 21bf016e4..6bcea253c 100644 --- a/app/views/admin/hidden_users/index.html.erb +++ b/app/views/admin/hidden_users/index.html.erb @@ -2,32 +2,42 @@ <%= render 'shared/filter_subnav', i18n_namespace: "admin.hidden_users.index" %> -

      <%= page_entries_info @users %>

      +<% if @users.any? %> +

      <%= page_entries_info @users %>

      - -<% @users.each do |user| %> - - +
      -

      <%= link_to user.name, admin_hidden_user_path(user) %>

      -
      + + + + + + <% @users.each do |user| %> + + - - + + + <% end %> + +
      <%= t("admin.hidden_users.index.user") %><%= t("admin.shared.actions") %>
      +

      <%= link_to user.name, admin_hidden_user_path(user) %>

      +
      - <%= link_to t("admin.actions.restore"), - restore_admin_hidden_user_path(user, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow on-hover" %> - <% unless user.confirmed_hide? %> - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_hidden_user_path(user, request.query_parameters), - method: :put, - class: "button hollow warning on-hover" %> - <% end %> -
      + <%= link_to t("admin.actions.restore"), + restore_admin_hidden_user_path(user, request.query_parameters), + method: :put, + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> + <% unless user.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_hidden_user_path(user, request.query_parameters), + method: :put, + class: "button" %> + <% end %> +
      + + <%= paginate @users %> +<% else %> +
      + <%= t("admin.hidden_users.index.no_hidden_users") %> +
      <% end %> - - -<%= paginate @users %> - - diff --git a/app/views/admin/legislation/processes/_subnav.html.erb b/app/views/admin/legislation/processes/_subnav.html.erb index 97640c4f4..f8e9bba56 100644 --- a/app/views/admin/legislation/processes/_subnav.html.erb +++ b/app/views/admin/legislation/processes/_subnav.html.erb @@ -1,11 +1,31 @@ diff --git a/app/views/admin/poll/officer_assignments/index.html.erb b/app/views/admin/poll/officer_assignments/index.html.erb index f27f6b2ae..04e296980 100644 --- a/app/views/admin/poll/officer_assignments/index.html.erb +++ b/app/views/admin/poll/officer_assignments/index.html.erb @@ -11,7 +11,7 @@ <%= t("admin.poll_officer_assignments.index.no_officers") %> <% else %> - +
      diff --git a/app/views/admin/poll/polls/index.html.erb b/app/views/admin/poll/polls/index.html.erb index 791ec4876..487f0fa54 100644 --- a/app/views/admin/poll/polls/index.html.erb +++ b/app/views/admin/poll/polls/index.html.erb @@ -7,7 +7,7 @@ <% if @polls.any? %>
      <%= t("admin.poll_officer_assignments.index.table_name") %> <%= t("admin.poll_officer_assignments.index.table_email") %>
      - + diff --git a/app/views/admin/poll/shifts/new.html.erb b/app/views/admin/poll/shifts/new.html.erb index b975c40a9..4e0665ea2 100644 --- a/app/views/admin/poll/shifts/new.html.erb +++ b/app/views/admin/poll/shifts/new.html.erb @@ -1,4 +1,4 @@ -<%= back_link_to admin_booths_path %> +<%= back_link_to available_admin_booths_path %>

      <%= @booth.name %>

      diff --git a/app/views/admin/proposals/index.html.erb b/app/views/admin/proposals/index.html.erb index d929843b1..ba161ce77 100644 --- a/app/views/admin/proposals/index.html.erb +++ b/app/views/admin/proposals/index.html.erb @@ -2,41 +2,55 @@ <%= render 'shared/filter_subnav', i18n_namespace: "admin.proposals.index" %> -

      <%= page_entries_info @proposals %>

      +<% if @proposals.any? %> +

      <%= page_entries_info @proposals %>

      -
      <%= t("admin.polls.index.name") %><%= t("admin.polls.index.name") %> <%= t("admin.polls.index.dates") %> <%= t("admin.actions.actions") %>
      - <% @proposals.each do |proposal| %> - - - + + <% end %> + +
      - <%= proposal.title %> -
      -
      -

      <%= proposal.summary %>

      - <%= proposal.description %> - <% if proposal.external_url.present? %> -

      <%= text_with_links proposal.external_url %>

      - <% end %> - <% if proposal.video_url.present? %> -

      <%= text_with_links proposal.video_url %>

      - <% end %> -

      <%= proposal.question %>

      -
      -
      - <%= link_to t("admin.actions.restore"), - restore_admin_proposal_path(proposal, request.query_parameters), - method: :put, - data: { confirm: t("admin.actions.confirm") }, - class: "button hollow on-hover-block" %> - <% unless proposal.confirmed_hide? %> - <%= link_to t("admin.actions.confirm_hide"), - confirm_hide_admin_proposal_path(proposal, request.query_parameters), + + + + + + + + <% @proposals.each do |proposal| %> + + + + - - <% end %> -
      <%= t("admin.shared.title") %><%= t("admin.shared.description") %><%= t("admin.shared.actions") %>
      + <%= proposal.title %> + +
      +

      <%= proposal.summary %>

      + <%= proposal.description %> + <% if proposal.external_url.present? %> +

      <%= text_with_links proposal.external_url %>

      + <% end %> + <% if proposal.video_url.present? %> +

      <%= text_with_links proposal.video_url %>

      + <% end %> +

      <%= proposal.question %>

      +
      +
      + <%= link_to t("admin.actions.restore"), + restore_admin_proposal_path(proposal, request.query_parameters), method: :put, - class: "button hollow warning on-hover-block" %> - <% end %> -
      + data: { confirm: t("admin.actions.confirm") }, + class: "button hollow warning" %> + <% unless proposal.confirmed_hide? %> + <%= link_to t("admin.actions.confirm_hide"), + confirm_hide_admin_proposal_path(proposal, request.query_parameters), + method: :put, + class: "button" %> + <% end %> +
      -<%= paginate @proposals %> + <%= paginate @proposals %> +<% else %> +
      + <%= t("admin.proposals.index.no_hidden_proposals") %> +
      +<% end %> diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb index f22321f38..55e51a8ac 100644 --- a/app/views/admin/tags/index.html.erb +++ b/app/views/admin/tags/index.html.erb @@ -1,39 +1,40 @@

      <%= t("admin.tags.index.add_tag") %>

      <%= form_for(@tag, url: admin_tags_path, as: :tag) do |f| %> - -
      -
      - <%= f.label :name, t("admin.tags.name.placeholder") %> - <%= f.text_field :name, placeholder: t("admin.tags.name.placeholder"), label: false %> -
      - +
      + <%= f.label :name, t("admin.tags.name.placeholder") %> + <%= f.text_field :name, placeholder: t("admin.tags.name.placeholder"), label: false %>
      <%= f.submit(t("admin.tags.create"), class: "button success") %> - <% end %> -

      <%= t("admin.tags.index.title") %>: <%= page_entries_info @tags %>

      +
      +

      <%= t("admin.tags.index.title") %>: <%= page_entries_info @tags %>

      + + + + + <% @tags.each do |tag| %> - + <% end %> +
      <%= t("admin.tags.index.topic") %><%= t("admin.actions.actions") %>
      + <%= form_for(tag, url: admin_tag_path(tag), as: :tag, - html: { id: "edit_tag_#{tag.id}", class: "text-right"}) do |f| %> + html: { id: "edit_tag_#{tag.id}"}) do |f| %> - - <%= tag.name %> - - - <%= link_to t("admin.tags.destroy"), admin_tag_path(tag), method: :delete, class: "button hollow alert on-hover" %> + <%= tag.name %> <% end %> + <%= link_to t("admin.tags.destroy"), admin_tag_path(tag), method: :delete, class: "button hollow alert" %> +
      <%= paginate @tags %> diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index 0a56ba237..4489cd226 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -80,8 +80,7 @@
      <% @poll_questions_answers.each do |answer| %> -
      +
      <% if answer.description.present? %>

      <%= answer.title %>

      diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 0ea0f748d..e27f4436e 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -22,12 +22,12 @@ <%= render "recommended", recommended_debates: @recommended_debates, recommended_proposals: @recommended_proposals %> +
      <% end %> <% cache [locale_and_user_status, @featured_debates, @featured_proposals, 'featured'] do %>
      - -
      +

      <%= t("welcome.debates.title") %>

      @@ -47,6 +47,5 @@
      -
      <% end %> diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index dfe92305d..87bbb6685 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -213,6 +213,7 @@ en: hidden_debate: Hidden debate hidden_proposal: Hidden proposal title: Hidden comments + no_hidden_comments: There is no hidden comments. dashboard: index: back: Go back to %{org} @@ -226,6 +227,7 @@ en: with_confirmed_hide: Confirmed without_confirmed_hide: Pending title: Hidden debates + no_hidden_debates: There is no hidden debates. hidden_users: index: filter: Filter @@ -234,6 +236,8 @@ en: with_confirmed_hide: Confirmed without_confirmed_hide: Pending title: Hidden users + user: User + no_hidden_users: There is no hidden users. show: email: 'Email:' hidden_at: 'Hidden at:' @@ -715,6 +719,7 @@ en: with_confirmed_hide: Confirmed without_confirmed_hide: Pending title: Hidden proposals + no_hidden_proposals: There is no hidden proposals. settings: flash: updated: Value updated @@ -757,6 +762,9 @@ en: placeholder: Search user by name or email search_results: "Search results" no_search_results: "No results found." + actions: Actions + title: Title + description: Description spending_proposals: index: geozone_filter_all: All zones @@ -901,11 +909,12 @@ en: total: Total proposals_with_notifications: Proposals with notifications tags: - create: Create Topic - destroy: Destroy Topic + create: Create topic + destroy: Destroy topic index: add_tag: Add a new proposal topic title: Proposal topics + topic: Topic name: placeholder: Type the name of the topic users: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 289546bab..d1a24b314 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -213,6 +213,7 @@ es: hidden_debate: Debate oculto hidden_proposal: Propuesta oculta title: Comentarios ocultos + no_hidden_comments: No hay comentarios ocultos. dashboard: index: back: Volver a %{org} @@ -226,6 +227,7 @@ es: with_confirmed_hide: Confirmados without_confirmed_hide: Pendientes title: Debates ocultos + no_hidden_debates: No hay debates ocultos. hidden_users: index: filter: Filtro @@ -234,6 +236,8 @@ es: with_confirmed_hide: Confirmados without_confirmed_hide: Pendientes title: Usuarios bloqueados + user: Usuario + no_hidden_users: No hay uusarios bloqueados. show: email: 'Email:' hidden_at: 'Bloqueado:' @@ -717,6 +721,7 @@ es: with_confirmed_hide: Confirmadas without_confirmed_hide: Pendientes title: Propuestas ocultas + no_hidden_proposals: No hay propuestas ocultas. settings: flash: updated: Valor actualizado @@ -759,6 +764,9 @@ es: placeholder: Buscar usuario por nombre o email search_results: "Resultados de la búsqueda" no_search_results: "No se han encontrado resultados." + actions: Acciones + title: "Título" + description: "Descripción" spending_proposals: index: geozone_filter_all: Todos los ámbitos de actuación @@ -903,11 +911,12 @@ es: total: Total proposals_with_notifications: Propuestas con notificaciones tags: - create: Crear Tema - destroy: Eliminar Tema + create: Crear tema + destroy: Eliminar tema index: add_tag: Añade un nuevo tema de propuesta title: Temas de propuesta + topic: Tema name: placeholder: Escribe el nombre del tema users: diff --git a/spec/factories.rb b/spec/factories.rb index b1c5ff329..ed1d24fd6 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -536,6 +536,14 @@ FactoryGirl.define do association :booth, factory: :poll_booth association :officer, factory: :poll_officer date Date.current + + trait :vote_collection_task do + task 0 + end + + trait :recount_scrutiny_task do + task 1 + end end factory :poll_voter, class: 'Poll::Voter' do diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index 4eeb81cb6..1aa487b26 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -113,4 +113,18 @@ feature 'Admin booths' do end end + scenario "Back link go back to available list when manage shifts" do + poll = create(:poll, :current) + booth = create(:poll_booth) + assignment = create(:poll_booth_assignment, poll: poll, booth: booth) + + visit available_admin_booths_path + + within("#booth_#{booth.id}") do + click_link "Manage shifts" + end + + click_link "Go back" + expect(current_path).to eq(available_admin_booths_path) + end end diff --git a/spec/features/admin/poll/officer_assignments_spec.rb b/spec/features/admin/poll/officer_assignments_spec.rb new file mode 100644 index 000000000..20be138b9 --- /dev/null +++ b/spec/features/admin/poll/officer_assignments_spec.rb @@ -0,0 +1,68 @@ +require 'rails_helper' + +feature 'Officer Assignments' do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + scenario "Index" do + poll = create(:poll) + booth = create(:poll_booth) + + officer1 = create(:poll_officer) + officer2 = create(:poll_officer) + officer3 = create(:poll_officer) + + booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) + officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer1) + + booth_assignment_2 = create(:poll_booth_assignment, poll: poll) + officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer2) + + visit admin_poll_path(poll) + + click_link 'Officers (2)' + + within('#officer_assignments') do + expect(page).to have_content officer1.name + expect(page).to have_content officer2.name + expect(page).to_not have_content officer3.name + end + end + + scenario "Search", :js do + poll = create(:poll) + booth = create(:poll_booth) + + user1 = create(:user, username: "John Snow") + user2 = create(:user, username: "John Silver") + user3 = create(:user, username: "John Edwards") + + officer1 = create(:poll_officer, user: user1) + officer2 = create(:poll_officer, user: user2) + officer3 = create(:poll_officer, user: user3) + + booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) + officer_assignment = create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer1) + + booth_assignment_2 = create(:poll_booth_assignment, poll: poll) + officer_assignment_2 = create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer2) + + visit admin_poll_path(poll) + + click_link 'Officers (2)' + + fill_in "search-officers", with: "John" + click_button "Search" + + within('#search-officers-results') do + expect(page).to have_content officer1.name + expect(page).to have_content officer2.name + expect(page).to_not have_content officer3.name + end + end + + +end \ No newline at end of file diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index 7512d8b6d..6f027fad3 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -92,6 +92,37 @@ feature 'Admin shifts' do end end + scenario "Vote Collection Shift and Recount & Scrutiny Shift don't include already assigned dates to officer", :js do + poll = create(:poll, :current) + booth = create(:poll_booth) + assignment = create(:poll_booth_assignment, poll: poll, booth: booth) + officer = create(:poll_officer) + + shift1 = create(:poll_shift, :vote_collection_task, officer: officer, booth: booth, date: Time.zone.today) + shift2 = create(:poll_shift, :recount_scrutiny_task, officer: officer, booth: booth, date: Time.zone.tomorrow) + + vote_collection_dates = (poll.starts_at.to_date..poll.ends_at.to_date).to_a + .reject { |date| date == Time.zone.today } + .map { |date| I18n.l(date, format: :long) } + recount_scrutiny_dates = (poll.ends_at.to_date..poll.ends_at.to_date + 1.week).to_a + .reject { |date| date == Time.zone.tomorrow } + .map { |date| I18n.l(date, format: :long) } + + visit available_admin_booths_path + + within("#booth_#{booth.id}") do + click_link "Manage shifts" + end + + fill_in "search", with: officer.email + click_button "Search" + click_link "Edit shifts" + + expect(page).to have_select('shift_date_vote_collection_date', options: ["Select day", *vote_collection_dates]) + select "Recount & Scrutiny", from: 'shift_task' + expect(page).to have_select('shift_date_recount_scrutiny_date', options: ["Select day", *recount_scrutiny_dates]) + end + scenario "Error on create", :js do poll = create(:poll, :current) booth = create(:poll_booth) diff --git a/spec/features/admin/tags_spec.rb b/spec/features/admin/tags_spec.rb index dd9c38c6b..8ff205852 100644 --- a/spec/features/admin/tags_spec.rb +++ b/spec/features/admin/tags_spec.rb @@ -23,7 +23,7 @@ feature 'Admin tags' do within("form.new_tag") do fill_in "tag_name", with: 'important issues' - click_button 'Create Topic' + click_button 'Create topic' end visit admin_tags_path @@ -39,8 +39,8 @@ feature 'Admin tags' do expect(page).to have_content @tag1.name expect(page).to have_content tag2.name - within("#edit_tag_#{tag2.id}") do - click_link 'Destroy Topic' + within("#tag_#{tag2.id}") do + click_link 'Destroy topic' end visit admin_tags_path @@ -58,8 +58,8 @@ feature 'Admin tags' do expect(page).to have_content @tag1.name expect(page).to have_content tag2.name - within("#edit_tag_#{tag2.id}") do - click_link 'Destroy Topic' + within("#tag_#{tag2.id}") do + click_link 'Destroy topic' end visit admin_tags_path @@ -81,7 +81,7 @@ feature 'Admin tags' do within("form.new_tag") do fill_in "tag_name", with: "wow_category" - click_button 'Create Topic' + click_button 'Create topic' end expect(ActsAsTaggableOn::Tag.category.where(name: "wow_category")).to exist