From 304743f64e712042b0b299c18338bce5a43d237d Mon Sep 17 00:00:00 2001 From: rgarcia Date: Fri, 23 Sep 2016 09:13:02 +0200 Subject: [PATCH] tmp commit poll index, show and new --- .../admin/poll/polls_controller.rb | 2 +- app/models/abilities/administrator.rb | 2 + app/views/admin/poll/polls/_poll.html.erb | 16 ++++++++ app/views/admin/poll/polls/index.html.erb | 17 +------- app/views/admin/poll/polls/show.html.erb | 6 ++- spec/features/admin/poll/polls_spec.rb | 40 +++++++++++++++++++ 6 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 app/views/admin/poll/polls/_poll.html.erb create mode 100644 spec/features/admin/poll/polls_spec.rb diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index b90fd2c11..eb8b417b8 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -1,5 +1,5 @@ class Admin::Poll::PollsController < Admin::BaseController - skip_authorization_check + load_and_authorize_resource def index end diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 0f1100137..bd74e1be9 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -40,6 +40,8 @@ module Abilities can [:search, :create, :index, :destroy], ::Manager can [:search, :create, :index, :destroy], ::Poll::Officer + can [:manage], Poll + can :manage, Annotation can [:read, :update, :destroy, :summary], SpendingProposal diff --git a/app/views/admin/poll/polls/_poll.html.erb b/app/views/admin/poll/polls/_poll.html.erb new file mode 100644 index 000000000..a9f2dcd1b --- /dev/null +++ b/app/views/admin/poll/polls/_poll.html.erb @@ -0,0 +1,16 @@ + + + + <%= link_to poll.name, admin_poll_path(poll) %> + ß + + + Próximamente +
(15/12/2016 - 15/02/2017) + + + <%= link_to t("admin.actions.edit"), + edit_admin_poll_path(poll), + class: "button hollow" %> + + \ No newline at end of file diff --git a/app/views/admin/poll/polls/index.html.erb b/app/views/admin/poll/polls/index.html.erb index c260ab255..b24cc10f6 100644 --- a/app/views/admin/poll/polls/index.html.erb +++ b/app/views/admin/poll/polls/index.html.erb @@ -16,21 +16,6 @@   - - - - - <%= link_to "Votación de propuestas 2016 (REFNUM)", "polls/3" %> - - - - Próximamente -
(15/12/2016 - 15/02/2017) - - - <%= link_to t("admin.actions.edit"), "polls/3/edit", class: "button hollow" %> - - - + <%= render @polls %> diff --git a/app/views/admin/poll/polls/show.html.erb b/app/views/admin/poll/polls/show.html.erb index 9b4971214..105cf2fe6 100644 --- a/app/views/admin/poll/polls/show.html.erb +++ b/app/views/admin/poll/polls/show.html.erb @@ -1,8 +1,12 @@ <%= render "shared/back_link" %>
-

Votación de propuestas 2016

+

+ <%= @poll.name %> +

+ <%= link_to t("admin.actions.edit"), "#", class: "button hollow float-right" %> +

(REFNUM)

Próximamente (15/12/2016 - 15/02/2017)

<%= link_to t("admin.polls.show.add_booth"), "#", class: "button success" %> diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb new file mode 100644 index 000000000..a94c81cc9 --- /dev/null +++ b/spec/features/admin/poll/polls_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +feature 'Admin polls' do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + scenario 'Index' do + 3.times { create(:poll) } + + visit admin_root_path + + within('#side_menu') do + click_link "Polls" + end + + expect(page).to have_css ".poll", count: 3 + + Poll.all.each do |poll| + within("#poll_#{poll.id}") do + expect(page).to have_content poll.name +#expect(page).to have_content "Status/Dates" - Hardcoded + end + end + end + + scenario 'Show', :focus do + poll = create(:poll) + + visit admin_polls_path + click_link poll.name + + expect(page).to have_content poll.name +#expect(page).to have_content "Status/Dates" - Hardcoded +#expect(page).to have_content "REFNUM" - Hardcoded + end + +end \ No newline at end of file