Files
old-holivud2/spec/models/contract_template_spec.rb
2020-07-03 10:23:03 +02:00

59 lines
1.9 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) }
it { is_expected.to have_many(:medical_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:misc_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
describe '#has_questionnaire?' do
it 'returns true if there are any questions present' do
contract_template = build(:contract_template)
expect(contract_template).not_to have_questionnaire
contract_template.question_1_text = 'Q1'
expect(contract_template).to have_questionnaire
end
end
end