diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b4637d3e69..d06f5c594f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -442,7 +442,7 @@ Metrics/BlockNesting: # Offense count: 14 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 652 + Max: 655 # Offense count: 29 # Configuration parameters: IgnoredMethods. diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 692b4db01a..88ca22aed4 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -12,6 +12,7 @@ def index @event = @program.events.new @event.event_users.new(user: current_user, event_role: 'submitter') @events = current_user.proposals(@conference) + @surveys = @conference.surveys.during_proposal.select(&:active?) end def show diff --git a/app/models/conference.rb b/app/models/conference.rb index cac3a84932..58b6fe6013 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -57,6 +57,10 @@ class Conference < ApplicationRecord has_many :event_types, through: :program has_many :surveys, as: :surveyable, dependent: :destroy do + def during_proposal + where(target: targets[:during_proposal]) + end + def for_registration where(target: targets[:during_registration]) end diff --git a/app/models/survey.rb b/app/models/survey.rb index 66783e90df..ccc5f42329 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -5,7 +5,7 @@ class Survey < ActiveRecord::Base has_many :survey_questions, dependent: :destroy has_many :survey_submissions, dependent: :destroy - enum target: [:after_conference, :during_registration, :after_event] + enum target: [:after_conference, :during_registration, :after_event, :during_proposal] validates :title, presence: true ## diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index cf57c6444b..961c536876 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -117,3 +117,10 @@ .col-md-12 - if can? :create, @event = link_to "New Proposal", new_conference_program_proposal_path(@conference.short_title), class: 'btn btn-success pull-right' + + - if @surveys.any? + .row + .col-md-12 + %h2 Surveys + + = render partial: 'surveys/list', locals: { surveys: @surveys, conference: @conference } diff --git a/spec/features/surveys_spec.rb b/spec/features/surveys_spec.rb index 52f8b40d90..98fcc493ed 100644 --- a/spec/features/surveys_spec.rb +++ b/spec/features/surveys_spec.rb @@ -52,4 +52,30 @@ expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Thank you for filling out the survey') end end + + context 'as a speaker' do + let(:speaker) { create(:user) } + + before :each do + sign_in speaker + end + + scenario 'respond to a survey during proposal submission', feature: true, js: true do + create :cfp, program: conference.program + create :event, program: conference.program, submitter: speaker + survey = create(:survey, surveyable: conference, target: :during_proposal) + create :boolean_mandatory, survey: survey + + visit conference_program_proposals_path(conference.short_title) + 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' + expect(flash).to eq('Successfully responded to survey.') + + visit conference_program_proposals_path(conference.short_title) + expect(find(:link, survey.title).sibling('.fa-solid')[:title]).to eq('Thank you for filling out the survey') + end + end end