Starts introducing valid answers to poll questions
This commit is contained in:
@@ -7,7 +7,7 @@ class PollsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@questions = @poll.questions.sort_for_list.for_render
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user