Starts adding questions to polls
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
<%= @poll.name %>
|
||||
|
||||
<%= @poll.questions.sort_for_list.each do |question| %>
|
||||
<%= question.title %>
|
||||
<% end %>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user