diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb new file mode 100644 index 0000000000..67274ba5c8 --- /dev/null +++ b/spec/features/admin/payment_method_spec.rb @@ -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 diff --git a/spec/features/consumer/checkout_spec.rb b/spec/features/consumer/checkout_spec.rb index adac695bf5..d9220c59aa 100644 --- a/spec/features/consumer/checkout_spec.rb +++ b/spec/features/consumer/checkout_spec.rb @@ -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:')