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

47 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe MaterialRelease do
it_behaves_like "a contractable"
it_behaves_like "an exploitable"
it_behaves_like "a notable"
it_behaves_like "a photoable"
it_behaves_like "a releasable"
it_behaves_like "a taggable"
describe "associations" do
it { is_expected.to have_many(:video_release_confirmations).dependent(:destroy) }
end
describe "validations" do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to allow_value("test@test.com", nil).for(:person_email) }
it { is_expected.not_to allow_values("foo", "test@foo", "N/A").for(:person_email) }
context "for native releases" do
it { is_expected.to validate_presence_of(:person_first_name).on(:native) }
it { is_expected.to validate_presence_of(:person_last_name).on(:native) }
it { is_expected.to validate_attachment_of(:signature).on(:native) }
end
end
describe "#uses_edl?" do
it { is_expected.to be_uses_edl }
end
describe "#contract_file_name" do
it "includes project name, release type, signed at date, release number and release name" do
release = create(:material_release_with_contract_template, name: "Coke", person_name: "John Doe", signed_at: DateTime.new(2020, 2, 10, 12, 0, 0))
expect(release.contract_file_name).to eq("my-video-project_material_2020.02.10_1_coke")
end
context "when signer is not present" do
it "includes created at date" do
release = create(:material_release_with_contract_template, name: "Coke", person_name: "John Doe", created_at: DateTime.new(2020, 3, 10, 12, 0, 0))
expect(release.contract_file_name).to eq("my-video-project_material_2020.03.10_1_coke")
end
end
end
end