Skip to content

Commit

Permalink
Adding message about having no saved cards to account/cards UI
Browse files Browse the repository at this point in the history
  • Loading branch information
oeoeaio committed May 31, 2017
1 parent 2d11bfc commit 9183360
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/darkswarm/account.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
}
}

.saved_cards, .no_cards {
margin-bottom: 1em;
}

.new_card {
opacity: 0;
-webkit-transition: opacity 0.4s linear;
Expand Down
6 changes: 3 additions & 3 deletions app/views/spree/users/_cards.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
.credit_cards{"ng-controller" => "CreditCardsCtrl"}
.row
.small-12.medium-6.columns
%span{ ng: { hide: 'savedCreditCards.length > 0' } }
 
%h3= t(:saved_cards)
.saved_cards{ ng: { show: 'savedCreditCards.length > 0' } }
%h3= t(:saved_cards)
= render 'saved_cards'
.no_cards{ ng: { hide: 'savedCreditCards.length > 0' } }
= t(:you_have_no_saved_cards)
%button.button.primary{ ng: { click: 'showForm()', hide: 'CreditCard.visible' } }
= t(:add_a_card)
Expand Down
2 changes: 1 addition & 1 deletion app/views/spree/users/_saved_cards.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
%td.expiry{ ng: { bind: '::card.expiry' } }
%td.actions
%a{"rel" => "nofollow", "data-method" => "delete", "ng-href" => "{{card.delete_link}}" }
Delete
= t(:delete)
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ en:
saved_cards: Saved cards
add_a_card: Add a Card
add_card: Add Card
you_have_no_saved_cards: You haven't saved any cards yet
saving_credit_card: Saving credit card...
card_has_been_removed: "Your card has been removed (number: %{number})"

Expand Down Expand Up @@ -1341,6 +1342,7 @@ Please follow the instructions there to make your enterprise visible on the Open
edit_order_cycle: "Edit Order Cycle"
roles: "Roles"
update: "Update"
delete: Delete
add_producer_property: "Add producer property"
in_progress: "In Progress"
started_at: "Started at"
Expand Down
15 changes: 14 additions & 1 deletion spec/features/consumer/account/cards_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
include AuthenticationWorkflow
describe "as a logged in user" do
let(:user) { create(:user) }
let!(:card) { create(:credit_card, user_id: user.id) }
let!(:card) { create(:credit_card, user_id: user.id, gateway_customer_profile_id: 'cus_AZNMJ') }

before do
quick_login_as user

stub_request(:get, "https://api.stripe.com/v1/customers/cus_AZNMJ").
to_return(:status => 200, :body => JSON.generate({id: "cus_AZNMJ"}))

stub_request(:delete, "https://api.stripe.com/v1/customers/cus_AZNMJ").
to_return(:status => 200, :body => JSON.generate({deleted: true, id: "cus_AZNMJ"}))
end

it "lists saved cards, shows interface for adding new cards" do
Expand All @@ -22,10 +28,17 @@
expect(page).to have_content card.last_digits
end

# Shows the interface for adding a card
click_button I18n.t(:add_a_card)
expect(page).to have_field 'first_name'
expect(page).to have_field 'card_number'
expect(page).to have_field 'card_month'

# Allows deletion of cards
click_link I18n.t(:delete)

expect(page).to have_content I18n.t(:card_has_been_removed, number: "x-#{card.last_digits}")
expect(page).to have_content I18n.t(:you_have_no_saved_cards)
end
end
end

0 comments on commit 9183360

Please sign in to comment.