Questions: fixes, redesign form, fix edit error

This commit is contained in:
Stella Rouzi 2015-09-10 12:39:52 +03:00
parent 38bc2e3c3a
commit e25425bd77
20 changed files with 300 additions and 117 deletions

View file

@ -0,0 +1,26 @@
require 'spec_helper'
describe Admin::QuestionsController do
let!(:conference) { create(:conference) }
let!(:question_with_answers) { create(:question_with_answers) }
let!(:question_without_answers) { create(:question) }
let(:organizer) { create(:organizer) }
describe 'PATCH #update_conference' do
before(:each) do
sign_in(organizer)
end
it 'enables a question for a conference if the question has answers' do
patch :toggle_question, conference_id: conference.short_title, id: question_with_answers, enable: 'true'
conference.reload
expect(conference.question_ids).to eq([question_with_answers.id])
expect(conference.question_ids).to_not include([question_without_answers.id])
expect(flash[:notice]).to eq("Questions for #{conference.short_title} successfully updated. Note: Only questions with answers can be enabled for a conference.")
expect(response).to redirect_to admin_conference_questions_path(conference.short_title)
end
end
end