diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 863f8769c..23544e8b2 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -6,6 +6,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController before_action :load_geozones, only: [:new, :create, :edit, :update] def index + @polls = Poll.order(starts_at: :desc) end def show diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb index 712a411bd..0c42738db 100644 --- a/app/views/admin/poll/polls/_poll.html.erb +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -4,19 +4,19 @@ <%= link_to poll.name, admin_poll_path(poll) %> -
| <%= t("admin.polls.index.name") %> | -<%= t("admin.polls.index.dates") %> | +<%= t("admin.polls.index.name") %> | +<%= t("admin.polls.index.start_date") %> | +<%= t("admin.polls.index.closing_date") %> | <%= t("admin.actions.actions") %> | diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 08f53bb5c..b4f004fff 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -921,6 +921,8 @@ en: create: "Create poll" name: "Name" dates: "Dates" + start_date: "Start Date" + closing_date: "Closing Date" geozone_restricted: "Restricted to districts" new: title: "New poll" diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 327001e9c..e203c8a56 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -921,6 +921,8 @@ es: create: "Crear votación" name: "Nombre" dates: "Fechas" + start_date: "Fecha de apertura" + closing_date: "Fecha de cierre" geozone_restricted: "Restringida a los distritos" new: title: "Nueva votación" diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index f5071314c..9fb533ed5 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -23,13 +23,15 @@ feature 'Admin polls' do expect(page).to have_content "There are no polls" end - scenario 'Index', :js do - 3.times { create(:poll) } + scenario "Index show polls list order by starts at date", :js do + poll_1 = create(:poll, name: "Poll first", starts_at: 15.days.ago) + poll_2 = create(:poll, name: "Poll second", starts_at: 1.month.ago) + poll_3 = create(:poll, name: "Poll third", starts_at: 2.days.ago) visit admin_root_path click_link "Polls" - within('#polls_menu') do + within("#polls_menu") do click_link "Polls" end @@ -42,6 +44,9 @@ feature 'Admin polls' do expect(page).to have_content poll.name end end + + expect(poll_3.name).to appear_before(poll_1.name) + expect(poll_1.name).to appear_before(poll_2.name) expect(page).not_to have_content "There are no polls" end
|---|