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