Sha256: 4150a2b5b225b714b72866b0f9e3d763535e825a636409d714e03b09811f421c

Contents?: true

Size: 1.57 KB

Versions: 25

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe "Automatic promotions", :type => :feature, :js => true do
  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) { create(:shipping_method) }
  let!(:payment_method) { create(:check_payment_method) }
  let!(:product) { create(:product, :name => "RoR Mug", :price => 20) }

  let!(:promotion) do
    promotion = Spree::Promotion.create!(:name => "$10 off when you spend more than $100")

   calculator = Spree::Calculator::FlatRate.new
   calculator.preferred_amount = 10

   rule = Spree::Promotion::Rules::ItemTotal.create
   rule.preferred_amount_min = 100
   rule.save

   promotion.rules << rule

   action = Spree::Promotion::Actions::CreateAdjustment.create
   action.calculator = calculator
   action.save

   promotion.actions << action
  end

  context "on the cart page" do

    before do
      visit spree.root_path
      click_link product.name
      click_button "add-to-cart-button"
    end

    it "automatically applies the promotion once the order crosses the threshold" do
      fill_in "order_line_items_attributes_0_quantity", :with => 10
      click_button "Update"
      expect(page).to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
      fill_in "order_line_items_attributes_0_quantity", :with => 1
      click_button "Update"
      expect(page).not_to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
spree_frontend-3.1.5 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.4 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.3 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.2 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.10 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.1 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.0 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.0.rc4 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.9 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.0.rc3 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.0.rc2 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.1.0.rc1 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.8 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.7 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.6.1 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.6 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.5 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.4 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.3 spec/features/automatic_promotion_adjustments_spec.rb
spree_frontend-3.0.2 spec/features/automatic_promotion_adjustments_spec.rb