diff --git a/Gemfile b/Gemfile index 4af8e854b6..543f35fc18 100644 --- a/Gemfile +++ b/Gemfile @@ -126,7 +126,7 @@ group :test, :development do # Pretty printed test output gem 'atomic' gem 'awesome_print' - gem 'capybara', '>= 2.18.0' # 3.0 requires rack 1.6 that only works with Rails 4.2 + gem 'capybara' gem 'database_cleaner', require: false gem "factory_bot_rails", '5.2.0', require: false gem 'fuubar', '~> 2.5.0' diff --git a/Gemfile.lock b/Gemfile.lock index 7a39fe0a06..2752f5f9f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,13 +132,14 @@ GEM builder (3.2.4) byebug (11.0.1) cancan (1.6.10) - capybara (2.18.0) + capybara (3.15.1) addressable mini_mime (>= 0.1.3) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (>= 2.0, < 4.0) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) childprocess (3.0.0) chronic (0.10.2) chunky_png (1.3.14) @@ -550,6 +551,7 @@ GEM nokogiri (~> 1.5) optimist (~> 3.0) redcarpet (3.5.0) + regexp_parser (1.8.2) request_store (1.5.0) rack (>= 1.4) responders (2.4.1) @@ -737,7 +739,7 @@ DEPENDENCIES bugsnag byebug (~> 11.0.0) cancan (~> 1.6.10) - capybara (>= 2.18.0) + capybara catalog! coffee-rails (~> 4.2.2) combine_pdf diff --git a/app/controllers/spree/admin/payments_controller.rb b/app/controllers/spree/admin/payments_controller.rb index 0b5732caa1..8b5f42c472 100644 --- a/app/controllers/spree/admin/payments_controller.rb +++ b/app/controllers/spree/admin/payments_controller.rb @@ -135,7 +135,9 @@ module Spree return unless @payment.payment_method.class == Spree::Gateway::StripeSCA @payment.authorize! - raise Spree::Core::GatewayError, I18n.t('authorization_failure') unless @payment.pending? + return if @payment.pending? && @payment.cvv_response_message.nil? + + raise Spree::Core::GatewayError, I18n.t('authorization_failure') end end end diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 93c1aa9823..3692cb26c1 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -329,7 +329,7 @@ feature ' expect(page).to have_field "variant_price", with: "3.0" expect(page).to have_field "variant_unit_value_with_description", with: "250 (bottle)" expect(page).to have_field "variant_on_hand", with: "9" - expect(page).to have_selector "span[name='on_hand']", "9" + expect(page).to have_selector "span[name='on_hand']", text: "9" select "Volume (L)", from: "variant_unit_with_scale" fill_in "variant_sku", with: "NEWSKU" diff --git a/spec/features/admin/enterprise_relationships_spec.rb b/spec/features/admin/enterprise_relationships_spec.rb index b99341fb46..3dd2c24f99 100644 --- a/spec/features/admin/enterprise_relationships_spec.rb +++ b/spec/features/admin/enterprise_relationships_spec.rb @@ -26,10 +26,9 @@ feature ' # Then I should see the relationships within('table#enterprise-relationships') do - expect(page).to have_relationship e1, e2, ['to add to order cycle'] - expect(page).to have_relationship e2, e3, ['to manage products'] - expect(page).to have_relationship e3, e4, - ['to add to order cycle', 'to manage products'] + expect(page).to have_relationship e1, e2, 'to add to order cycle' + expect(page).to have_relationship e2, e3, 'to manage products' + expect_relationship_with_permissions e3, e4, ['to add to order cycle', 'to manage products'] end end @@ -50,7 +49,7 @@ feature ' # Wait for row to appear since have_relationship doesn't wait expect(page).to have_selector 'tr', count: 2 - expect(page).to have_relationship e1, e2, ['to add to order cycle', 'to add products to inventory', 'to edit profile'] + expect_relationship_with_permissions e1, e2, ['to add to order cycle', 'to add products to inventory', 'to edit profile'] er = EnterpriseRelationship.where(parent_id: e1, child_id: e2).first expect(er).to be_present expect(er.permissions.map(&:name)).to match_array ['add_to_order_cycle', 'edit_profile', 'create_variant_overrides'] @@ -79,7 +78,7 @@ feature ' er = create(:enterprise_relationship, parent: e1, child: e2, permissions_list: [:add_to_order_cycle]) visit admin_enterprise_relationships_path - expect(page).to have_relationship e1, e2, ['to add to order cycle'] + expect(page).to have_relationship e1, e2, 'to add to order cycle' accept_alert do first("a.delete-enterprise-relationship").click @@ -119,9 +118,24 @@ feature ' private - def have_relationship(parent, child, perms = []) - perms = perms.join(' ') + def have_relationship(parent, child, permission = "") + have_table_row [parent.name, 'permits', child.name, permission, ''] + end - have_table_row [parent.name, 'permits', child.name, perms, ''] + def expect_relationship_with_permissions(parent, child, permissions = []) + tr = find_relationship(parent, child) + td = tr.find('td:nth-child(4)') + permissions.each_with_index do |permission, index| + expect(td.find("li:nth-child(#{index + 1})").text).to eq permission + end + end + + def find_relationship(parent, child) + page.all('tr').each do |tr| + return tr if tr.find('td:first-child').text == parent.name && + tr.find('td:nth-child(2)').text == "permits" && + tr.find('td:nth-child(3)').text == child.name + end + raise "relationship not found" end end diff --git a/spec/features/admin/order_cycles/complex_editing_spec.rb b/spec/features/admin/order_cycles/complex_editing_spec.rb index 4b9aa275fc..ea5b3d536a 100644 --- a/spec/features/admin/order_cycles/complex_editing_spec.rb +++ b/spec/features/admin/order_cycles/complex_editing_spec.rb @@ -27,7 +27,7 @@ feature ' expect(page.find('#order_cycle_name').value).to eq(oc.name) expect(page.find('#order_cycle_orders_open_at').value).to eq(oc.orders_open_at.to_s) expect(page.find('#order_cycle_orders_close_at').value).to eq(oc.orders_close_at.to_s) - expect(page).to have_content "COORDINATOR #{oc.coordinator.name}" + expect(page).to have_content "COORDINATOR\n#{oc.coordinator.name}" click_button 'Next' diff --git a/spec/features/admin/payments_stripe_spec.rb b/spec/features/admin/payments_stripe_spec.rb index 1f83d09cac..00c110195a 100644 --- a/spec/features/admin/payments_stripe_spec.rb +++ b/spec/features/admin/payments_stripe_spec.rb @@ -81,8 +81,8 @@ feature ' click_button "Update" expect(page).to have_link "StripeSCA" - expect(page).to have_content "PROCESSING" - expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "processing" + expect(page).to have_content "PENDING" + expect(OrderPaymentFinder.new(order.reload).last_payment.state).to eq "pending" end end end diff --git a/spec/features/admin/product_import_spec.rb b/spec/features/admin/product_import_spec.rb index 6443489cf4..e1b93d1e69 100644 --- a/spec/features/admin/product_import_spec.rb +++ b/spec/features/admin/product_import_spec.rb @@ -534,8 +534,8 @@ feature "Product Import", js: true do proceed_to_validation # Check that all rows are validated. - heading = "120 #{I18n.t('admin.product_import.import.products_to_create')}" - find(".panel-header", text: heading).click + heading = I18n.t('admin.product_import.import.products_to_create') + find(".header-description", text: heading).click expect(page).to have_content "Imported Product 10" expect(page).to have_content "Imported Product 60" expect(page).to have_content "Imported Product 110" diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index fcf5931c73..309bdca9e8 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -304,7 +304,6 @@ feature " # Clearing values manually fill_in "variant-overrides-#{variant.id}-price", with: '' - fill_in "variant-overrides-#{variant.id}-count_on_hand", with: '' select_on_demand variant, :use_producer_settings fill_in "variant-overrides-#{variant.id}-default_stock", with: '' within "tr#v_#{variant.id}" do diff --git a/spec/features/consumer/account/settings_spec.rb b/spec/features/consumer/account/settings_spec.rb index 11dee72750..99abb4e52d 100644 --- a/spec/features/consumer/account/settings_spec.rb +++ b/spec/features/consumer/account/settings_spec.rb @@ -33,7 +33,7 @@ feature "Account Settings", js: true do expect(enqueued_jobs.last.to_s).to match "new@email.com" - expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')} ×" + expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')}\n×" user.reload expect(user.email).to eq 'old@email.com' expect(user.unconfirmed_email).to eq 'new@email.com' @@ -49,7 +49,7 @@ feature "Account Settings", js: true do fill_in 'user_password_confirmation', with: 'NewPassword' click_button I18n.t(:update) - expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')} ×" + expect(find(".alert-box.success").text.strip).to eq "#{I18n.t('spree.account_updated')}\n×" expect(user.reload.encrypted_password).to_not eq initial_password end diff --git a/spec/features/consumer/account_spec.rb b/spec/features/consumer/account_spec.rb index a721235773..84cb4e3731 100644 --- a/spec/features/consumer/account_spec.rb +++ b/spec/features/consumer/account_spec.rb @@ -65,8 +65,8 @@ feature ' href: "#{distributor2.permalink}/shop", count: 1) expect(page).not_to have_content distributor_without_orders.name - expect(page).to have_content distributor1.name + " " + "Balance due" - expect(page).to have_content distributor_credit.name + " Credit" + expect(page).to have_content distributor1.name + "\n" + "Balance due" + expect(page).to have_content distributor_credit.name + "\nCredit" # It reveals table of orders for distributors when clicked expand_active_table_node distributor1.name @@ -98,7 +98,7 @@ feature ' context "without any completed orders" do it "displays an appropriate message" do visit "/account" - expect(page).to have_content { t :you_have_no_orders_yet } + expect(page).to have_content I18n.t(:you_have_no_orders_yet) end end end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index e3557c88ab..25d442bf76 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -42,7 +42,7 @@ feature "Registration", js: true do expect(URI.parse(current_url).path).to eq registration_path # Done reading introduction - page.has_content? + expect(page).to have_text "What do I get?" click_button "Let's get started!" expect(page).to have_content 'Woot!' @@ -53,7 +53,7 @@ feature "Registration", js: true do fill_in 'enterprise_address', with: '123 Abc Street' fill_in 'enterprise_city', with: 'Northcote' fill_in 'enterprise_zipcode', with: '3070' - expect(page).to have_select('enterprise_country', options: %w(Albania Australia), selected: 'Australia') + expect(page).to have_select('enterprise_country', options: ["Albania", "Australia"], selected: 'Australia') select 'Vic', from: 'enterprise_state' click_button "Continue" expect(page).to have_content 'Who is responsible for managing My Awesome Enterprise?' diff --git a/spec/features/consumer/shopping/checkout_stripe_spec.rb b/spec/features/consumer/shopping/checkout_stripe_spec.rb index 06a38adeda..07e1d98607 100644 --- a/spec/features/consumer/shopping/checkout_stripe_spec.rb +++ b/spec/features/consumer/shopping/checkout_stripe_spec.rb @@ -239,6 +239,8 @@ feature "Check out with Stripe", js: true do new_order = create(:order, user: user, order_cycle: order_cycle, distributor: distributor, bill_address_id: nil, ship_address_id: nil) set_order(new_order) add_product_to_cart(new_order, product, quantity: 10) + stub_payment_intents_post_request order: new_order + stub_successful_capture_request order: new_order # Checkout with saved card visit checkout_path diff --git a/spec/features/consumer/shopping/orders_spec.rb b/spec/features/consumer/shopping/orders_spec.rb index f13269f9da..980d51893d 100644 --- a/spec/features/consumer/shopping/orders_spec.rb +++ b/spec/features/consumer/shopping/orders_spec.rb @@ -188,6 +188,6 @@ feature "Order Management", js: true do end def be_confirmed_order_page - have_content /Order #\w+ Confirmed PAID/ + have_content "Order ##{order.number} Confirmed" end end diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb index 4eefb7c114..ce8efc02ae 100644 --- a/spec/features/consumer/shopping/variant_overrides_spec.rb +++ b/spec/features/consumer/shopping/variant_overrides_spec.rb @@ -60,8 +60,8 @@ feature "shopping with variant overrides defined", js: true do it "calculates fees correctly" do page.find("#variant-#{product1_variant1.id} .graph-button").click - expect(page).to have_selector 'li', text: "#{with_currency(55.55)} Item cost" - expect(page).to have_selector 'li', text: "#{with_currency(5.56)} Packing fee" + expect(page).to have_selector 'li', text: "#{with_currency(55.55)}\nItem cost" + expect(page).to have_selector 'li', text: "#{with_currency(5.56)}\nPacking fee" expect(page).to have_selector 'li', text: "= #{with_currency(61.11)}" end diff --git a/spec/views/spree/admin/orders/edit.html.haml_spec.rb b/spec/views/spree/admin/orders/edit.html.haml_spec.rb index 8a8c5b03f8..4394065394 100644 --- a/spec/views/spree/admin/orders/edit.html.haml_spec.rb +++ b/spec/views/spree/admin/orders/edit.html.haml_spec.rb @@ -31,9 +31,9 @@ describe "spree/admin/orders/edit.html.haml" do it "displays order shipping costs, transaction fee and order total" do render - expect(rendered).to have_content("Shipping: UPS Ground $6.00") - expect(rendered).to have_content("Transaction fee: $10.00") - expect(rendered).to have_content("Order Total $36.00") + expect(rendered).to have_content("Shipping Method\nUPS Ground $6.00") + expect(rendered).to have_content("Transaction fee:\n\n$10.00") + expect(rendered).to have_content("Order Total\n$36.00") end end end diff --git a/spec/views/spree/shared/_order_details.html.haml_spec.rb b/spec/views/spree/shared/_order_details.html.haml_spec.rb index 60e95ac0f6..76777a363f 100644 --- a/spec/views/spree/shared/_order_details.html.haml_spec.rb +++ b/spec/views/spree/shared/_order_details.html.haml_spec.rb @@ -21,7 +21,7 @@ describe "spree/shared/_order_details.html.haml" do render - expect(rendered).to have_content("Paying via: Bartering") + expect(rendered).to have_content("Paying via:\nBartering") end it "displays payment methods safely" do @@ -29,7 +29,7 @@ describe "spree/shared/_order_details.html.haml" do render - expect(rendered).to have_content("Paying via: Barter→ing") + expect(rendered).to have_content("Paying via:\nBarter→ing") end it "shows the last used payment method" do @@ -51,6 +51,6 @@ describe "spree/shared/_order_details.html.haml" do render - expect(rendered).to have_content("Paying via: Credit") + expect(rendered).to have_content("Paying via:\nCredit") end end