Skip to content

Commit

Permalink
Adds coverage on bogus credit cards
Browse files Browse the repository at this point in the history
  • Loading branch information
filipefurtad0 committed Feb 13, 2022
1 parent aff9d56 commit 82809a5
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions spec/system/consumer/split_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
calculator: Calculator::FlatRate.new(preferred_amount: 4.56))
}
let!(:payment_method) { create(:payment_method, distributors: [distributor]) }
let!(:check_without_fee) {
create(:payment_method, distributors: [distributor], name: "Simple Credit Card",
type: "Spree::PaymentMethod::Check")
}

before do
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
Expand Down Expand Up @@ -131,7 +135,7 @@
visit checkout_path
end

context "details step" do
context "details step" do
describe "filling out delivery details" do
before do
fill_out_details
Expand Down Expand Up @@ -246,15 +250,48 @@

context "payment step" do
let(:order) { create(:order_ready_for_payment, distributor: distributor) }
describe "selecting a Cash payment method" do

before do
choose "Check"
end
describe "selecting a Cash payment method" do
before do
choose "Check"
end

it "selects cash and proceeds to the summary step" do
click_on "Next - Order summary"
expect(page).to have_content "Shopping @ #{distributor.name}"
expect(page).to have_selector("div.checkout-tab.selected", text: "3 - Order summary")
end
end

describe "credit card payments" do
["Spree::Gateway::Bogus", "Spree::Gateway::BogusSimple"].each do |gateway_type|
context "with a credit card payment method using #{gateway_type}" do
let!(:check_without_fee) {
create(:payment_method, distributors: [distributor], name: "Simple Credit Card",
type: gateway_type)
}

before do
choose "Simple Credit Card"
end

it "fills-in valid card data and proceeds to summary page" do
fill_in 'Card number', with: "4111111111111111"
fill_in 'CVC', with: '123'
fill_in 'Month', with: "3"
fill_in 'Year', with: (Date.current.year + 1).to_s
click_on "Next - Order summary"
expect(page).to have_selector("div.checkout-tab.selected", text: "3 - Order summary")
end

it "fills-in an expired card data and triggers an error when proceeding to summary page" do
fill_in 'Card number', with: "9999999988887777"
fill_in 'CVC', with: '123'
fill_in 'Month', with: "3"
fill_in 'Year', with: (Date.current.year - 1).to_s
click_on "Next - Order summary"
expect(page).not_to have_selector("div.checkout-tab.selected", text: "3 - Order summary")
end
end
end
end
end
Expand Down

0 comments on commit 82809a5

Please sign in to comment.