Browse Source

Tested, translations are now in

development
Godwin 10 years ago
parent
commit
16d1f9fdf9
  1. 23
      app/controllers/conferences_controller.rb
  2. 6
      app/views/conferences/_register_thanks.html.haml
  3. 2061
      config/locales/translation-info.yml
  4. 163
      features/registration.feature
  5. 27
      features/step_definitions/interface_steps.rb
  6. 4
      features/support/paths.rb

23
app/controllers/conferences_controller.rb

@ -361,9 +361,18 @@ class ConferencesController < ApplicationController
@registration = ConferenceRegistration.find(session[:registration][:registration_id])
if params[:confirm_payment]
info = YAML.load(@registration.payment_info)
paypal = PayPal!.checkout!(info[:token], info[:payer_id], PayPalRequest(info[:amount]))
if paypal.payment_info.first.payment_status == 'Completed'
@registration.registration_fees_paid = paypal.payment_info.first.amount.total
amount = nil
status = nil
if is_test?
status = info[:status]
amount = info[:amount]
else
paypal = PayPal!.checkout!(info[:token], info[:payer_id], PayPalRequest(info[:amount]))
status = paypal.payment_info.first.payment_status
amount = paypal.payment_info.first.amount.total
end
if status == 'Completed'
@registration.registration_fees_paid = amount
@registration.save!
end
end
@ -512,8 +521,12 @@ class ConferencesController < ApplicationController
set_conference
@conference_registration = ConferenceRegistration.find_by(payment_confirmation_token: params[:confirmation_token])
if !@conference_registration.nil? && @conference_registration.conference_id == @conference.id && @conference_registration.complete && @conference_registration.registration_fees_paid.nil?
@conference_registration.payment_info = {:payer_id => params[:PayerID], :token => params[:token], :amount => PayPal!.details(params[:token]).amount.total}.to_yaml
@conference_registration.save!
if !is_test?
#@conference_registration.payment_info = {:payer_id => '1234', :token => '5678', :amount => '0.00'}.to_yaml
#else
@conference_registration.payment_info = {:payer_id => params[:PayerID], :token => params[:token], :amount => PayPal!.details(params[:token]).amount.total}.to_yaml
@conference_registration.save!
end
session[:registration] = YAML.load(@conference_registration.data)
session[:registration][:registration_id] = @conference_registration.id
session[:registration][:path] = Array.new

6
app/views/conferences/_register_thanks.html.haml

@ -11,11 +11,11 @@
.row
.columns.small-12.centered
%p=_'registration.thanks.all_done.please_pay.currency','(amounts are in $USD)'
%button{name: 'auto_payment_amount', type: 'submit', value: '25.0', :class => 'good'}
%button{name: 'auto_payment_amount', id: 'auto_pay_25', type: 'submit', value: '25.0', :class => 'good'}
= number_to_currency(25, :unit => '$')
%button{name: 'auto_payment_amount', type: 'submit', value: '50.0', :class => 'better'}
%button{name: 'auto_payment_amount', id: 'auto_pay_50', type: 'submit', value: '50.0', :class => 'better'}
= number_to_currency(50, :unit => '$')
%button{name: 'auto_payment_amount', type: 'submit', value: '100.0', :class => 'best'}
%button{name: 'auto_payment_amount', id: 'auto_pay_100', type: 'submit', value: '100.0', :class => 'best'}
= number_to_currency(100, :unit => '$')
.row
.columns.small-12.centered

2061
config/locales/translation-info.yml

File diff suppressed because it is too large

163
features/registration.feature

@ -2,6 +2,84 @@ Feature: Registration
In order to register for the latest Bike!Bike!
As a visitor
@javascript
Scenario: Register as really eager participant
Given There is an upcoming conference in Moncton NB
And Registration is open
And an organization named Cool Cats Bikes exists in Sackville NB
When I go to the landing page
Then I see a Register Now link
And I click on the Register Now link
And I fill in my email with goodgodwin@hotmail.com
And I press register
And I fill in my firstname with Michael
And I fill in my lastname with Godwin
And I fill in my username with Godwin
And I check is_participant
And I press next
And I see Do you require housing?
And I select bed from housing
And I fill in housing extra with I have a bad back
And I see Do you want to borrow a bike?
And I select large from loaner bike
And I see Would you like to host a workshop?
And I select No from workshop host
And I see Anything else
And I fill in other with I'm coming two months early
And I should not be registered for the conference
And I press submit
Then I should be registered for the conference
And my registration should not be confirmed
And I should get a confirm email
And in the email I should see please confirm your registration
And in the email I should see a confirmation link
And I see Who do you Represent
When I go to the confirmation page
Then I see Thanks for confirming
And I see Who do you Represent
And my registration is confirmed
But my registration is not complete
And my registration is not completed
Then I click on Cool Cats Bikes
And press next
Then I should see Thanks for completing your registration
And my registration is complete
And my registration is completed
But my registration is not paid
Then I should get a Thanks email
And in the email I should see pay the registration donation
And in the email I should see a pay registration link
When I go to the pay registration page
Then I see Thanks for completing your registration
And I see we ask that you pay
And I see custom amount
Then I pay 12.34
Then I should see Your order summary
When I finish with paypal
Then I should see confirm your payment
And I should see $12.34
And I have enough funds
And I press confirm payment
Then I should see We'll see you in Moncton
And my registration is paid
@javascript
Scenario: Register as participant with some second thoughts
Given There is an upcoming conference in Moncton NB
@ -159,88 +237,17 @@ Feature: Registration
When I go to the pay registration page
Then I see Thanks for completing your registration
And I see we ask that you pay
And I see payment amount
And I see submit payment
And I see $25.00
Then I fill in payment amount with 12.34
And press submit payment
Then I pay 25.00
Then I should see Your order summary
When I finish paying
Then I should see We'll see you in Moncton
And my registration is paid
@javascript
Scenario: Register as really eager participant
Given There is an upcoming conference in Moncton NB
And Registration is open
And an organization named Cool Cats Bikes exists in Sackville NB
When I finish with paypal
Then I should see confirm your payment
And I should see $25.00
And I have enough funds
And I press confirm payment
When I go to the landing page
Then I see a Register Now link
And I click on the Register Now link
And I fill in my email with goodgodwin@hotmail.com
And I press register
And I fill in my firstname with Michael
And I fill in my lastname with Godwin
And I fill in my username with Godwin
And I check is_participant
And I press next
And I see Do you require housing?
And I select bed from housing
And I fill in housing extra with I have a bad back
And I see Do you want to borrow a bike?
And I select large from loaner bike
And I see Would you like to host a workshop?
And I select No from workshop host
And I see Anything else
And I fill in other with I'm coming two months early
And I should not be registered for the conference
And I press submit
Then I should be registered for the conference
And my registration should not be confirmed
And I should get a confirm email
And in the email I should see please confirm your registration
And in the email I should see a confirmation link
And I see Who do you Represent
When I go to the confirmation page
Then I see Thanks for confirming
And I see Who do you Represent
And my registration is confirmed
But my registration is not complete
And my registration is not completed
Then I click on Cool Cats Bikes
And press next
Then I should see Thanks for completing your registration
And my registration is complete
And my registration is completed
But my registration is not paid
Then I should get a Thanks email
And in the email I should see pay the registration donation
And in the email I should see a pay registration link
Then I should see Thanks for completing your registration
And I see we ask that you pay
And I see payment amount
And I see submit payment
Then I fill in payment amount with 12.34
And press submit payment
Then I should see Your order summary
When I finish paying
Then I should see We'll see you in Moncton
And my registration is paid

27
features/step_definitions/interface_steps.rb

@ -14,8 +14,31 @@ When(/^I go to the (.+) page$/) do |page_name|
visit path_to(page_name.to_sym)
end
When(/^(I )?(finish|cancel) (paying|(the )?payment)$/) do |a, action, b, c|
visit path_to((action == 'finish' ? 'confirm' : action) + ' payment')
When(/^(I )?(finish|cancel) ((with )?paypal)$/) do |a, action, b, c|
@last_registration.payment_info = {:payer_id => '1234', :token => '5678', :amount => @last_payment_amount}.to_yaml
@last_registration.save!
visit path_to((action == 'finish' ? 'confirm' : action) + ' paypal')
end
Then(/^(I )?pay \$?([\d\.]+)$/) do | a, amount |
button = nil
begin; button = locate("auto pay #{amount.to_f.to_i}"); rescue; end
if button
click_link_or_button(button)
else
fill_in(locate('payment amount'), :with => amount)
click_link_or_button(locate('custom amount'))
end
@last_payment_amount = amount
end
Then(/^(I )?(don't )?have enough funds$/) do | a, status |
if status.blank?
info = YAML.load(@last_registration.payment_info)
info[:status] = 'Completed'
@last_registration.payment_info = info.to_yaml
@last_registration.save!
end
end
Given(/^There is an upcoming conference( in .+)?$/) do |location|

4
features/support/paths.rb

@ -8,9 +8,9 @@ module NavigationHelpers
path = "/conferences/bikebike/#{@last_conference.slug}/register/confirm/#{@last_registration.confirmation_token}"
when /^pay registration$/i
path = "/conferences/bikebike/#{@last_conference.slug}/register/pay-registration/#{@last_registration.confirmation_token}"
when /^paypal confirm$/i
when /^confirm paypal$/i
path = "/conferences/bikebike/#{@last_conference.slug}/register/paypal-confirm/#{@last_registration.payment_confirmation_token}"
when /^paypal cancel$/i
when /^cancel paypal$/i
path = "/conferences/bikebike/#{@last_conference.slug}/register/paypal-cancel/#{@last_registration.confirmation_token}"
when /^translation list$/i
path = '/translations/'

Loading…
Cancel
Save