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

40 lines
1.3 KiB
Ruby

require 'rails_helper'
describe UnreleasedAppearance do
describe 'associations' do
it { is_expected.to belong_to(:video) }
end
describe 'validations' do
it do
is_expected.to validate_presence_of(:time_elapsed)
is_expected.to validate_presence_of(:note_category)
end
end
describe "enums" do
it { is_expected.to define_enum_for(:note_category).with_values([:other, :missing_talent_release, :missing_appearance_release, :missing_location_release, :missing_acquired_media_license, :missing_materials_release, :missing_music_license, :logo_may_require_blurring]) }
end
describe ".note_text" do
let(:unreleased_appearance) do
create(:unreleased_appearance)
end
it "returns notes field in case category is 'other'" do
unreleased_appearance.notes = "good note"
result = unreleased_appearance.note_text
expect(result).to eq "good note"
end
it "returns human readable predefined value if category is not 'other'" do
UnreleasedAppearance.note_categories.each_pair do |category, value|
next if category == 'other'
unreleased_appearance.note_category = category
result = unreleased_appearance.note_text
expect(result).to eq unreleased_appearance.note_category.humanize
end
end
end
end