Sha256: 754651e6da51dc9ac8530a6c4544cc126b9b610aa11cc24e309b1bdd76d14170

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

require 'spec_helper'

describe Spree::Promotion::Rules::ReferredPromotionRule, :type => :model do
  before(:each) do
    @rule = FactoryGirl.build(:referred_promotion_rule)
    @user = FactoryGirl.create(:user, email: Faker::Internet.email)
    @referred = FactoryGirl.create(:user, email: Faker::Internet.email, referral_code: @user.referral.code)
    @organic_order = FactoryGirl.create(:order, :user => @user)
    @referred_order = FactoryGirl.create(:order, :user => @referred)
  end
  it "is applicable for an order" do
    expect(@rule.applicable?(@referred_order)).to be_truthy
  end
  it "is elegible for referred user" do
    expect(@rule.eligible?(@referred_order)).to be_truthy
  end
  it "is not elegible for organic user" do
    expect(@rule.eligible?(@organic_order)).to be_falsy
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_reffiliate-2.4.1 spec/models/spree/promotion/rules/referred_promotion_rule_spec.rb
spree_reffiliate-2.3.1 spec/models/spree/promotion/rules/referred_promotion_rule_spec.rb