Sha256: 476018451a4a19b0856ed31c94020ba8fd2668903c894ca40531a6af6d84a83b

Contents?: true

Size: 1.9 KB

Versions: 26

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe "Free shipping promotions", type: :feature, js: true do
  let!(:store) { create(:store) }
  let!(:country) { create(:country, name: "United States of America", states_required: true) }
  let!(:state) { create(:state, name: "Alabama", country: country) }
  let!(:zone) { create(:zone) }
  let!(:shipping_method) do
    sm = create(:shipping_method)
    sm.calculator.preferred_amount = 10
    sm.calculator.save
    sm
  end

  let!(:payment_method) { create(:check_payment_method) }
  let!(:product) { create(:product, name: "RoR Mug", price: 20) }
  let!(:promotion) do
    create(
      :promotion,
      apply_automatically: true,
      promotion_actions: [Spree::Promotion::Actions::FreeShipping.new],
      name: "Free Shipping",
      starts_at: 1.day.ago,
      expires_at: 1.day.from_now,
    )
  end

  context "free shipping promotion automatically applied" do
    before do
      visit spree.root_path
      click_link "RoR Mug"
      click_button "add-to-cart-button"
      click_button "Checkout"
      fill_in "order_email", with: "spree@example.com"
      fill_in "First Name", with: "John"
      fill_in "Last Name", with: "Smith"
      fill_in "Street Address", with: "1 John Street"
      fill_in "City", with: "City of John"
      fill_in "Zip", with: "01337"
      select country.name, from: "Country"
      select state.name, from: "order[bill_address_attributes][state_id]"
      fill_in "Phone", with: "555-555-5555"

      # To shipping method screen
      click_button "Save and Continue"
      # To payment screen
      click_button "Save and Continue"
    end

    # Regression test for https://github.com/spree/spree/issues/4428
    it "applies the free shipping promotion" do
      within("#checkout-summary") do
        expect(page).to have_content("Shipping total:  $10.00")
        expect(page).to have_content("Promotion (Free Shipping): -$10.00")
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
solidus_frontend-2.5.2 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.5.1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.5.0 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.5.0.rc1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.5.0.beta2 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.5.0.beta1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.4.2 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.2.2 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.4.1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.1.1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.4.0 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.4.0.rc1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.4.0.beta1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.0 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.0.rc3 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.0.rc2 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.0.rc1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.3.0.beta1 spec/features/free_shipping_promotions_spec.rb
solidus_frontend-2.2.1 spec/features/free_shipping_promotions_spec.rb