Sha256: 4fd10808bd598e9cb705b99987616a59dad8366263ee113233cdf338d8b89e92

Contents?: true

Size: 860 Bytes

Versions: 34

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.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

34 entries across 34 versions & 2 rubygems

Version Path
solidus_core-2.8.6 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.6.6 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.7.4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.5 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.7.3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.6.5 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.7.2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.6.4 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.1 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.6.3 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.8.0 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.7.1 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core-2.6.2 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.14 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.13 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.12 spec/models/spree/promotion/rules/user_logged_in_spec.rb
solidus_core_devise_token_auth-2.8.0.alpha.11 spec/models/spree/promotion/rules/user_logged_in_spec.rb