Starts adding questions to polls

This commit is contained in:
kikito
2016-10-31 14:27:25 +01:00
parent 3eca3faacd
commit 1aab780592
4 changed files with 13 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
class Poll < ActiveRecord::Base
has_many :booths
has_many :voters, through: :booths, class_name: "Poll::Voter"
has_many :questions
validates :name, presence: true
end
end

View File

@@ -4,6 +4,7 @@ class Poll::Question < ActiveRecord::Base
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases
belongs_to :poll
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
has_many :comments, as: :commentable

View File

@@ -1 +1,5 @@
<%= @poll.name %>
<%= @poll.questions.sort_for_list.each do |question| %>
<%= question.title %>
<% end %>

View File

@@ -15,8 +15,14 @@ feature 'Polls' do
scenario 'Polls can be seen' do
poll = create(:poll)
questions = create_list(:poll_question, 5, poll: poll)
visit poll_path(poll)
expect(page).to have_content(poll.name)
questions.each do |question|
expect(page).to have_content(question.title)
end
end
end