Sha256: f283d95a3e91f4f8b6e48ae5281a2c1afa86a55648e28fb1206bcf9359bda002

Contents?: true

Size: 832 Bytes

Versions: 32

Compression:

Stored size: 832 Bytes

Contents

require 'spec_helper'

describe Spree::Promotion::Rules::UserLoggedIn, :type => :model do
  let(:rule) { Spree::Promotion::Rules::UserLoggedIn.new }

  context "#eligible?(order)" do
    let(:order) { Spree::Order.new }

    it "should be eligible if order has an associated user" do
      user = double('User')
      allow(order).to receive_messages(:user => user)

      expect(rule).to be_eligible(order)
    end

    context "when user is not logged in" do
      before { allow(order).to receive_messages(:user => nil) } # better to be explicit here
      it { expect(rule).not_to be_eligible(order) }
      it "sets an error message" do
        rule.eligible?(order)
        expect(rule.eligibility_errors.full_messages.first).
          to eq "You need to login before applying this coupon code."
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
solidus_core-1.2.3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-1.1.4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-1.0.7 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.5 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.0.10 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.1 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.0 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.0.rc4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.0.9 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.0.rc3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.0.rc2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.1.0.rc1 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-1.0.6 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.0.8 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-1.2.2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
spree_core-3.0.7 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-1.2.1 spec/models/spree/promotion/rules/user_logged_in_spec.rb