Feature tests for PaymentMethod in admin and checkout

This commit is contained in:
David Cook
2013-08-12 14:02:11 +10:00
parent 98d520f0e3
commit 725766d82e
2 changed files with 43 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
require "spec_helper"
feature %q{
As a Super Admin
I want to be able to set a distributor on each payment method
} do
include AuthenticationWorkflow
include WebHelper
background do
@distributors = (1..3).map { create(:distributor_enterprise) }
end
#Create and Edit uses same partial form
context "creating a payment method", js: true do
scenario "assigning a distributor to the payment method" do
login_to_admin_section
click_link 'Configuration'
click_link 'Payment Methods'
click_link 'New Payment Method'
fill_in 'payment_method_name', :with => 'Cheque payment method'
select @distributors[0].name, :from => 'payment_method_distributor_id'
click_button 'Create'
flash_message.should == 'Payment Method has been successfully created!'
payment_method = Spree::PaymentMethod.find_by_name('Cheque payment method')
payment_method.distributor.should == @distributors[0]
end
end
end

View File

@@ -57,7 +57,10 @@ feature %q{
c = Spree::Country.find_by_name('Australia')
Spree::ZoneMember.create(:zoneable => c, :zone => @zone)
create(:shipping_method, zone: @zone)
create(:payment_method, :description => 'Cheque payment method')
@payment_method_all = create(:payment_method, :name => 'Cheque payment method', :description => 'Cheque payment method') #valid for any distributor
@payment_method_distributor = create(:payment_method, :name => 'Edible Garden payment method', :distributor => @distributor)
@payment_method_alternative = create(:payment_method, :name => 'Alternative Distributor payment method', :distributor => @distributor_alternative)
end
@@ -203,11 +206,15 @@ feature %q{
click_checkout_continue_button
# -- Checkout: Payment
# Given the distributor I have selected for my order, I should only see payment methods valid for that distributor
page.should have_selector 'label', :text => @payment_method_all.name
page.should have_selector 'label', :text => @payment_method_distributor.name
page.should_not have_selector 'label', :text => @payment_method_alternative.name
click_checkout_continue_button
# -- Checkout: Order complete
page.should have_content('Your order has been processed successfully')
page.should have_content('Cheque payment method')
page.should have_content(@payment_method_all.description)
# page.should have_content('Your order will be available on:')