osem-fcy/spec/features/surveys_spec.rb

56 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
feature Survey do
let(:conference) { create(:conference) }
context 'as an organizer' do
let(:organizer) { create(:organizer, resource: conference) }
before :each do
sign_in organizer
end
scenario 'create a survey', feature: true, js: true do
visit admin_conference_path(conference)
click_link 'Surveys'
click_link 'New'
fill_in 'Title', with: 'Example Survey'
click_button 'Create Survey'
within('#flash') { expect(page).to have_text('Successfully created survey') }
fill_in :survey_question_title, with: 'Example question'
select 'boolean', from: 'Type of Question:', visible: false # Hidden by bootstrap-select
click_button 'Create Survey question'
within('#flash') { expect(page).to have_text('Successfully created Survey Question.') }
end
end
context 'as an attendee' do
let(:attendee) { create(:user) }
before :each do
sign_in attendee
end
scenario 'respond to a survey during registration', feature: true, js: true do
create :registration_period, conference: conference
create :registration, conference: conference, user: attendee
survey = create(:survey, surveyable: conference, target: :during_registration)
create :boolean_mandatory, survey: survey
visit conference_conference_registration_path(conference)
2022-05-18 06:31:12 +02:00
expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Please fill out the survey')
click_link survey.title
choose 'Yes'
click_button 'Submit'
within('#flash') { expect(page).to have_text('Successfully responded to survey.') }
visit conference_conference_registration_path(conference)
2022-05-18 06:31:12 +02:00
expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Thank you for filling out the survey')
end
end
end