Sha256: a7ac12f1475ac3fef0fc68dfaa8d32c72f8879dcbc28c15630dd316a1c6e071b

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

RSpec.feature "Promotion Code Invalidation" do
  given!(:promotion) do
    FactoryBot.create(
      :promotion_with_item_adjustment,
      code: "PROMO",
      per_code_usage_limit: 1,
      adjustment_rate: 5
    )
  end

  background do
    create(:store)
    FactoryBot.create(:product, name: "DL-44")
    FactoryBot.create(:product, name: "E-11")

    visit spree.root_path
    click_link "DL-44"
    click_button "Add To Cart"

    visit spree.root_path
    click_link "E-11"
    click_button "Add To Cart"
  end

  scenario "adding the promotion to a cart with two applicable items" do
    fill_in "Coupon code", with: "PROMO"
    click_button "Update"

    expect(page).to have_content("The coupon code was successfully applied to your order")

    within("#cart_adjustments") do
      expect(page).to have_content("-$10.00")
    end

    # Remove an item
    fill_in "order_line_items_attributes_0_quantity", with: 0
    click_button "Update"
    within("#cart_adjustments") do
      expect(page).to have_content("-$5.00")
    end

    # Add it back
    visit spree.root_path
    click_link "DL-44"
    click_button "Add To Cart"
    within("#cart_adjustments") do
      expect(page).to have_content("-$10.00")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_frontend-2.5.2 spec/features/promotion_code_invalidation_spec.rb
solidus_frontend-2.5.1 spec/features/promotion_code_invalidation_spec.rb
solidus_frontend-2.5.0 spec/features/promotion_code_invalidation_spec.rb
solidus_frontend-2.5.0.rc1 spec/features/promotion_code_invalidation_spec.rb
solidus_frontend-2.5.0.beta2 spec/features/promotion_code_invalidation_spec.rb
solidus_frontend-2.5.0.beta1 spec/features/promotion_code_invalidation_spec.rb