New registration completed and tested

This commit is contained in:
Godwin
2017-06-03 12:55:13 -07:00
parent 6eddbe0a69
commit eed9bd8b40
21 changed files with 763 additions and 1009 deletions
+5 -1
View File
@@ -16,6 +16,10 @@ Given /^(?:(?:that )?there is )?an? (upcoming|past)( regional)? conference(?: in
TestState.last_conference.save!
end
Given /^there is an organization named '(.+)' in (.+)$/ do |org_name, location|
TestState.last_organization = create_org(org_name, location)
end
Given /^(?:the conference |it )has no (poster|date)$/i do |field|
if field == 'date'
TestState.last_conference.start_date = nil
@@ -33,7 +37,7 @@ Given /^(?:the conference |it )?is not (featured|public)$/i do |field|
end
Given /^the conference accepts housing providers that live within (\d+)(mi|km)$/i do |number, unit|
TestState.last_conference.provider_conditions = {'distance' => {'number' => number.to_i, 'unit' => unit}}
TestState.last_conference.provider_conditions = { 'distance' => {'number' => number.to_i, 'unit' => unit } }
TestState.last_conference.save!
end
+15 -6
View File
@@ -64,6 +64,10 @@ Then /^(?:I )?(un)?check '(.+)'$/i do |uncheck, text|
end
end
Then /^(?:I )?(un)?check ([^']+)$/i do |uncheck, name|
find("input[type=\"checkbox\"][name$=\"[#{name.gsub(/\s/, '_')}]\"]").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)
@@ -74,8 +78,8 @@ Then /^(?:I )?(?:select|choose|want) (?:an? |the )?'(.+?)'$/i do |value|
option.first(:xpath, './/..').set(option.value)
end
Then /^(?:I )?fill in (.+?) with '(.+)'$/i do |field, value|
field = field.gsub(/^\s*(my|the)\s*(.+)$/, '\2')
Then /^(?:I )?fill in (.+?) with '(.*)'$/i do |field, value|
field = field.gsub(/^\s*(my|the)?\s*(.+)$/, '\2').gsub(/\s/, '_')
find(selector_for(field)).set value
if /email/ =~ field && !(/organization/ =~ field)
@@ -88,7 +92,12 @@ Then /^(?:I )?enter (?:my |an? |some |the )?(.+?)(?: as '(.+)')?$/i do |field, v
sel = selector_for(field)
element = first(sel, visible: true) || first(sel, visible: false)
element = element.first('[contenteditable]') if element.tag_name.to_s.downcase == 'div'
html = false
if element.tag_name.to_s.downcase == 'div'
element = element.first('[contenteditable]')
html = true
end
unless value.present?
value = case field
@@ -102,11 +111,11 @@ Then /^(?:I )?enter (?:my |an? |some |the )?(.+?)(?: as '(.+)')?$/i do |field, v
when 'subject', 'title'
Forgery::LoremIpsum.sentence(random: true).gsub(/\.$/, '').titlecase
when /(comment|reply)/
Forgery::LoremIpsum.paragraphs(2, sentences: 6, random: true)
Forgery::LoremIpsum.paragraphs(2, sentences: 6, random: true, html: html)
when 'message'
Forgery::LoremIpsum.paragraphs(2, sentences: 6, random: true)
Forgery::LoremIpsum.paragraphs(2, sentences: 6, random: true, html: html)
when 'info'
Forgery::LoremIpsum.paragraphs(rand(1..4), sentences: rand(3..8), random: true)
Forgery::LoremIpsum.paragraphs(rand(1..4), sentences: rand(3..8), random: true, html: html)
else
fail "Unknown selector '#{field}'"
end
+18
View File
@@ -3,11 +3,29 @@ Given /^(?:I am |'(.+)' is )?registered(?: for the conference)?$/i do |username|
create_registration(username.present? ? get_user(username) : TestState.my_account)
end
Given /^(.+) and (.+) are companions$/i do |user1, user2|
u1 = get_user(user1.gsub(/'/, ''))
u2 = get_user(user2.gsub(/'/, ''))
registration1 = ConferenceRegistration.find_by(user_id: u1.id, conference_id: TestState.last_conference.id)
registration1.housing_data['companion'] = { 'id' => u2.id }
registration1.save
registration2 = ConferenceRegistration.find_by(user_id: u2.id, conference_id: TestState.last_conference.id)
registration2.housing_data['companion'] = { 'id' => u1.id }
registration2.save
end
Given /^(?:I )?have paid( \$?\d+|\$?\d+\.\d+)? for registration$/i do |amount|
TestState.my_registration.registration_fees_paid = amount ? amount.to_f : 50.0
TestState.my_registration.save!
end
Given /^my payment status will be '(Completed|Pending|Denied|Error)'$/i do |status|
TestState.my_registration.data ||= {}
TestState.my_registration.data['payment_status'] = status
TestState.my_registration.save!
end
Then /^my registration should( not)? be (confirmed|completed?|paid)$/i do |state, field|
ConferenceRegistration.find_by!(email: TestState.last_email_entered).
send(field == 'confirmed' ? 'is_confirmed' : (field == 'paid' ? 'registration_fees_paid' : field)).