From 611716bbd36397a93e5c0ecfeb48f383925f6a06 Mon Sep 17 00:00:00 2001 From: Godwin Date: Mon, 4 Sep 2017 14:10:55 -0700 Subject: [PATCH] Added post-conference survey --- app/assets/stylesheets/_application.scss | 232 ++++++++++++++++-- app/controllers/conferences_controller.rb | 51 +++- app/controllers/workshops_controller.rb | 4 +- app/helpers/form_helper.rb | 2 +- .../application/permission_denied.html.haml | 10 +- app/views/conferences/_conference.html.haml | 8 +- app/views/conferences/survey.html.haml | 70 ++++++ .../registration_steps/_review.html.haml | 34 ++- config/locales/en.yml | 52 ++++ db/schema.rb | 1 - features/registration.feature | 7 + features/step_definitions/interface_steps.rb | 15 +- features/step_definitions/registration.rb | 46 +--- features/support/paths.rb | 4 +- features/survey.feature | 44 ++++ 15 files changed, 481 insertions(+), 99 deletions(-) create mode 100644 app/views/conferences/survey.html.haml create mode 100644 features/survey.feature diff --git a/app/assets/stylesheets/_application.scss b/app/assets/stylesheets/_application.scss index 255e23b..986e6ed 100644 --- a/app/assets/stylesheets/_application.scss +++ b/app/assets/stylesheets/_application.scss @@ -80,31 +80,6 @@ a { cursor: pointer; text-decoration-skip: ink; @include link; - // border-bottom: 0 solid; - // position: relative; - - // @include after { - // content: ''; - // position: absolute; - // border-bottom: 0 solid; - // right: 0; - // bottom: 0; - // left: 0; - // opacity: 0; - // @include _(transition, all 150ms ease-in-out); - // @include _(transform-origin, 25% 50%); - // @include _(transform, scaleX(0)); - // } - - // &:hover, - // &:active, - // &:focus { - // @include after { - // border-bottom: 0.1em solid; - // opacity: 1; - // @include _(transform, scaleX(1)); - // } - // } } .target:target { @@ -121,6 +96,10 @@ a { position: absolute !important; } +.medium-up { + display: none; +} + table, .table { margin-bottom: 2em; margin-left: 1em; @@ -2349,6 +2328,19 @@ a.logo { font-size: 0.75em; margin: 0.5em 0 0; } + + .access-registration { + display: inline-block; + font-size: 0.85em; + color: $mid-gray; + margin: 0.5em 1em; + text-align: right; + right: 0; + + a { + display: block; + } + } } .help-link { @@ -3340,7 +3332,151 @@ body.policy .policy-agreement ul { } } +#main ol.survey { + counter-reset: survey-question; + list-style: none; + padding: 0 1em; + $item-color: $dark-gray; + + li { + margin: 2em 0; + border: 0.1em solid $item-color; + background-color: $extra-light-gray; + + @include before { + content: counter(survey-question); + counter-increment: survey-question; + @include font-family(secondary); + float: left; + font-size: 3.5em; + background-color: $item-color; + color: $white; + width: 1.25em; + height: 1.25em; + line-height: 1.25em; + text-align: center; + margin: 0;// 0.3333em 0 0; + } + } + + header { + @include _-(display, flex); + @include _(align-items, center); + overflow: auto; + margin: 0; + padding: 0.5em 1em; + min-height: 4.375em; + } + + p { + margin: 0; + line-height: 1.25em; + } + + .question-title { + margin: 0; + color: $mid-gray; + line-height: 2.6667em; + } + + .question-details { + margin: 0.05em; + padding: 1em; + background-color: $white; + overflow: auto; // let it scroll just in case + } + + .comment { + max-width: 40em; + margin: auto; + + textarea { + min-height: 5em; + } + } + + .open-ended { + margin: 2em 1em; + } + + label { + cursor: pointer; + + &:hover { + background-color: $light-gray; + } + + input { + cursor: inherit; + } + } +} + +fieldset.likert { + margin: 0 0 0.5em; + + label { + display: block; + margin-bottom: 0.5em; + } +} + +.responsive-table.likert { + width: 100%; + margin: 0; + + .table-th { + padding: 0.5em; + } + + .table-td { + padding: 0; + } + + label { + display: block; + padding: 0.5em; + } +} + @include breakpoint(medium) { + #main ol.survey { + .open-ended { + margin: 2em 1em 2em 5em; + } + } + + fieldset.likert { + margin: 0 0 0.5em 5em; + } + + .responsive-table.likert { + margin: 2em 0 1em; + + .table-td, .table-thead .table-th { + text-align: center; + } + + .table-th { + vertical-align: middle; + } + + .table-td { + position: relative; + vertical-align: middle; + text-align: center; + } + + label { + width: 100%; + padding: 1.7em 0; + } + + input { + margin: auto; + } + } + :focus, input[type="submit"]:focus, .check-box-field input:focus + label, @@ -3355,6 +3491,14 @@ body.policy .policy-agreement ul { } } + .medium-up { + display: inherit; + } + + .small-only { + display: none; + } + html[data-input="kb"] { #main-nav .logo:focus { outline-offset: -0.2em; @@ -3471,6 +3615,7 @@ body.policy .policy-agreement ul { margin-top: 0; padding-top: 0.1em; font-size: 4.25em; + min-width: 2.25em; } .nav { @@ -3556,6 +3701,11 @@ body.policy .policy-agreement ul { margin-bottom: 5.5em; @include _(box-shadow, 0 0 2em -0.5em rgba(0, 0, 0, 0.5)); } + + .access-registration { + position: absolute; + max-width: 11.5em; + } } ul.warnings { @@ -3891,10 +4041,26 @@ body.policy .policy-agreement ul { .table-th, .table-td { display: table-cell; } + + .table-thead { + display: table-header-group; + } + + .table-tbody { + display: table-row-group; + } + + .table-tfoot { + display: table-footer-group; + } } } // medium @include breakpoint(large) { + .responsive-table.likert { + table-layout: fixed; + } + #main { padding-left: $sidebar-width; } @@ -3958,4 +4124,20 @@ body.policy .policy-agreement ul { #main-nav .columns.medium-3 { width: auto; } + + .responsive-table.likert { + .table-tr { + border: 0.1rem solid $light-gray; + } + + .table-td { + border: 0; + } + + .table-th { + border-top: 0; + border-right: 0; + border-left: 0; + } + } } diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index d7029b3..f9791c5 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -43,7 +43,7 @@ class ConferencesController < ApplicationController def register set_conference do_403 unless @this_conference.is_public || @this_conference.host?(current_user) - do_403 unless @this_conference.registration_open + do_403 unless @this_conference.registration_open || @this_conference.registered?(current_user) if logged_in? if request.post? @@ -110,10 +110,49 @@ class ConferencesController < ApplicationController end def survey - return do_404 - # set_conference - # do_403 unless @this_conference.is_public || @this_conference.host?(current_user) - # do_403 if @this_conference.registration_open + set_conference + ensure_registration_is_complete! + return do_403 unless @this_conference.post_conference_survey_available? || @registration.survey_taken + end + + def save_survey + set_conference + ensure_registration_is_complete! + return do_403 unless @this_conference.post_conference_survey_available?(@registration) && !@registration.survey_taken + + # compile the results + results = {} + @this_conference.post_conference_survey_questions.each do |name, question| + case question[:type] + when :multi_likert + answer = {} + question[:questions].each do |q| + r = params["#{name}_#{q}"] + answer[q] = r if r.present? && question[:options].include?(r.to_sym) + end + results[name] = answer + else + answer = params[name] + if answer.present? + unless question[:waive_option].present? && answer.to_sym == question[:waive_option] + results[name] = answer + end + end + end + end + + # create the survey + Survey.create( + name: @this_conference.post_conference_survey_name, + version: @this_conference.post_conference_survey_version, + results: results + ) + + # mark this user as having taken the survey + @registration.survey_taken = true + @registration.save! + + redirect_to conference_survey_path end helper_method :registration_complete? @@ -166,7 +205,7 @@ class ConferencesController < ApplicationController rescue_from ActiveRecord::PremissionDenied do |exception| if !@this_conference.can_register? - do_404 + do_403 elsif logged_in? redirect_to 'conferences/register' else diff --git a/app/controllers/workshops_controller.rb b/app/controllers/workshops_controller.rb index c1d5fc4..865b7a4 100644 --- a/app/controllers/workshops_controller.rb +++ b/app/controllers/workshops_controller.rb @@ -26,6 +26,7 @@ class WorkshopsController < ApplicationController def create_workshop set_conference + return do_404 unless @this_conference.registration_open ensure_registration_is_complete! @workshop = Workshop.new @@ -121,6 +122,7 @@ class WorkshopsController < ApplicationController return do_404 unless workshop.present? can_edit = workshop.can_edit?(current_user) else + return do_404 unless @this_conference.registration_open workshop = Workshop.new(conference_id: @this_conference.id) workshop.workshop_facilitators = [WorkshopFacilitator.new(user_id: current_user.id, role: :creator)] can_edit = true @@ -175,7 +177,7 @@ class WorkshopsController < ApplicationController set_conference ensure_registration_is_complete! workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id) - return do_404 unless workshop + return do_404 unless workshop.present? && workshop.can_show_interest?(current_user) # save the current state interested = workshop.interested? current_user diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb index 1b402c0..4f6b478 100644 --- a/app/helpers/form_helper.rb +++ b/app/helpers/form_helper.rb @@ -476,7 +476,7 @@ module FormHelper label = labels[i] elsif is_single label = options[:translate] == false ? label_key.to_s : _(label_key.to_s) - elsif box.is_a?(Integer) + elsif box.is_a?(Integer) && options[:translate] != false label = I18n.t(label_key.to_s)[box] else label = options[:translate] == false ? box : _("#{label_key.to_s}.#{box}") diff --git a/app/views/application/permission_denied.html.haml b/app/views/application/permission_denied.html.haml index 8fdf1d1..be2f0f0 100644 --- a/app/views/application/permission_denied.html.haml +++ b/app/views/application/permission_denied.html.haml @@ -1,4 +1,4 @@ -= render :partial => 'application/header', :locals => {:image_file => @banner_image || '403.jpg'} += render partial: 'application/header', locals: {image_file: @banner_image || '403.jpg'} %article - if @template.present? =render @template @@ -6,5 +6,9 @@ = row do = columns do %h2=_'error.403.title','Sorry, you currently don\'t have access to this page' - %p=_'error.403.description', :p - = render 'contact', cancel_btn: false, contact_reason: :website \ No newline at end of file + - if logged_in? + %p=_'error.403.description', :p + = render 'contact', cancel_btn: false, contact_reason: :website + - else + %p=_'error.403.not_logged_in', :p + = render "application/login" \ No newline at end of file diff --git a/app/views/conferences/_conference.html.haml b/app/views/conferences/_conference.html.haml index ad60f64..5732206 100644 --- a/app/views/conferences/_conference.html.haml +++ b/app/views/conferences/_conference.html.haml @@ -10,8 +10,12 @@ - if conference.start_date.present? && conference.end_date.present? .secondary = date_span(conference.start_date.to_date, conference.end_date.to_date) - - if conference.poster.present? && links.include?(:register) && conference.can_register? + - if conference.poster.present? && links.include?(:register) && conference.can_register?(current_user) .register-link + - unless logged_in? + .access-registration + = _'actions.conference.already_registered' + = link_to (_'actions.conference.access_registration'), register_path(conference.slug) = (link_to _(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register'), register_path(conference.slug), class: [:button, :register]) - if conference.poster.present? %figure @@ -23,7 +27,7 @@ = richtext conference.info .links - = (link_to (_(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register')), register_path(conference.slug), class: [:button, :register]) if links.include?(:register) && conference.can_register? + = (link_to (_(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register')), register_path(conference.slug), class: [:button, :register]) if links.include?(:register) && conference.can_register?(current_user) = (link_to (_'articles.workshops.info.read_more'), conference_path(conference.slug), class: :button) if links.include?(:read_more) = (link_to (_'forms.actions.generic.administrate'), administrate_conference_path(conference.slug), class: [:button]) if links.include?(:administrate) = (link_to (_'forms.actions.generic.edit'), edit_conference_path(conference.slug), class: [:button, :subdued]) if links.include?(:edit) diff --git a/app/views/conferences/survey.html.haml b/app/views/conferences/survey.html.haml new file mode 100644 index 0000000..eac1069 --- /dev/null +++ b/app/views/conferences/survey.html.haml @@ -0,0 +1,70 @@ += render partial: 'conferences/page_header', locals: {page_key: 'Conference_Survey'} +- if @warnings.present? + = row class: 'warnings', tag: :ul do + - @warnings.each do |warning| + = columns tag: :li, class: 'warning-info' do + = warning +%article + - if !@registration.checked_in? + = row do + = columns(medium: 12) do + %h2=_"articles.conference_survey.headings.post_conference", :t + %p=_"articles.conference_survey.paragraphs.post_conference_not_checked_in", :p + - elsif @registration.survey_taken + = row do + = columns(medium: 12) do + %h2=_"articles.conference_survey.headings.post_conference", :t + %p=_"articles.conference_survey.paragraphs.post_conference_taken", :p + - else + = form_tag conference_survey_save_path(@this_conference.slug) do + = row do + = columns(medium: 12) do + %h2=_"articles.conference_survey.headings.post_conference", :t + %p=_"articles.conference_survey.paragraphs.post_conference", :p + = textfield :email, nil, required: true, big: true unless logged_in? + %ol.survey + - @this_conference.post_conference_survey_questions.each do |name, question| + %li + %header + %p= _"articles.conference_survey.paragraphs.#{name}", :p + .question-details + - case question[:type] + - when :open_ended + .open-ended= textarea name, nil, plain: true, short: true, label: false, class: question[:comment_size] + - when :multi_likert + - options = question[:options].to_a + - options << question[:waive_option] if question[:waive_option].present? + .table.responsive-table.likert + .table-thead.medium-up + .table-tr + .table-th.corner + - options.each do |option| + .table-th{id: "#{name}-option-#{option}"}=_("articles.conference_survey.likert.#{option}") + .table-tbody + - question[:questions].each do |q| + .table-tr + .table-th{id: "#{name}-question-#{q}"}=_("articles.conference_survey.questions.#{q}") + - options.each do |option| + .table-td + =label_tag do + =radio_button_tag "#{name}_#{q}", option, aria: { labelledby: "#{name}-question-#{q} #{name}-option-#{option}" } + %span.small-only=_("articles.conference_survey.likert.#{option}") + - when :likert + - options = question[:options].to_a + - options << question[:waive_option] if question[:waive_option].present? + - is_numerical = question[:options].is_a?(Range) + %fieldset.likert + - options.each do |option| + = label_tag do + = radio_button_tag name, option + = _("articles.conference_survey.likert.#{option}") + - if question[:comment].present? + .comment + = textarea "#{name}_comment", nil, label: "articles.conference_survey.comment.#{question[:comment] == true ? 'default' : question[:comment]}", plain: true, short: true + + + = row do + = columns(medium: 12) do + %p=_"articles.conference_survey.paragraphs.post_conference_submit", :p + .actions.center + = button :submit diff --git a/app/views/registration_steps/_review.html.haml b/app/views/registration_steps/_review.html.haml index feced7e..8168a3f 100644 --- a/app/views/registration_steps/_review.html.haml +++ b/app/views/registration_steps/_review.html.haml @@ -1,3 +1,10 @@ +- if @allow_survey + = row do + = columns(medium: 12) do + %h2=_'articles.conference_survey.headings.post_conference', :t + %p=_'articles.conference_survey.paragraphs.post_conference', :p + .actions.centered + = link_to (_'actions.conference_registration.take_survey'), conference_survey_path(@this_conference), class: [:button, :modify] = registration_step_header = row do = columns(medium: 12) do @@ -9,7 +16,7 @@ .table-tr .table-th =_"articles.conference_registration.step_names.#{step}" - = button :edit, name: :edit_step, value: step, class: [:unstyled, :edit] + = button :edit, name: :edit_step, value: step, class: [:unstyled, :edit] if @this_conference.registration_open .table-td - case data[:type] - when :bool @@ -32,7 +39,7 @@ - else = value.html_safe - else - %p.centered=_'articles.conference_registration.paragraphs.registration_cancelled', :p + %p=_'articles.conference_registration.paragraphs.registration_cancelled', :p - if @allow_cancel_attendance .actions.centered = button :cancel_registration, value: :cancel_registration, class: :red @@ -70,17 +77,18 @@ %td{colspan: 3, lang: guest.user.locale.to_s == I18n.locale.to_s ? nil : guest.user.locale} = paragraph guest.housing_data['other'] -= row do - = columns(medium: 12) do - %h3=_'articles.workshops.headings.Workshops', :t - - if @this_conference.workshop_info.present? - = richtext @this_conference.workshop_info - - else - %p=_'articles.conference_registration.paragraphs.workshops', :p - .actions.centered - .buttons - = link_to (_'articles.conference_registration.actions.View_Workshops'), workshops_path(@this_conference), class: :button - = link_to (_'actions.workshops.create'), create_workshop_path(@this_conference), class: [:button, :modify] +- if @this_conference.registration_open + = row do + = columns(medium: 12) do + %h3=_'articles.workshops.headings.Workshops', :t + - if @this_conference.workshop_info.present? + = richtext @this_conference.workshop_info + - else + %p=_'articles.conference_registration.paragraphs.workshops', :p + .actions.centered + .buttons + = link_to (_'articles.conference_registration.actions.View_Workshops'), workshops_path(@this_conference), class: :button + = link_to (_'actions.workshops.create'), create_workshop_path(@this_conference), class: [:button, :modify] - if @my_workshops.present? = row do = columns(medium: 12) do diff --git a/config/locales/en.yml b/config/locales/en.yml index 788ad2f..be6b2f3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1653,6 +1653,51 @@ en: spaces: We respect each others bodies and spaces. open_minds: We encourage open minds and open hearts. peaceful: We are peaceful and honest. + conference_survey: + headings: + post_conference: Post-Conference Survey + years_attended: Years attended + reattend_again: Coming back? + services: Services + experience: Experience + improvement_ideas: Improvement Ideas + comments: Comments + paragraphs: + post_conference: Please share your feelings and experiences from this year's Bike!Bike! through this post-conference survey. + The information you provide will be analysed and shared as a report with + with the direct responses accessible to outgoing and incoming organizers. All response you provide will be anonymous. + post_conference_submit: Your responses will are anonymous. Once you press submit, you will not be able to edit your responses. + post_conference_taken: Thank you for taking the post-conference survey, your responses have been recorded anonymously. + post_conference_not_checked_in: Our records indicate that you did not check in to the conference, this survey is only available to people who attended the conference in person. If you believe this in in error, please contact us. + years_attended: How many times have you attended Bike!Bike!? + reattend_again: How likely are you to re-attend in the future? + services: How satisfied are you with the following services? + experience: 'How would you describe your personal experience at this years Bike!Bike!? (i.e.: Was it inclusive/exclusive, inspiring/disappointing, educational/fun, etc.)' + improvement_ideas: What are some ways that Bike!Bike! can improve in the future? + comments: Do you have any additional comments, questions, or concerns? + likert: + very_unsatisfied: Very unsatisfied + unsatisfied: Unsatisfied + neutral: Neutral + satisfied: Satisfied + very_satisfied: Very satisfied + not_likely: Not likely + likely: Likely + very_likely: Very likely + first: This was my first time attending + two_to_four: 2-4 + five_or_more: 5+ + na: Not applicable + questions: + housing: Housing + bike: Loaner bike + food: Meals + schedule: Conference schedule + events: Special events + workshops: Workshop content and facilitation + website: Registration and website + comment: + default: Any additional comments? conference_registration: complete: payment_processed: Thank you for your payment! Your registration is now complete. @@ -2388,6 +2433,7 @@ en: no_file_selected: No file selected actions: generic: + submit: Submit check_in: Complete check in reopen_registration: Re-open my registration cancel_registration: Cancel my registration @@ -2502,6 +2548,7 @@ en: Contact_Us: Contact Us Conferences: Conferences conferences: + Conference_Survey: Post-Conference Survey Conference_Registration: Conference Registration Create_Workshop: Create a Workshop Email_Participants: Email Participants @@ -2596,11 +2643,16 @@ en: conference: edit_registration: My registration Translate: Edit %{language} version + already_registered: Already registered? + access_registration: Access your registration + conference_registration: + take_survey: Take the survey now error: '403': description: You do not currently have sufficient permissions to access this page. If you believe this is an error, please contact us. title: You do not have access to this page + not_logged_in: You may need to be signed in to access this page. Please sign in using the form below, if you have any further problems don't hessitate to contact us. '404': description: The page you are looking for could not be found. If you think this was in error, please contact us. diff --git a/db/schema.rb b/db/schema.rb index edf5f7f..90d77e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -110,7 +110,6 @@ ActiveRecord::Schema.define(version: 20170817000540) do t.boolean "is_participant" t.boolean "is_volunteer" t.string "confirmation_token" - t.binary "data_old" t.string "email" t.boolean "complete" t.boolean "completed" diff --git a/features/registration.feature b/features/registration.feature index 2cf7a57..86b543e 100644 --- a/features/registration.feature +++ b/features/registration.feature @@ -640,3 +640,10 @@ Scenario: Housing providers can enter incorrect data and fix it When I click the 'Next' button Then I should see 'Your registration is complete' + +Scenario: Registration is not accessible after registration is closed + Given there is an upcoming conference in 'Brooklyn NY' + And registration is closed + And I am on the registration page + + Then I should see 'You may need to be signed in to access this page' diff --git a/features/step_definitions/interface_steps.rb b/features/step_definitions/interface_steps.rb index c839022..07c0770 100644 --- a/features/step_definitions/interface_steps.rb +++ b/features/step_definitions/interface_steps.rb @@ -67,6 +67,12 @@ Then /^(?:I )?(un)?check ([^']+)$/i do |uncheck, name| find("input[type=\"checkbox\"][name$=\"[#{name.gsub(/\s/, '_')}]\"]").click end +Then /^(?:I )?set ([^']+) to (.+?)(?: under (.+))?$/i do |name, value, under| + _name = ((under.present? ? "#{under.gsub(/\s/, '_')}_" : '') + name.gsub(/\s/, '_')).downcase + _value = value.gsub(/\s/, '_').downcase + find("input[type=\"radio\"][name=\"#{_name}\"][value=\"#{_value}\"]").click +end + Then /^(?:my )?'(.+)' should (not )?be checked$/i do |text, negate| label = find('.check-box-field label', text: text) find("##{label[:for]}", visible: false).send(negate ? :should_not : :should, be_checked) @@ -133,24 +139,19 @@ Then /^(?:my )?(.+)? should (not )?be set to (.+)$/i do |field, should, value| page.find('[id$="' + field.gsub(/\s+/, '_') + '"]').value.send(should.nil? ? 'should' : 'should_not', eq(value)) end -Then /^(?:I )?set (.+?) to (.+)$/i do |field, value| - field = field.gsub(/^\s*(my|the)\s*(.+)$/, '\2') - page.find('[id$="' + field.gsub(/\s+/, '_') + '"]', :visible => false).set value -end - Then /^(?:I )?wait for (.+?) to appear$/i do |field| count = 0 element = nil while element.nil? && count < 120 begin element = page.find('[id$="' + field.gsub(/\s+/, '_') + '"]'); rescue; end - begin element ||= page.find('[id$="' + field.gsub(/\s+/, '_') + '"]', :visible => false); rescue; end + begin element ||= page.find('[id$="' + field.gsub(/\s+/, '_') + '"]', visible: false); rescue; end sleep(1) count += 1 end end Then /^(?:I )?select (.+?) from (.+)$/i do |value, field| - select(value, :from => locate(field)) + select(value, from: locate(field)) end Then /^in a new session$/i do diff --git a/features/step_definitions/registration.rb b/features/step_definitions/registration.rb index e27821a..547d357 100644 --- a/features/step_definitions/registration.rb +++ b/features/step_definitions/registration.rb @@ -3,6 +3,14 @@ Given /^(?:I am |'(.+)' is )?registered(?: for the conference)?$/i do |username| create_registration(username.present? ? get_user(username) : TestState.my_account) end +Given /^I am (not )?checked in?$/i do |do_not_check_in| + unless do_not_check_in + TestState.my_registration.data ||= {} + TestState.my_registration.data['checked_in'] ||= DateTime.now + TestState.my_registration.save! + end +end + Given /^(.+) and (.+) are companions$/i do |user1, user2| u1 = get_user(user1.gsub(/'/, '')) u2 = get_user(user2.gsub(/'/, '')) @@ -54,44 +62,6 @@ When /^(?:I )?(finish|cancel|don't finish) (?:(?:with )?(?:paypal|the payment))$ visit send("register_paypal_#{action == 'cancel' ? 'cancel' : 'confirm'}_path".to_sym, TestState.last_conference.slug, :paypal_confirm, 'token', amount: YAML.load(TestState.my_registration.payment_info)[:amount]) end -# Then /^(?:I )?pay \$?([\d\.]+)$/i do |amount| -# button = nil - -# paypal_info = YAML.load(File.read(Rails.root.join("config/paypal.yml")))['test'].symbolize_keys -# TestState.last_conference.paypal_username = paypal_info[:username] -# TestState.last_conference.paypal_password = paypal_info[:password] -# TestState.last_conference.paypal_signature = paypal_info[:signature] -# TestState.last_conference.save! - -# TestState.my_registration.payment_info = { -# payer_id: '1234', -# token: '5678', -# amount: amount.to_f, -# status: 'Completed' -# }.to_yaml -# TestState.my_registration.save! - -# control = page.all("[value^=\"#{amount}\"]") - -# TestState.last_payment_amount = amount - -# if control.length > 0 -# control.first.trigger('click') -# else -# fill_in(locate('amount'), with: amount) -# click_link_or_button(locate('payment')) -# end -# end - -# Then /^(?:I )?(don't )?have enough funds$/i do |status| -# if status.blank? -# info = YAML.load(TestState.my_registration.payment_info) -# info[:status] = 'Completed' -# TestState.my_registration.payment_info = info.to_yaml -# TestState.my_registration.save! -# end -# end - Given /^a workshop( titled .+)? exists?$/i do |title| workshop = Workshop.new workshop.conference_id = TestState.last_conference.id diff --git a/features/support/paths.rb b/features/support/paths.rb index 78947e0..e24f970 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -16,7 +16,7 @@ module NavigationHelpers when /^registration$/i path = :register args << TestState.last_conference.slug - when /^(conference|register|workshops)$/i + when /^(conference(?:[_\s]survey)?|register|workshops)$/i args << TestState.last_conference.slug when /^confirm(ation)?$/ path = :confirm @@ -26,7 +26,7 @@ module NavigationHelpers end if path.is_a?(Symbol) - path = Rails.application.routes.url_helpers.send("#{path}_path".to_sym, *args) + path = Rails.application.routes.url_helpers.send("#{path.to_s.gsub(/\s+/, '_')}_path".to_sym, *args) end raise "Can't find mapping from \"#{path}\" to a path." unless path.present? diff --git a/features/survey.feature b/features/survey.feature new file mode 100644 index 0000000..592ca17 --- /dev/null +++ b/features/survey.feature @@ -0,0 +1,44 @@ +Feature: Survey + + Scenario: Take the post-conference survey + Given that there is a past conference + And registration is closed + And I am logged in + And registered + And I am checked in + And I am on the registration page + Then I should see 'Please share your feelings and experiences' + + When I click on 'Take the survey now' + Then I should see 'Please share your feelings and experiences from this year's Bike!Bike!' + But I should not see 'Thank you for taking the post-conference survey' + + When I click on 'This was my first time attending' + And click on 'Likely' + And set housing to satisfied under services + And set bike to NA under services + And set food to unsatisfied under services + And set schedule to neutral under services + And set events to very satisfied under services + And set website to very unsatisfied under services + And enter a services comment as 'The website sucks' + And enter an experience as 'Fun' + And enter improvement ideas as 'No idea' + And click 'Submit' + + Then I should see 'Thank you for taking the post-conference survey' + + Scenario: Try to take the post-conference survey when not checked in + Given that there is a past conference + And registration is closed + And I am logged in + And registered + And I am not checked in + And I am on the conference survey page + + Then I should see 'you did not check in' + Then I should not see 'Please share your feelings and experiences from this year's Bike!Bike!' + But I should not see 'Thank you for taking the post-conference survey' + + When I go to the registration page + Then I should not see 'Please share your feelings and experiences'