Files
old-holivud2/spec/models/contract_template_spec.rb
2020-05-31 22:38:19 +02:00

45 lines
1.4 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe ContractTemplate do
it_behaves_like 'an exploitable'
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:parent).optional }
it { is_expected.to have_many(:duplicates) }
it { is_expected.to have_many(:talent_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:appearance_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:location_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:material_releases).dependent(:restrict_with_error) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:release_type) }
end
describe '#fee' do
it { is_expected.to monetize(:fee) }
end
describe '#fee?' do
it 'returns true when there is a fee amount' do
fee_contract = build(:contract_template, fee: 500)
no_fee_contract = build(:contract_template, fee: 0)
expect(fee_contract).to be_fee
expect(no_fee_contract).not_to be_fee
end
end
describe '#duplicated?' do
it 'returns true when there is a parent association' do
contract_template = build(:contract_template, parent: build(:contract_template))
expect(contract_template).to be_duplicated
end
end
end