First version of Polls Controller
This commit is contained in:
13
app/controllers/polls_controller.rb
Normal file
13
app/controllers/polls_controller.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class PollsController < ApplicationController
|
||||||
|
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -6,6 +6,7 @@ module Abilities
|
|||||||
can [:read, :map], Debate
|
can [:read, :map], Debate
|
||||||
can [:read, :map, :summary], Proposal
|
can [:read, :map, :summary], Proposal
|
||||||
can :read, Comment
|
can :read, Comment
|
||||||
|
can :read, Poll
|
||||||
can :read, SpendingProposal
|
can :read, SpendingProposal
|
||||||
can :read, Legislation
|
can :read, Legislation
|
||||||
can :read, User
|
can :read, User
|
||||||
|
|||||||
3
app/views/polls/index.html.erb
Normal file
3
app/views/polls/index.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<% @polls.each do |poll| %>
|
||||||
|
<%= link_to poll.name, poll %>
|
||||||
|
<% end %>
|
||||||
1
app/views/polls/show.html.erb
Normal file
1
app/views/polls/show.html.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<%= @poll.name %>
|
||||||
@@ -85,6 +85,10 @@ Rails.application.routes.draw do
|
|||||||
get :search, on: :collection
|
get :search, on: :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :polls, only: [:show, :index] do
|
||||||
|
resources :questions, only: [:show, :index]
|
||||||
|
end
|
||||||
|
|
||||||
resources :users, only: [:show] do
|
resources :users, only: [:show] do
|
||||||
resources :direct_messages, only: [:new, :create, :show]
|
resources :direct_messages, only: [:new, :create, :show]
|
||||||
end
|
end
|
||||||
|
|||||||
22
spec/features/polls_spec.rb
Normal file
22
spec/features/polls_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Polls' do
|
||||||
|
|
||||||
|
scenario 'Polls can be listed' do
|
||||||
|
polls = create_list(:poll, 3)
|
||||||
|
|
||||||
|
visit polls_path
|
||||||
|
|
||||||
|
polls.each do |poll|
|
||||||
|
expect(page).to have_link(poll.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Polls can be seen' do
|
||||||
|
poll = create(:poll)
|
||||||
|
visit poll_path(poll)
|
||||||
|
expect(page).to have_content(poll.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Reference in New Issue
Block a user