require 'test_helper' module Workarea decorate Storefront::Accounts::CreditCardsSystemTest, with: :murals_your_way do def test_managing_credit_cards visit storefront.accounts_path click_link t('workarea.storefront.users.add_credit_card') within '#credit_card_form' do fill_in 'credit_card[number]', with: '4111111111111111' fill_in 'credit_card[first_name]', with: 'Ben' fill_in 'credit_card[last_name]', with: 'Crouse' select '1', from: 'credit_card[month]' select @year, from: 'credit_card[year]' fill_in 'credit_card[cvv]', with: '999' click_button t('workarea.storefront.forms.save') end assert(page.has_content?('Success')) assert(page.has_content?('ending in 1111')) assert(page.has_content?('1')) assert(page.has_content?(@year)) click_link t('workarea.storefront.forms.edit') within '#credit_card_form' do select '2', from: 'credit_card[month]' fill_in 'credit_card[cvv]', with: '999' click_button t('workarea.storefront.forms.save') end assert(page.has_content?('Success')) assert(page.has_content?('ending in 1111')) assert(page.has_content?('2')) assert(page.has_content?(@year)) click_button t('workarea.storefront.forms.delete') assert(page.has_no_content?('ending in 1111')) visit storefront.new_users_credit_card_path within '#credit_card_form' do fill_in 'credit_card[number]', with: '401200003333042211' fill_in 'credit_card[first_name]', with: 'Ben' fill_in 'credit_card[last_name]', with: 'Crouse' select '1', from: 'credit_card[month]' select @year, from: 'credit_card[year]' fill_in 'credit_card[cvv]', with: '999' click_button t('workarea.storefront.forms.save') end refute(page.has_content?('Success')) assert(page.has_content?(I18n.t('workarea.payment.store_credit_card_failure'))) end end end