diff --git a/app/models/poll.rb b/app/models/poll.rb index 4543a2544..11ac6ccb8 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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 \ No newline at end of file +end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index b8815cf2d..75f78fb15 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -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 diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index 01749b19a..e9eeb7ca2 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -1 +1,5 @@ <%= @poll.name %> + +<%= @poll.questions.sort_for_list.each do |question| %> + <%= question.title %> +<% end %> diff --git a/spec/features/polls_spec.rb b/spec/features/polls_spec.rb index d3c101ed8..a873c22f4 100644 --- a/spec/features/polls_spec.rb +++ b/spec/features/polls_spec.rb @@ -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