Sha256: 8b84817f0bbaa8c311ac8d05e0dea0a02bc7f6f2ee1582e5c4fbb78cf7701dbd

Contents?: true

Size: 834 Bytes

Versions: 2

Compression:

Stored size: 834 Bytes

Contents

require 'spec_helper'

describe Spree::ReferredRecord, :type => :model do
  before(:each) do
    @user = FactoryGirl.create(:user, email: Faker::Internet.email)
    @referred = FactoryGirl.create(:user, email:  Faker::Internet.email, referral_code: @user.referral.code)
    @referral_record = @referred.referred_record
  end

  it "has a user id" do
    expect(@referral_record.user_id).not_to be_nil
  end

  it "has a referral id" do
    expect(@referral_record.referral_id).not_to be_nil
  end

  it "returns an associated user record" do
    expect(@referral_record.referral.user).to eq(@user)
  end

  it "returns an associated referred user record" do
    expect(@referral_record.user).to eq(@referred)
  end

  it "returns an associated referral record" do
    expect(@referral_record.referral).to eq(@user.referral)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_reffiliate-2.4.1 spec/models/spree/referred_record_spec.rb
spree_reffiliate-2.3.1 spec/models/spree/referred_record_spec.rb