Browse Source

Merge branch 'development'

development
Godwin 7 years ago
parent
commit
5fb19d4324
  1. 232
      app/assets/stylesheets/_application.scss
  2. 51
      app/controllers/conferences_controller.rb
  3. 4
      app/controllers/workshops_controller.rb
  4. 2
      app/helpers/form_helper.rb
  5. 6
      app/views/application/permission_denied.html.haml
  6. 8
      app/views/conferences/_conference.html.haml
  7. 70
      app/views/conferences/survey.html.haml
  8. 14
      app/views/registration_steps/_review.html.haml
  9. 52
      config/locales/en.yml
  10. 1
      db/schema.rb
  11. 7
      features/registration.feature
  12. 15
      features/step_definitions/interface_steps.rb
  13. 46
      features/step_definitions/registration.rb
  14. 4
      features/support/paths.rb
  15. 44
      features/survey.feature

232
app/assets/stylesheets/_application.scss

@ -80,31 +80,6 @@ a {
cursor: pointer; cursor: pointer;
text-decoration-skip: ink; text-decoration-skip: ink;
@include link; @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 { .target:target {
@ -121,6 +96,10 @@ a {
position: absolute !important; position: absolute !important;
} }
.medium-up {
display: none;
}
table, .table { table, .table {
margin-bottom: 2em; margin-bottom: 2em;
margin-left: 1em; margin-left: 1em;
@ -2349,6 +2328,19 @@ a.logo {
font-size: 0.75em; font-size: 0.75em;
margin: 0.5em 0 0; 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 { .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) { @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, :focus,
input[type="submit"]:focus, input[type="submit"]:focus,
.check-box-field input:focus + label, .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"] { html[data-input="kb"] {
#main-nav .logo:focus { #main-nav .logo:focus {
outline-offset: -0.2em; outline-offset: -0.2em;
@ -3471,6 +3615,7 @@ body.policy .policy-agreement ul {
margin-top: 0; margin-top: 0;
padding-top: 0.1em; padding-top: 0.1em;
font-size: 4.25em; font-size: 4.25em;
min-width: 2.25em;
} }
.nav { .nav {
@ -3556,6 +3701,11 @@ body.policy .policy-agreement ul {
margin-bottom: 5.5em; margin-bottom: 5.5em;
@include _(box-shadow, 0 0 2em -0.5em rgba(0, 0, 0, 0.5)); @include _(box-shadow, 0 0 2em -0.5em rgba(0, 0, 0, 0.5));
} }
.access-registration {
position: absolute;
max-width: 11.5em;
}
} }
ul.warnings { ul.warnings {
@ -3891,10 +4041,26 @@ body.policy .policy-agreement ul {
.table-th, .table-td { .table-th, .table-td {
display: table-cell; display: table-cell;
} }
.table-thead {
display: table-header-group;
}
.table-tbody {
display: table-row-group;
}
.table-tfoot {
display: table-footer-group;
}
} }
} // medium } // medium
@include breakpoint(large) { @include breakpoint(large) {
.responsive-table.likert {
table-layout: fixed;
}
#main { #main {
padding-left: $sidebar-width; padding-left: $sidebar-width;
} }
@ -3958,4 +4124,20 @@ body.policy .policy-agreement ul {
#main-nav .columns.medium-3 { #main-nav .columns.medium-3 {
width: auto; 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;
}
}
} }

51
app/controllers/conferences_controller.rb

@ -43,7 +43,7 @@ class ConferencesController < ApplicationController
def register def register
set_conference set_conference
do_403 unless @this_conference.is_public || @this_conference.host?(current_user) 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 logged_in?
if request.post? if request.post?
@ -110,10 +110,49 @@ class ConferencesController < ApplicationController
end end
def survey def survey
return do_404 set_conference
# set_conference ensure_registration_is_complete!
# do_403 unless @this_conference.is_public || @this_conference.host?(current_user) return do_403 unless @this_conference.post_conference_survey_available? || @registration.survey_taken
# do_403 if @this_conference.registration_open 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 end
helper_method :registration_complete? helper_method :registration_complete?
@ -166,7 +205,7 @@ class ConferencesController < ApplicationController
rescue_from ActiveRecord::PremissionDenied do |exception| rescue_from ActiveRecord::PremissionDenied do |exception|
if !@this_conference.can_register? if !@this_conference.can_register?
do_404 do_403
elsif logged_in? elsif logged_in?
redirect_to 'conferences/register' redirect_to 'conferences/register'
else else

4
app/controllers/workshops_controller.rb

@ -26,6 +26,7 @@ class WorkshopsController < ApplicationController
def create_workshop def create_workshop
set_conference set_conference
return do_404 unless @this_conference.registration_open
ensure_registration_is_complete! ensure_registration_is_complete!
@workshop = Workshop.new @workshop = Workshop.new
@ -121,6 +122,7 @@ class WorkshopsController < ApplicationController
return do_404 unless workshop.present? return do_404 unless workshop.present?
can_edit = workshop.can_edit?(current_user) can_edit = workshop.can_edit?(current_user)
else else
return do_404 unless @this_conference.registration_open
workshop = Workshop.new(conference_id: @this_conference.id) workshop = Workshop.new(conference_id: @this_conference.id)
workshop.workshop_facilitators = [WorkshopFacilitator.new(user_id: current_user.id, role: :creator)] workshop.workshop_facilitators = [WorkshopFacilitator.new(user_id: current_user.id, role: :creator)]
can_edit = true can_edit = true
@ -175,7 +177,7 @@ class WorkshopsController < ApplicationController
set_conference set_conference
ensure_registration_is_complete! ensure_registration_is_complete!
workshop = Workshop.find_by_id_and_conference_id(params[:workshop_id], @this_conference.id) 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 # save the current state
interested = workshop.interested? current_user interested = workshop.interested? current_user

2
app/helpers/form_helper.rb

@ -476,7 +476,7 @@ module FormHelper
label = labels[i] label = labels[i]
elsif is_single elsif is_single
label = options[:translate] == false ? label_key.to_s : _(label_key.to_s) 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] label = I18n.t(label_key.to_s)[box]
else else
label = options[:translate] == false ? box : _("#{label_key.to_s}.#{box}") label = options[:translate] == false ? box : _("#{label_key.to_s}.#{box}")

6
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 %article
- if @template.present? - if @template.present?
=render @template =render @template
@ -6,5 +6,9 @@
= row do = row do
= columns do = columns do
%h2=_'error.403.title','Sorry, you currently don\'t have access to this page' %h2=_'error.403.title','Sorry, you currently don\'t have access to this page'
- if logged_in?
%p=_'error.403.description', :p %p=_'error.403.description', :p
= render 'contact', cancel_btn: false, contact_reason: :website = render 'contact', cancel_btn: false, contact_reason: :website
- else
%p=_'error.403.not_logged_in', :p
= render "application/login"

8
app/views/conferences/_conference.html.haml

@ -10,8 +10,12 @@
- if conference.start_date.present? && conference.end_date.present? - if conference.start_date.present? && conference.end_date.present?
.secondary .secondary
= date_span(conference.start_date.to_date, conference.end_date.to_date) = 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 .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]) = (link_to _(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register'), register_path(conference.slug), class: [:button, :register])
- if conference.poster.present? - if conference.poster.present?
%figure %figure
@ -23,7 +27,7 @@
= richtext conference.info = richtext conference.info
.links .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 (_'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.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) = (link_to (_'forms.actions.generic.edit'), edit_conference_path(conference.slug), class: [:button, :subdued]) if links.include?(:edit)

70
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

14
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 = registration_step_header
= row do = row do
= columns(medium: 12) do = columns(medium: 12) do
@ -9,7 +16,7 @@
.table-tr .table-tr
.table-th .table-th
=_"articles.conference_registration.step_names.#{step}" =_"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 .table-td
- case data[:type] - case data[:type]
- when :bool - when :bool
@ -32,7 +39,7 @@
- else - else
= value.html_safe = value.html_safe
- else - else
%p.centered=_'articles.conference_registration.paragraphs.registration_cancelled', :p %p=_'articles.conference_registration.paragraphs.registration_cancelled', :p
- if @allow_cancel_attendance - if @allow_cancel_attendance
.actions.centered .actions.centered
= button :cancel_registration, value: :cancel_registration, class: :red = button :cancel_registration, value: :cancel_registration, class: :red
@ -70,7 +77,8 @@
%td{colspan: 3, lang: guest.user.locale.to_s == I18n.locale.to_s ? nil : guest.user.locale} %td{colspan: 3, lang: guest.user.locale.to_s == I18n.locale.to_s ? nil : guest.user.locale}
= paragraph guest.housing_data['other'] = paragraph guest.housing_data['other']
= row do - if @this_conference.registration_open
= row do
= columns(medium: 12) do = columns(medium: 12) do
%h3=_'articles.workshops.headings.Workshops', :t %h3=_'articles.workshops.headings.Workshops', :t
- if @this_conference.workshop_info.present? - if @this_conference.workshop_info.present?

52
config/locales/en.yml

@ -1653,6 +1653,51 @@ en:
spaces: We respect each others bodies and spaces. spaces: We respect each others bodies and spaces.
open_minds: We encourage open minds and open hearts. open_minds: We encourage open minds and open hearts.
peaceful: We are peaceful and honest. 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: conference_registration:
complete: complete:
payment_processed: Thank you for your payment! Your registration is now complete. payment_processed: Thank you for your payment! Your registration is now complete.
@ -2388,6 +2433,7 @@ en:
no_file_selected: No file selected no_file_selected: No file selected
actions: actions:
generic: generic:
submit: Submit
check_in: Complete check in check_in: Complete check in
reopen_registration: Re-open my registration reopen_registration: Re-open my registration
cancel_registration: Cancel my registration cancel_registration: Cancel my registration
@ -2502,6 +2548,7 @@ en:
Contact_Us: Contact Us Contact_Us: Contact Us
Conferences: Conferences Conferences: Conferences
conferences: conferences:
Conference_Survey: Post-Conference Survey
Conference_Registration: Conference Registration Conference_Registration: Conference Registration
Create_Workshop: Create a Workshop Create_Workshop: Create a Workshop
Email_Participants: Email Participants Email_Participants: Email Participants
@ -2596,11 +2643,16 @@ en:
conference: conference:
edit_registration: My registration edit_registration: My registration
Translate: Edit %{language} version Translate: Edit %{language} version
already_registered: Already registered?
access_registration: Access your registration
conference_registration:
take_survey: Take the survey now
error: error:
'403': '403':
description: You do not currently have sufficient permissions to access this description: You do not currently have sufficient permissions to access this
page. If you believe this is an error, please contact us. page. If you believe this is an error, please contact us.
title: You do not have access to this page 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': '404':
description: The page you are looking for could not be found. If you think this description: The page you are looking for could not be found. If you think this
was in error, please contact us. was in error, please contact us.

1
db/schema.rb

@ -110,7 +110,6 @@ ActiveRecord::Schema.define(version: 20170817000540) do
t.boolean "is_participant" t.boolean "is_participant"
t.boolean "is_volunteer" t.boolean "is_volunteer"
t.string "confirmation_token" t.string "confirmation_token"
t.binary "data_old"
t.string "email" t.string "email"
t.boolean "complete" t.boolean "complete"
t.boolean "completed" t.boolean "completed"

7
features/registration.feature

@ -640,3 +640,10 @@ Scenario: Housing providers can enter incorrect data and fix it
When I click the 'Next' button When I click the 'Next' button
Then I should see 'Your registration is complete' 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'

15
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 find("input[type=\"checkbox\"][name$=\"[#{name.gsub(/\s/, '_')}]\"]").click
end 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| Then /^(?:my )?'(.+)' should (not )?be checked$/i do |text, negate|
label = find('.check-box-field label', text: text) label = find('.check-box-field label', text: text)
find("##{label[:for]}", visible: false).send(negate ? :should_not : :should, be_checked) 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)) page.find('[id$="' + field.gsub(/\s+/, '_') + '"]').value.send(should.nil? ? 'should' : 'should_not', eq(value))
end 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| Then /^(?:I )?wait for (.+?) to appear$/i do |field|
count = 0 count = 0
element = nil element = nil
while element.nil? && count < 120 while element.nil? && count < 120
begin element = page.find('[id$="' + field.gsub(/\s+/, '_') + '"]'); rescue; end 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) sleep(1)
count += 1 count += 1
end end
end end
Then /^(?:I )?select (.+?) from (.+)$/i do |value, field| Then /^(?:I )?select (.+?) from (.+)$/i do |value, field|
select(value, :from => locate(field)) select(value, from: locate(field))
end end
Then /^in a new session$/i do Then /^in a new session$/i do

46
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) create_registration(username.present? ? get_user(username) : TestState.my_account)
end 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| Given /^(.+) and (.+) are companions$/i do |user1, user2|
u1 = get_user(user1.gsub(/'/, '')) u1 = get_user(user1.gsub(/'/, ''))
u2 = get_user(user2.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]) 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 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| Given /^a workshop( titled .+)? exists?$/i do |title|
workshop = Workshop.new workshop = Workshop.new
workshop.conference_id = TestState.last_conference.id workshop.conference_id = TestState.last_conference.id

4
features/support/paths.rb

@ -16,7 +16,7 @@ module NavigationHelpers
when /^registration$/i when /^registration$/i
path = :register path = :register
args << TestState.last_conference.slug args << TestState.last_conference.slug
when /^(conference|register|workshops)$/i when /^(conference(?:[_\s]survey)?|register|workshops)$/i
args << TestState.last_conference.slug args << TestState.last_conference.slug
when /^confirm(ation)?$/ when /^confirm(ation)?$/
path = :confirm path = :confirm
@ -26,7 +26,7 @@ module NavigationHelpers
end end
if path.is_a?(Symbol) 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 end
raise "Can't find mapping from \"#{path}\" to a path." unless path.present? raise "Can't find mapping from \"#{path}\" to a path." unless path.present?

44
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'
Loading…
Cancel
Save