class FormsDataset < Dataset::Base uses :pages, :shop_orders, :shop_discounts def load create_record :form, :checkout, :title => 'Checkout', :body => checkout_body, :config => checkout_config, :content => '' end def checkout_body <<-BODY
  1. Name
  2. Address
  3. State and Country
  4. Postcode
  1. Name on Card
  2. Card
BODY end def checkout_config <<-CONFIG checkout: test: true gateway: name: Bogus credentials: login: 123456 CONFIG end helpers do def mock_page_with_request_and_data @page = pages(:home) @request = OpenStruct.new({ :session => {} }) @data = {} stub(@page).data { @data } stub(@page).request { @request } end def mock_response @response = OpenStruct.new({ :result => { :results => {} } }) mock(Forms::Tags::Responses).current(anything,anything) { @response } end def mock_valid_form_checkout_request @form = forms(:checkout) @form[:extensions] = { :checkout => { :test => true, :gateway => { :name => 'Bogus' }, :mail => { :subject=> 'new order', :bcc => 'orders@example.com' }, } } @data = { :card => { :number => '1', :name => 'Mr. Joe Bloggs', :verification => '123', :month => 1, :year => 2012, :type => 'visa' }, :options => { :address => { :address1 => 'address', :zip => 'zip' } } } @request.session = { :shop_order => @order.id } end def mock_valid_form_address_request @form = forms(:checkout) @form[:extensions] = { :address => { :billing => true, :shipping => true } } @data = { :billing => { :id => shop_addresses(:billing).id, :name => shop_addresses(:billing).name, :email => shop_addresses(:billing).email, :street => shop_addresses(:billing).street, :city => shop_addresses(:billing).city, :state => shop_addresses(:billing).state, :country => shop_addresses(:billing).country, :postcode => shop_addresses(:billing).postcode }, :shipping => { :id => shop_addresses(:shipping).id, :name => shop_addresses(:shipping).name, :email => shop_addresses(:shipping).email, :street => shop_addresses(:shipping).street, :city => shop_addresses(:shipping).city, :state => shop_addresses(:shipping).state, :country => shop_addresses(:shipping).country, :postcode => shop_addresses(:shipping).postcode } } @request.session = { :shop_order => @order.id } end def mock_valid_form_discount_request @form = forms(:checkout) @form[:extensions] = { :discount => { :process => 'add' } } @data = { :discount => { :code => shop_discounts(:ten_percent).code } } @request.session = { :shop_order => @order.id } end end end