Files
old-holivud2/spec/models/location_release_spec.rb
2020-08-24 15:52:23 +02:00

58 lines
2.2 KiB
Ruby

require "rails_helper"
RSpec.describe LocationRelease do
it_behaves_like 'an approvable'
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
it "ensures that film start date is before film end date" do
location_release = build(:location_release, filming_started_on: 1.day.ago, filming_ended_on: 3.days.ago)
expect(location_release).not_to be_valid
expect(location_release.errors[:filming_ended_on]).to include("must be after the filming started on date")
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 location name" do
release = create(:location_release_with_contract_template, name: "Benny's Burritos", signed_at: DateTime.new(2020, 2, 10, 12, 0, 0))
expect(release.contract_file_name).to eq("my-video-project_location_2020.02.10_1_benny-s-burritos")
end
context "when signature timestamp is nil" do
it "uses created at date" do
release = create(:location_release_with_contract_template,
name: "Benny's Burritos",
signed_at: nil,
created_at: DateTime.new(2020, 2, 10, 12, 0, 0))
expect(release.contract_file_name).to eq("my-video-project_location_2020.02.10_1_benny-s-burritos")
end
end
end
end