Starts introducing valid answers to poll questions

This commit is contained in:
kikito
2016-10-31 16:31:48 +01:00
parent 1aab780592
commit 575aa62960
4 changed files with 17 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ class PollsController < ApplicationController
end
def show
@questions = @poll.questions.sort_for_list.for_render
end
end

View File

@@ -23,6 +23,7 @@ class Poll::Question < ActiveRecord::Base
scope :sort_for_list, -> { order('proposal_id IS NULL', :created_at)}
scope :for_render, -> { includes(:author, :proposal) }
scope :by_geozone, -> (geozone_id) { joins(:geozones).where(geozones: {id: geozone_id}) }
def description
super.try :html_safe
@@ -45,4 +46,6 @@ class Poll::Question < ActiveRecord::Base
end
end
end

View File

@@ -1,5 +1,10 @@
<%= @poll.name %>
<%= @poll.questions.sort_for_list.each do |question| %>
<% @questions.each do |question| %>
<div id="<%= dom_id(question) %>">
<%= question.title %>
<%= question.valid_answers.each do |valid_answer| %>
<%= link_to valid_answer %>
<% end %>
</div>
<% end %>

View File

@@ -21,7 +21,12 @@ feature 'Polls' do
expect(page).to have_content(poll.name)
questions.each do |question|
within("#poll_question_#{question.id}") do
expect(page).to have_content(question.title)
question.valid_answers.each do |answer|
expect(page).to have_link(answer)
end
end
end
end
end