Adds missing validation to poll::question. Fixes specs
This commit is contained in:
@@ -54,7 +54,7 @@ class Admin::Poll::QuestionsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def question_params
|
def question_params
|
||||||
params.require(:poll_question).permit(:title, :question, :summary, :description, :proposal_id, :valid_answers)
|
params.require(:poll_question).permit(:poll_id, :title, :question, :summary, :description, :proposal_id, :valid_answers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def search_params
|
def search_params
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Poll::Question < ActiveRecord::Base
|
|||||||
has_many :partial_results
|
has_many :partial_results
|
||||||
belongs_to :proposal
|
belongs_to :proposal
|
||||||
|
|
||||||
|
validates :poll_id, presence: true
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :summary, presence: true
|
validates :summary, presence: true
|
||||||
validates :author, presence: true
|
validates :author, presence: true
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ feature 'Admin poll questions' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Create' do
|
scenario 'Create' do
|
||||||
|
poll = create(:poll, name: 'Movies')
|
||||||
title = "Star Wars: Episode IV - A New Hope"
|
title = "Star Wars: Episode IV - A New Hope"
|
||||||
summary = "It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire"
|
summary = "It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire"
|
||||||
description = %{
|
description = %{
|
||||||
@@ -41,6 +42,7 @@ feature 'Admin poll questions' do
|
|||||||
visit admin_questions_path
|
visit admin_questions_path
|
||||||
click_link "Create question"
|
click_link "Create question"
|
||||||
|
|
||||||
|
select 'Movies', from: 'poll_question_poll_id'
|
||||||
fill_in 'poll_question_title', with: title
|
fill_in 'poll_question_title', with: title
|
||||||
fill_in 'poll_question_summary', with: summary
|
fill_in 'poll_question_summary', with: summary
|
||||||
fill_in 'poll_question_description', with: description
|
fill_in 'poll_question_description', with: description
|
||||||
@@ -53,6 +55,7 @@ feature 'Admin poll questions' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Create from successful proposal index' do
|
scenario 'Create from successful proposal index' do
|
||||||
|
poll = create(:poll, name: 'Proposals')
|
||||||
proposal = create(:proposal, :successful)
|
proposal = create(:proposal, :successful)
|
||||||
|
|
||||||
visit proposals_path
|
visit proposals_path
|
||||||
@@ -64,6 +67,8 @@ feature 'Admin poll questions' do
|
|||||||
expect(page).to have_field('poll_question_description', with: proposal.description)
|
expect(page).to have_field('poll_question_description', with: proposal.description)
|
||||||
expect(page).to have_field('poll_question_valid_answers', with: "Yes, No")
|
expect(page).to have_field('poll_question_valid_answers', with: "Yes, No")
|
||||||
|
|
||||||
|
select 'Proposals', from: 'poll_question_poll_id'
|
||||||
|
|
||||||
click_button 'Save'
|
click_button 'Save'
|
||||||
|
|
||||||
expect(page).to have_content(proposal.title)
|
expect(page).to have_content(proposal.title)
|
||||||
|
|||||||
Reference in New Issue
Block a user