From e5eb8f97f9097fafd1c82076c86ef67632db1bc0 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Mon, 22 Feb 2021 13:02:30 -0800 Subject: [PATCH] add basic feature spec for authorisation table --- app/views/spree/users/_transactions.html.haml | 2 +- .../consumer/account/payments_spec.rb | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 spec/features/consumer/account/payments_spec.rb diff --git a/app/views/spree/users/_transactions.html.haml b/app/views/spree/users/_transactions.html.haml index 7343eef31c..2acce38612 100644 --- a/app/views/spree/users/_transactions.html.haml +++ b/app/views/spree/users/_transactions.html.haml @@ -1,7 +1,7 @@ %script{ type: "text/ng-template", id: "account/transactions.html" } - if @payments_requiring_action.present? .active_table - %h3.requiring-authorization= t(".authorization_required") + %h3.requiring-authorization= t(".authorisation_required") .small-12.columns %table %tr diff --git a/spec/features/consumer/account/payments_spec.rb b/spec/features/consumer/account/payments_spec.rb new file mode 100644 index 0000000000..9f6ddf33c9 --- /dev/null +++ b/spec/features/consumer/account/payments_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +feature "Payments requiring action", js: true do + include AuthenticationHelper + + describe "as a logged in user" do + let(:user) { create(:user) } + let(:order) { create(:order, user: user) } + + before do + login_as user + end + + context "there is a payment requiring authorization" do + let!(:payment) do + create(:payment, order: order, cvv_response_message: "https://stripe.com/redirect") + end + + it "shows a table of payments requiring authorization" do + visit "/account" + + find("a", :text => %r{#{I18n.t('spree.users.show.tabs.transactions')}}i).click + expect(page).to have_content I18n.t("spree.users.transactions.authorisation_required") + end + end + + context "there are no payments requiring authorization" do + let!(:payment) do + create(:payment, order: order, cvv_response_message: nil) + end + + it "does not show the table of payments requiring authorization" do + visit "/account" + + find("a", :text => %r{#{I18n.t('spree.users.show.tabs.transactions')}}i).click + expect(page).to_not have_content I18n.t("spree.users.transactions.authorisation_required") + end + end + end +end