2020-05-31 22:38:19 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
describe ContractTemplatePreview do
|
|
|
|
|
describe '#build_releasable' do
|
|
|
|
|
it 'fills missing contract template data' do
|
|
|
|
|
ct = ContractTemplate.new
|
|
|
|
|
ct.release_type = :talent
|
|
|
|
|
preview = ContractTemplatePreview.new(ct)
|
|
|
|
|
expect do
|
|
|
|
|
preview.build_releasable
|
|
|
|
|
end.to change { ct.name }
|
|
|
|
|
.and change { ct.body.to_s }
|
|
|
|
|
.and change { ct.guardian_clause.to_s }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'does not overwrite existing contract template data' do
|
|
|
|
|
ct = build(:contract_template)
|
|
|
|
|
preview = ContractTemplatePreview.new(ct)
|
|
|
|
|
expect do
|
|
|
|
|
preview.build_releasable
|
|
|
|
|
end.to not_change { ct.name }
|
|
|
|
|
.and not_change { ct.body.to_s }
|
|
|
|
|
.and not_change { ct.guardian_clause.to_s }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'fills releasable with dummy data' do
|
|
|
|
|
it 'with guardian details when guardian clause is present' do
|
|
|
|
|
ct = build(:contract_template)
|
|
|
|
|
preview = ContractTemplatePreview.new(ct)
|
|
|
|
|
releasable = preview.build_releasable
|
|
|
|
|
expect(releasable.attributes).to include(expected_dummy_data)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'with guardian details when guardian clause is not present' do
|
|
|
|
|
ct = ContractTemplate.new
|
|
|
|
|
ct.release_type = :appearance
|
|
|
|
|
preview = ContractTemplatePreview.new(ct)
|
|
|
|
|
releasable = preview.build_releasable
|
|
|
|
|
expect(releasable.attributes).to include(expected_dummy_data)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def expected_dummy_data
|
|
|
|
|
{
|
|
|
|
|
'id' => nil,
|
|
|
|
|
'person_first_name' => 'Dummy',
|
|
|
|
|
'person_last_name' => 'Person',
|
2020-06-19 09:23:07 +02:00
|
|
|
'person_address_street1' => 'Street 1',
|
|
|
|
|
'person_address_street2' => 'Street 2',
|
|
|
|
|
'person_address_city' => 'City',
|
|
|
|
|
'person_address_state' => 'State',
|
|
|
|
|
'person_address_zip' => '12345',
|
2020-05-31 22:38:19 +02:00
|
|
|
'person_phone' => '00 111 222 333 4444',
|
|
|
|
|
'updated_at' => nil,
|
|
|
|
|
'minor' => true,
|
2020-06-19 09:23:07 +02:00
|
|
|
'guardian_address_street1' => 'Street 3',
|
|
|
|
|
'guardian_address_street2' => 'Street 4',
|
|
|
|
|
'guardian_address_city' => 'City-2',
|
|
|
|
|
'guardian_address_state' => 'State-2',
|
|
|
|
|
'guardian_address_zip' => '112233',
|
2020-05-31 22:38:19 +02:00
|
|
|
"guardian_first_name" => nil,
|
|
|
|
|
"guardian_last_name" => nil,
|
|
|
|
|
"guardian_name_old" => nil,
|
|
|
|
|
'guardian_phone' => '00 123 456 7890',
|
|
|
|
|
'person_email' => 'email@email.com',
|
|
|
|
|
'locale' => nil,
|
|
|
|
|
'tagging_status' => 'pending',
|
|
|
|
|
'contract_template_id' => nil,
|
|
|
|
|
'applicable_medium_id' => nil,
|
|
|
|
|
'applicable_medium_text' => '',
|
|
|
|
|
'territory_id' => nil,
|
|
|
|
|
'territory_text' => '',
|
|
|
|
|
'term_id' => nil,
|
|
|
|
|
'term_text' => '',
|
|
|
|
|
'restriction_id' => nil,
|
|
|
|
|
'restriction_text' => '',
|
|
|
|
|
'signed_at' => nil,
|
|
|
|
|
'internal_tag_list' => nil,
|
|
|
|
|
'tag_list' => nil
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|