Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :account_auth do
association :user
association :account
end
end

View File

@@ -0,0 +1,18 @@
FactoryBot.define do
factory :account do
name "My Team"
plan_uid "me_suite"
trait :mesuite do
plan_uid :me_suite
end
trait :releaseme do
plan_uid :releaseme
end
trait :deliverme do
plan_uid :deliverme
end
end
end

View File

@@ -0,0 +1,37 @@
FactoryBot.define do
factory :acquired_media_release do
association :project
name "Test Acquired Media Release"
trait :native do
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
factory :acquired_media_release_with_contract_template do
after(:build) do |acquired_media_release, _|
acquired_media_release.contract_template = build(:acquired_media_release_contract_template)
end
end
factory :acquired_media_release_with_file_infos do
transient do
file_infos_count { 3 }
end
after(:create) do |acquired_media_release, evaluator|
create_list(:file_info, evaluator.file_infos_count, releasable: acquired_media_release)
end
end
end
end

View File

@@ -0,0 +1,69 @@
FactoryBot.define do
factory :appearance_release do
association :project
person_first_name "Jane"
person_last_name "Doe"
person_photo do
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
trait :native do
person_address "100 Test Lane, New York, NY 10001"
person_phone "123-555-6789"
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
trait :minor do
minor true
guardian_first_name "Jamie"
guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001"
guardian_phone "123-555-1234"
end
trait :minor_with_guardian_photo do
minor true
guardian_first_name "Jamie"
guardian_last_name "Doe"
guardian_address "100 Test Lane, New York, 10001"
guardian_phone "123-555-1234"
guardian_photo do
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
Rack::Test::UploadedFile.new(path, "image/jpeg")
end
end
trait :without_person_photo do
person_photo nil
end
trait :with_person_photo do
person_photo do
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :with_person_photo_only do
end
factory :appearance_release_with_contract_template do
after(:build) do |appearance_release, _|
appearance_release.contract_template = build(:appearance_release_contract_template)
end
end
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :applicable_medium do
label "All"
trait :other do
label "Other"
end
end
end

View File

@@ -0,0 +1,15 @@
FactoryBot.define do
factory :audio_confirmation do
association :video
time_elapsed "5"
confirmation_type "original_music"
trait :library do
confirmation_type "library_music"
end
trait :original do
confirmation_type "original_music"
end
end
end

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :bookmark do
association :video
time_elapsed "5"
end
end

View File

@@ -0,0 +1,8 @@
FactoryBot.define do
factory :broadcast_recording do
association :broadcast
file_name "high.mp4"
asset_uid "asset_uid"
asset_playback_uid "asset_playback_uid"
end
end

View File

@@ -0,0 +1,28 @@
FactoryBot.define do
factory :broadcast do
association :project
name "My Live Stream"
transient do
skip_create_callback false
end
trait :with_stream do
stream_uid "mux_stream"
stream_key "mux_key"
stream_playback_uid "mux_playback_id"
status "created"
streamer_status "idle"
end
trait :with_files do
files { [Rack::Test::UploadedFile.new('spec/fixtures/files/contract.pdf', 'application/pdf')] }
end
after(:build) do |broadcast, evaluator|
if evaluator.skip_create_callback
broadcast.class.skip_callback(:create, :after, :create_mux_live_stream, raise: false)
end
end
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :composer do
association :music_release
name "Beethoven"
affiliation "Affiliation"
percentage 100.0
end
end

View File

@@ -0,0 +1,31 @@
FactoryBot.define do
factory :contract_template do
association :project
name "Test template"
release_type "appearance"
body "This is a test contract template."
guardian_clause "Is the signer a minor?"
fee "$0.00"
factory :appearance_release_contract_template do
release_type "appearance"
end
factory :talent_release_contract_template do
release_type "talent"
end
factory :material_release_contract_template do
release_type "material"
end
factory :location_release_contract_template do
release_type "location"
end
factory :acquired_media_release_contract_template do
release_type "acquired_media"
end
end
end

View File

@@ -0,0 +1,27 @@
FactoryBot.define do
factory :directory do
association :project
association :user
name "Payrolls"
category "Finance"
trait :for_manager do
permissions "Account Managers & Project Managers"
end
trait :for_account_manager do
permissions "Account Managers Only"
end
trait :with_files do
files { [Rack::Test::UploadedFile.new('spec/fixtures/files/location_photo.png', 'image/png')] }
end
file_names = ['location_photo.png', 'material_photo.png', 'person_photo.png']
trait :many_files do
files { 30.times.map { Rack::Test::UploadedFile.new("spec/fixtures/files/#{file_names.sample}", 'image/png') } }
end
end
end

View File

@@ -0,0 +1,24 @@
FactoryBot.define do
factory :download do
association :project
release_type "AppearanceRelease"
trait :with_file do
file do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
factory :download_release_type_appearance do
name "Natgeo Contract"
release_type "AppearanceRelease"
end
factory :download_release_type_music do
name "Discovery Contract"
release_type "MusicRelease"
end
end
end

View File

@@ -0,0 +1,15 @@
FactoryBot.define do
factory :edl_event do
channel "V"
start_time "start_time"
timecode_in "timecode_in"
timecode_out "timecode_out"
duration "duration"
source_file_name "source_file_name"
clip_name "clip_name"
description "description"
matches []
initialize_with { new(attributes) }
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :file_info do
association :releasable, factory: :acquired_media_release
filename "filename.txt"
content_type "text/plain"
byte_size 1_000
end
end

View File

@@ -0,0 +1,8 @@
FactoryBot.define do
factory :graphics_element do
association :video
graphic_type "Logo"
text "some text"
time_elapsed "5"
end
end

12
spec/factories/imports.rb Normal file
View File

@@ -0,0 +1,12 @@
FactoryBot.define do
factory :import do
association :project
end
trait :with_file do
file do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
end

View File

@@ -0,0 +1,59 @@
FactoryBot.define do
factory :location_release do
association :project
name "Test Premises"
trait :native do
person_first_name "Jane"
person_last_name "Doe"
person_phone "100-555-1000"
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
factory :location_release_with_contract_template do
after(:build) do |location_release, _|
location_release.contract_template = build(:location_release_contract_template)
end
end
factory :location_release_with_contract_template_and_photo do
after(:build) do |location_release, _|
location_release.contract_template = build(:location_release_contract_template)
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
location_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :location_release_with_photo do
after(:build) do |location_release, _|
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
location_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :location_release_with_photos do
transient do
photos_count { 2 }
end
after(:build) do |location_release, evaluator|
location_release.photos = evaluator.photos_count.times.map do
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
end
end
end

View File

@@ -0,0 +1,59 @@
FactoryBot.define do
factory :material_release do
association :project
name "Test Materials"
trait :native do
person_first_name "Jane"
person_last_name "Doe"
person_phone "100-555-1001"
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
factory :material_release_with_contract_template do
after(:build) do |material_release, _|
material_release.contract_template = build(:material_release_contract_template)
end
end
factory :material_release_with_contract_template_and_photo do
after(:build) do |material_release, _|
material_release.contract_template = build(:material_release_contract_template)
path = Rails.root.join("spec", "fixtures", "files", "material_photo.png")
material_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :material_release_with_photo do
after(:build) do |material_release, _|
path = Rails.root.join("spec", "fixtures", "files", "material_photo.png")
material_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :material_release_with_photos do
transient do
photos_count { 2 }
end
after(:build) do |material_release, evaluator|
material_release.photos = evaluator.photos_count.times.map do
path = Rails.root.join("spec", "fixtures", "files", "material_photo.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
end
end
end

View File

@@ -0,0 +1,29 @@
FactoryBot.define do
factory :music_release do
association :project
name "OST Test"
person_first_name "John"
person_last_name "Doe"
after(:build) do |music_release, _|
music_release.composers << build(:composer, music_release: music_release) if music_release.composers.empty?
music_release.publishers << build(:publisher, music_release: music_release) if music_release.publishers.empty?
end
factory :music_release_with_contract_template do
after(:build) do |music_release, _|
music_release.contract_template = build(:contract_template)
end
end
factory :music_release_with_file_infos do
transient do
file_infos_count { 3 }
end
after(:create) do |release, evaluator|
create_list(:file_info, evaluator.file_infos_count, releasable: release)
end
end
end
end

7
spec/factories/notes.rb Normal file
View File

@@ -0,0 +1,7 @@
FactoryBot.define do
factory :note do
association :user
association :notable, factory: :appearance_release
content "My note text"
end
end

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :project_membership do
association :project
association :user
end
end

View File

@@ -0,0 +1,64 @@
FactoryBot.define do
factory :project do
association :account
client_name "My Client"
description "This is the video project description."
details "These are the details of the video project. "
name "My Video Project"
producer_address "123 Corporate Lane, New York, NY 10001"
producer_name "Production Company, LLC"
# Enable all release category sections by default
after(:build) do |project, _|
project.settings(:features).attributes = {
acquired_media_release: true,
appearance_release: true,
location_release: true,
material_release: true,
music_release: true,
talent_release: true,
video_analysis: true,
}
end
# Allow team members to be set for a given project
after(:build) do |project, evaluator|
Array.wrap(evaluator.members).each do |member|
next if member.account_manager?(project.account)
project.project_memberships.build(user: member)
end
end
transient do
members { [] }
end
trait :sample do
name "My Sample Video Project"
sample true
end
trait :discovery_client do
predefined_client_name "discovery"
end
trait :nat_geo_client do
predefined_client_name "nat_geo"
end
factory :project_with_contract_template do
after(:build) do |project, _|
project.contract_templates << build(:contract_template, project: nil)
end
end
factory :project_with_directories do
after(:build) do |project, _|
project.directories << build(:directory, project: nil, name: "Shared")
project.directories << build(:directory, :for_manager, project: nil, name: "Financial Documents")
project.directories << build(:directory, :for_account_manager, project: nil, name: "Salaries")
end
end
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :publisher do
association :music_release
name "Jingle Punks"
affiliation "Affiliation"
percentage 100.0
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :restriction do
label "None"
trait :other do
label "Other"
end
end
end

View File

@@ -0,0 +1,65 @@
FactoryBot.define do
factory :talent_release do
association :project
person_first_name "Jane"
person_last_name "Doe"
photos [Rack::Test::UploadedFile.new(Rails.root.join("spec", "fixtures", "files", "person_photo.png"), "image/png")]
trait :native do
person_phone "123-555-6789"
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
trait :minor do
minor true
guardian_first_name "Jamie"
guardian_last_name "Doe"
guardian_phone "123-555-1234"
end
trait :minor_with_guardian_photo do
minor true
guardian_first_name "Jamie"
guardian_last_name "Doe"
guardian_phone "123-555-1234"
guardian_photo do
path = Rails.root.join("spec", "fixtures", "files", "pratt.jpg")
Rack::Test::UploadedFile.new(path, "image/jpeg")
end
end
factory :talent_release_with_contract_template do
after(:build) do |talent_release, _|
talent_release.contract_template = build(:talent_release_contract_template)
end
end
factory :talent_release_with_contract_template_and_photos do
after(:build) do |talent_release, _|
talent_release.contract_template = build(:talent_release_contract_template)
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
talent_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :talent_release_with_photo do
after(:build) do |talent_release, _|
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
talent_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
end
end

9
spec/factories/terms.rb Normal file
View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :term do
label "Worldwide"
trait :other do
label "Other"
end
end
end

View File

@@ -0,0 +1,9 @@
FactoryBot.define do
factory :territory do
label "In Perpetuity"
trait :other do
label "Other"
end
end
end

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :unreleased_appearance do
association :video
time_elapsed "1.5"
end
end

View File

@@ -0,0 +1,8 @@
FactoryBot.define do
factory :user_context do
association :user
association :account
initialize_with { new(user, account) }
end
end

57
spec/factories/users.rb Normal file
View File

@@ -0,0 +1,57 @@
FactoryBot.define do
factory :user do
sequence(:email) { |num| "user-#{num}@test.com" }
password_digest { 'password' }
trait :with_name do
first_name "John"
last_name "Doe"
email "funny@mail.com"
end
trait :with_different_name do
first_name "Specimen"
last_name "Simpson"
email "different@mail.com"
end
after(:create) do |user|
if user.accounts.empty?
account = create(:account)
auth = create(:account_auth, user: user, account: account, role: :account_manager)
user.account_auths << auth
end
end
trait :accountless do
after(:create) do |user|
user.accounts.delete_all
end
end
trait :admin do
admin true
end
trait :account_manager do
after(:create) do |user|
user.update(admin: false)
user.account_auths.update(role: :account_manager)
end
end
trait :manager do
after(:create) do |user|
user.update(admin: false)
user.account_auths.update(role: :project_manager)
end
end
trait :associate do
after(:create) do |user|
user.update(admin: false)
user.account_auths.update(role: :associate)
end
end
end
end

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :video_release_confirmation do
association :video
association :releasable, factory: :appearance_release
end
end

33
spec/factories/videos.rb Normal file
View File

@@ -0,0 +1,33 @@
FactoryBot.define do
factory :video do
association :project
file do
path = Rails.root.join("spec", "fixtures", "files", "video_file.mp4")
Rack::Test::UploadedFile.new(path, "video/mp4")
end
edl_file do
path = Rails.root.join("spec", "fixtures", "files", "sample-edl.edl")
Rack::Test::UploadedFile.new(path, "application/octet-stream")
end
trait :with_graphics_only_edl_file do
graphics_only_edl_file do
path = Rails.root.join("spec", "fixtures", "files", "sample-edl.edl")
Rack::Test::UploadedFile.new(path, "application/octet-stream")
end
end
trait :with_audio_only_edl_file do
audio_only_edl_file do
path = Rails.root.join("spec", "fixtures", "files", "sample-edl.edl")
Rack::Test::UploadedFile.new(path, "application/octet-stream")
end
end
trait :published do
report_published_at 1.day.ago
end
end
end

View File

@@ -0,0 +1,6 @@
FactoryBot.define do
factory :zoom_meeting do
api_meeting_id "zoom_meeting_id"
association :zoom_user, :with_api_id
end
end

View File

@@ -0,0 +1,7 @@
FactoryBot.define do
factory :zoom_user do
trait :with_api_id do
api_id "api_user_id"
end
end
end