Sha256: 06b6bc9c98ecb93ad83d8404b160d50f61002bf6d6ccee198fa5fdce927068fd

Contents?: true

Size: 1.66 KB

Versions: 10

Compression:

Stored size: 1.66 KB

Contents

require "rails_helper"

RSpec.describe ::Dorsale::CustomerVault::Individual, :type => :model do
  it "should have a valid factory" do
    individual = build(:customer_vault_individual)
    expect(individual).to be_valid
  end

  it { is_expected.to have_one(:address).dependent(:destroy) }
  it { is_expected.to belong_to :corporation }
  it { is_expected.to have_many :comments }
  it { is_expected.to have_many :taggings }
  it { is_expected.to have_many :tags }
  it { is_expected.to have_many(:tasks).dependent(:destroy) }
  it { is_expected.to have_many(:comments).dependent(:destroy) }
  it { is_expected.to have_many(:events).dependent(:destroy) }
  it { is_expected.to validate_presence_of :first_name }
  it { is_expected.to validate_presence_of :last_name }

  it { is_expected.to belong_to :activity_type }
  it { is_expected.to belong_to :origin }

  it { is_expected.to respond_to :context }

  describe "activity type" do
    it "should have the same activity than his corporation" do
      corporation = create(:customer_vault_corporation)
      individual = create(:customer_vault_individual, corporation: corporation)
      expect(individual.activity_type).to eq corporation.activity_type
    end

    it "should have no activity if no corporation" do
      individual = create(:customer_vault_individual, corporation: nil)
      expect(individual.activity_type).to eq nil
    end

    it "should have no activity if his corporation has no activity" do
      corporation = create(:customer_vault_corporation, activity_type: nil)
      individual = create(:customer_vault_individual, corporation: corporation)
      expect(individual.activity_type).to eq nil
    end
  end


end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dorsale-3.8.1 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.8.0 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.8 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.7 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.6 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.5 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.4 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.2 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.1 spec/models/dorsale/customer_vault/individual_spec.rb
dorsale-3.7.0 spec/models/dorsale/customer_vault/individual_spec.rb