Sha256: 2e8a96f95ab92d9957b4a0b3f42efe3171dc5da6de4fd877b196f67c93e948ad

Contents?: true

Size: 1.58 KB

Versions: 47

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe "Adjustments Promotions", type: :feature do
  stub_authorization!

  before(:each) do
    create(:promotion_with_item_adjustment,
           name: "$10 off",
           path: 'test',
           code: "10_off",
           starts_at: 1.day.ago,
           expires_at: 1.day.from_now,
           adjustment_rate: 10)

    order = create(:order_with_totals)
    line_item = order.line_items.first
    # so we can be sure of a determinate price in our assertions
    line_item.update_column(:price, 10)

    visit spree.admin_order_adjustments_path(order)
  end

  context "admin adding a promotion" do
    context "successfully" do
      it "should create a new adjustment", js: true do
        fill_in "coupon_code", with: "10_off"
        click_button "Add Coupon Code"
        expect(page).to have_content("$10 off")
        expect(page).to have_content("-$10.00")
      end
    end

    context "for non-existing promotion" do
      it "should show an error message", js: true do
        fill_in "coupon_code", with: "does_not_exist"
        click_button "Add Coupon Code"
        expect(page).to have_content("doesn't exist.")
      end
    end

    context "for already applied promotion" do
      it "should show an error message", js: true do
        fill_in "coupon_code", with: "10_off"
        click_button "Add Coupon Code"
        expect(page).to have_content('-$10.00')

        fill_in "coupon_code", with: "10_off"
        click_button "Add Coupon Code"
        expect(page).to have_content("already been applied")
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 2 rubygems

Version Path
solidus_backend-2.10.5 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.10.3 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.10.2 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.6 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.8.6 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.10.1 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.5 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.10.0 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.4 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.6.6 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.7.4 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.8.5 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.3 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.2 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.10.0.beta1 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.7.3 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.6.5 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.1 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.0 spec/features/admin/orders/adjustments_promotions_spec.rb
solidus_backend-2.9.0.rc.1 spec/features/admin/orders/adjustments_promotions_spec.rb