Added post-conference survey

This commit is contained in:
Godwin
2017-09-04 14:10:55 -07:00
parent 90448e059f
commit 611716bbd3
15 changed files with 481 additions and 99 deletions
+8 -7
View File
@@ -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
+8 -38
View File
@@ -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