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,117 @@
require "rails_helper"
feature "Account manager managing account members" do
scenario "promoting an asssociate to project manager" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :associate, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Associate"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Project Manager", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Project Manager"
end
scenario "demoting a project manager to associate" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :manager, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Project Manager"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Associate", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Associate"
end
scenario "promoting an asssociate to account manager" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :associate, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Associate"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Account Manager", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Account Manager"
end
scenario "demoting an account manager to associate" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :account_manager, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Account Manager"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Associate", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Associate"
end
scenario "promoting a project_manager to account manager" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :manager, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Project Manager"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Account Manager", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Account Manager"
end
scenario "demoting an account manager to associate" do
account = create(:account)
account_manager = create(:user, :account_manager, primary_account: account)
associate = create(:user, :account_manager, primary_account: account, email: "associate.user@test.com")
sign_in account_manager
visit account_auths_path
expect(page).to have_content "Account Manager"
within "#account_auth_#{associate.account_auths.first.id}" do
select "Project Manager", from: "Role"
click_on "Change Role"
end
expect(page).to have_content "Role has been updated"
expect(page).to have_content "Project Manager"
end
end

View File

@@ -0,0 +1,164 @@
require "rails_helper"
feature "Admin managing accounts" do
let(:current_user) { create(:user, admin: true, email: "user@test.com") }
let(:another_user) { create(:user, admin: false, email: "user2@test.com", accounts: current_user.accounts) }
let(:project) { create(:project, account: current_user.primary_account) }
scenario "creates a new account" do
sign_in current_user
visit admin_signed_in_root_path
click_link "New Account"
fill_in "Name", with: "MGM"
select "ME Suite", from: "Plan"
click_on "Create Account"
expect(page).to have_content "The account was created"
expect(page).to have_content /MGM/
expect(page).to have_content /Add Account Manager/
end
scenario "sees account details" do
sign_in current_user
visit admin_signed_in_root_path
click_button "Manage"
click_link "Overview"
expect(page).to have_content "ME Suite"
expect(page).to have_content "Users 1"
expect(page).to have_content "Created at less than a minute ago"
end
scenario "sees videos for an account in the system" do
visit_account_overview_page
expect(page).to have_content "Videos"
expect(page).to have_content "Name My Video"
by "clicking on Analysis link can navigate to video analysis page" do
click_button "Manage"
click_link "Analysis"
expect(page.current_path).to eq video_video_analyses_path(I18n.locale, @video_1)
end
end
scenario "re-analyzes the video" do
visit_account_overview_page
by "clicking on Re-analyze link can navigate to video analysis page" do
click_button "Manage"
click_link "Re-analyze"
expect(page).to have_content t("video_analyses.create.notice")
expect(page.current_path).to eq video_video_analyses_path(I18n.locale, @video_1)
end
end
scenario "manages users in an account" do
another_account = create(:account, name: "New Account")
user = create(:user, admin: false, email: "user@example.com")
user.account_auths << AccountAuth.create(user: user, account: current_user.primary_account, role: :account_manager)
sign_in current_user
visit admin_signed_in_root_path
within "#account_#{current_user.primary_account.id}" do
click_button "Manage"
click_link "Account Managers"
end
expect(page).to have_content "user@example.com"
end
scenario "manages an account" do
sign_in current_user
visit admin_signed_in_root_path
click_button "Manage"
click_link "Edit"
expect(page).to have_content "Edit Account"
by "updating an account" do
fill_in "Name", with: "Another Team"
click_button "Update Account"
end
expect(page).to have_content "Another Team"
end
scenario "sees information for each account in the system" do
mgm = create(:account, name: "MGM", users: build_list(:user, 1, email: "user@mgm.com"), projects: build_list(:project, 1))
discovery = create(:account, name: "Discovery", users: [build(:user, email: "user1@discovery.com"), build(:user, email: "user2@discovery.com")])
video_1 = create(:video, project: mgm.projects.first)
path = Rails.root.join("spec", "fixtures", "files", "video_file_1m.mp4")
longer_file = Rack::Test::UploadedFile.new(path, "video/mp4")
video_2 = create(:video, project: mgm.projects.first, file: longer_file)
video_3 = create(:video, project: mgm.projects.first, file: longer_file, created_at: 1.month.ago)
video_1.file.blob.analyze
video_2.file.blob.analyze
video_3.file.blob.analyze
sign_in current_user
visit profile_path
click_link "Admin"
expect(page).to have_content /Name Plan # Projects Monthly Video Upload Minutes Total Video Upload Minutes Total Storage Created At/
expect(page).to have_content /MGM ME Suite 1 1 minutes 2 minutes 6.74 MB/
expect(page).to have_content /Discovery ME Suite 0 0 minutes 0 minutes 0 Bytes/
end
scenario "Uses the search button to filter accounts", js: true do
sign_in current_user
create(:account, name: "First account")
create(:account, name: "Second account")
visit admin_accounts_path
expect(page).to have_content("First account")
expect(page).to have_content("Second account")
fill_in "query", with: "First"
click_button "search-button"
expect(page).to have_content("First account")
expect(page).not_to have_content("Second_account")
end
scenario "Uses search button to filter videos in account overview", js: true do
sign_in current_user
account = create(:account, name: "User accound")
project = create(:project, account: account)
create(:video, name: "First Video", project: project)
create(:video, name: "Second Video", project: project)
visit admin_account_path(account)
expect(page).to have_content("First Video")
expect(page).to have_content("Second Video")
fill_in "query", with: "First"
click_button "search-button"
expect(page).to have_content("First Video")
expect(page).not_to have_content("Second Video")
end
def visit_account_overview_page
@video_1 = create(:video, project: project)
@video_1.file.blob.analyze
VideoAnalysis.use_overlay_video = false
allow(BrayniacAI::EdlParse).to receive(:create).and_return(
BrayniacAI::EdlParse.new({ results: [], edl_timecode_start: "00:00:00:00" })
)
sign_in current_user
visit admin_signed_in_root_path
click_button "Manage"
click_link "Overview"
end
end

View File

@@ -0,0 +1,123 @@
require "rails_helper"
feature "Admin managing users" do
let(:current_user) { create(:user, admin: true, email: "user@test.com") }
let(:project) { create(:project, account: current_user.primary_account) }
before do
sign_in current_user
end
scenario "creates a new user" do
visit admin_users_path
click_link "New User"
fill_in "Email", with: "bob@example.com"
fill_in "Password", with: "password"
select "My Team", from: "Account"
check "Admin User"
select "Account Manager", from: "Role"
click_on "Create User"
expect(page).to have_content "The user was created"
end
scenario "sees list of users" do
visit admin_users_path
expect(page).to have_content "user@test.com"
expect(page).to have_content "account_manager"
expect(page).to have_content current_user.primary_account.name
end
context "searchs for users" do
before do
create(:user, :with_name)
create(:user, :with_different_name)
visit admin_users_path
end
scenario "shows all users when query is empty", js: true do
expect(page).to have_selector "form#search"
expect(page).to have_content "John"
expect(page).to have_content "Specimen"
end
scenario "shows only users matching search query", js: true do
within "form#search" do
fill_in "Search users", with: "John"
click_on "button"
end
expect(page).to have_content "John"
expect(page).not_to have_content "Specimen"
end
scenario "shows no users matching search query", js: true do
within "form#search" do
fill_in "Search users", with: "nonexisting"
click_on "button"
end
expect(page).not_to have_content "John"
expect(page).not_to have_content "Specimen"
end
end
scenario "manages users" do
another_user = create(:user, admin: false, email: "user2@test.com", accounts: current_user.accounts)
note_author_user = create(:user, admin: false, email: "writer@test.com", accounts: current_user.accounts)
create(:note, user: note_author_user, email: note_author_user.email)
visit admin_users_path
by "clicking Edit button can update existing users" do
within "#user_#{another_user.id}" do
click_on "Manage"
click_link "Edit"
end
expect(page).to have_content("Edit User")
fill_in "Email", with: "user-updated@example.com"
check "Admin User"
click_button "Update User"
expect(page).not_to have_content("user2@test.com")
click_link "Users"
expect(page).to have_content("user-updated@example.com associate")
end
by "clicking Delete button can remove existing users" do
sign_in current_user
visit admin_users_path
within "#user_#{another_user.id}" do
click_on "Manage"
click_link "Delete"
end
expect(page).not_to have_content "user2@test.com"
expect(page).to have_content user_deleted_message
end
by "clicking Delete button can remote users who posted ntoes" do
sign_in current_user
visit admin_users_path
within "#user_#{note_author_user.id}" do
click_on "Manage"
click_link "Delete"
end
expect(page).not_to have_content "writer@test.com"
expect(page).to have_content user_deleted_message
end
end
private
def user_deleted_message
t "admin.users.destroy.alert"
end
end

View File

@@ -0,0 +1,36 @@
require "rails_helper"
feature "Admin masquerading as an user" do
let!(:current_user) { create(:user, admin: true, email: "me@test.com") }
let!(:another_user) { create(:user, admin: false, email: "them@test.com") }
let(:project) { create(:project, account: current_user.primary_account) }
scenario "masquerades as user and stops" do
my_project = create(:project, name: "My Project", account: current_user.primary_account)
another_project = create(:project, name: "Their Project", account: another_user.primary_account)
sign_in current_user
visit admin_users_path
click_link "Masquerade"
expect(page).not_to have_content("me@test.com")
expect(page).to have_content("them@test.com")
expect(page).to have_content("Their Project")
expect(page).not_to have_content("My Project")
expect(page).to have_content "Stop Masquerading"
click_link "Stop Masquerading"
expect(page).to have_content("me@test.com")
expect(page).to have_content("them@test.com")
expect(page).to have_content("Masquerade")
visit projects_path
expect(page).to have_content("me@test.com")
expect(page).not_to have_content("them@test.com")
expect(page).to have_content("My Project")
expect(page).not_to have_content("Their Project")
expect(page).not_to have_content "Stop Masquerading"
end
end

View File

@@ -0,0 +1,41 @@
require "rails_helper"
feature "Guest account sign up" do
scenario "creates a new account and signs in successfully" do
visit new_account_path
fill_in "Email", with: "user+1@test.com"
fill_in "Password", with: "password"
fill_in "Account Name", with: "Test Account"
click_on "Start Free Trial"
expect(page).to have_content "We are excited to help you organize and automate your media projects. Click below to create your first project and get started."
expect(page).to have_content "Welcome"
expect(page).to have_link "Create Your First Project"
end
scenario "navivates to new account page when account creation fails" do
visit new_account_path
fill_in "Email", with: "user+1@test.com"
fill_in "Password", with: "password"
fill_in "Account Name", with: ""
click_on "Start Free Trial"
expect(page).to have_content "Sign Up"
end
scenario "navivates to new account page when user creation fails" do
visit new_account_path
fill_in "Email", with: ""
fill_in "Password", with: "password"
fill_in "Account Name", with: "Test Account"
click_on "Start Free Trial"
expect(page).to have_content "Sign Up"
end
end

View File

@@ -0,0 +1,106 @@
require "rails_helper"
feature "User creates notes" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
shared_examples "a notable collection UI", js: true do
specify do
sign_in current_user
visit polymorphic_path [subject.project, subject.model_name.plural]
by "not adding content to the note" do
open_notes_modal(subject)
submit_notes_modal(subject, notes: "")
expect(page).to have_css(".invalid-feedback", text: "can't be blank")
end
by "adding content to the note" do
submit_notes_modal(subject, notes: "Test note!")
expect(page).to have_note_for(subject, "Test note!")
end
by "adding another note" do
add_notes_to(subject, notes: "Another note")
expect(page).to have_note_for(subject, "Another note")
expect(page).to have_more_notes_for(subject)
end
by "viewing all the notes" do
open_notes_list_for(subject)
expect(page).to have_css(".list-group-item", text: "Test note!")
expect(page).to have_css(".list-group-item", text: "Another note")
end
end
def open_notes_modal(release)
click_button "Manage"
click_link "Notes"
end
def submit_notes_modal(release, notes:)
action = url_for([release, :notes, only_path: true])
notes_form = "form[action='#{action}']"
within notes_form do
fill_in "Content", with: notes
click_button "Create Note"
end
end
def add_notes_to(release, notes:)
open_notes_modal(release)
submit_notes_modal(release, notes: notes)
end
def have_note_for(release, notes)
have_selector("td", text: notes)
end
def have_more_notes_for(release)
notes_path = url_for [release, :notes, only_path: true]
have_link("more note", href: notes_path) # , visible: :all)
end
def open_notes_list_for(release)
notes_path = url_for [release, :notes, only_path: true]
click_link "more note", href: notes_path
end
end
context "for appearance releases" do
subject! { create(:appearance_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
context "for talent releases" do
subject! { create(:talent_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
context "for location releases" do
subject! { create(:location_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
context "for material releases" do
subject! { create(:material_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
context "for acquired media releases" do
subject! { create(:acquired_media_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
context "for music releases" do
subject! { create(:music_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
end

View File

@@ -0,0 +1,89 @@
require "rails_helper"
feature "User creates tags" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
shared_examples "a taggable collection UI", js: true do
specify do
sign_in current_user
visit polymorphic_path [subject.project, subject.model_name.plural]
by "adding tag" do
open_tags_modal(subject)
submit_tags_modal(subject, tags: "Test tag!")
expect(page).to have_content("Test tag!")
click_button "Close"
within "##{ActionController::Base.helpers.dom_id(subject, "tags_preview")}" do
expect(page).to have_content("Test tag!")
end
end
by "removing tag" do
open_tags_modal(subject)
submit_tags_modal(subject, tags: "Test tag!")
remove_tags
expect(page).not_to have_content("Test tag!")
click_button "Close"
within "##{ActionController::Base.helpers.dom_id(subject, "tags_preview")}" do
expect(page).not_to have_content("Test tag!")
end
end
end
def open_tags_modal(release)
click_button "Manage"
click_link "Tags"
end
def submit_tags_modal(release, tags:)
action = url_for([release, :acts_as_taggable_on_tags, only_path: true])
tags_form = "form[action='#{action}']"
within tags_form do
fill_in "Name", with: tags
click_button "Add"
end
end
def remove_tags
click_link "Remove"
end
end
context "for appearance releases" do
subject! { create(:appearance_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for talent releases" do
subject! { create(:talent_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for location releases" do
subject! { create(:location_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for material releases" do
subject! { create(:material_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for acquired media releases" do
subject! { create(:acquired_media_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for music releases" do
subject! { create(:music_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
end

View File

@@ -0,0 +1,9 @@
require "rails_helper"
feature "User has cookies disabled" do
scenario "the cookie disabled page", js: true do
visit cookies_disabled_path
expect(page).to have_content("Cookies are disabled")
end
end

View File

@@ -0,0 +1,54 @@
require "rails_helper"
feature "User imports release templates", type: :feature do
let(:current_user) { create(:user, :account_manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
let(:project_one) { create(:project, name: "Avengers", members: [current_user], account: current_user.primary_account) }
let!(:project_one_template) { create(:contract_template, name: "First Contract Template", fee: 50, release_type: "appearance", project: project_one) }
let(:project_two) { create(:project, name: "Justice League", members: [], account: current_user.primary_account) }
let!(:project_two_template) { create(:contract_template, name: "Second Contract Template", fee: 50, release_type: "talent", project: project_two) }
before do
sign_in(current_user)
end
scenario "importing two existing templates into a project" do
visit project_contract_templates_path(project)
click_on "Import Release Template"
select_templates([project_one_template.id, project_two_template.id])
click_on "Import Selected Templates"
expect(page).to have_content("Selected templates were imported with success")
expect(page).to have_content("First Contract Template")
expect(page).to have_content("Second Contract Template")
end
scenario "preventing import of already imported template" do
release_template_ids = [project_one_template.id, project_two_template.id]
project.import_contract_templates(release_template_ids)
visit project_contract_templates_path(project)
expect(page).not_to have_button("Import Selected Templates")
end
scenario "searching for a template", js: true do
visit project_contract_templates_path(project)
click_on "Import Release Template"
fill_in "query", with: "Second"
click_on "search-button"
expect(page).not_to have_content("First Contract Template")
expect(page).to have_content("Second Contract Template")
fill_in "query", with: "Avengers"
click_on "search-button"
expect(page).to have_content("First Contract Template")
expect(page).not_to have_content("Second Contract Template")
end
private
def select_templates(template_ids)
template_ids.each do |id|
find(:css, "input[name='template_ids[]'][value='#{id}']").set(true)
end
end
end

View File

@@ -0,0 +1,49 @@
require "rails_helper"
RSpec.feature "User can see directories on project page", type: :feature do
before do
sign_in(user)
end
let!(:project) { create(:project_with_directories, members: user, account: user.primary_account) }
context "User is an associate" do
let(:user) { create(:user, :associate) }
scenario "user is associate" do
visit project_path(project)
expect(page).to have_link("Add Folder")
expect(page).to have_content("Shared")
expect(page).not_to have_content("Financial Documents")
expect(page).not_to have_content("Salaries")
end
end
context "User is a project manager" do
let(:user) { create(:user, :manager) }
scenario "user is associate" do
visit project_path(project)
expect(page).to have_link("Add Folder")
expect(page).to have_content("Shared")
expect(page).to have_content("Financial Documents")
expect(page).not_to have_content("Salaries")
end
end
context "User is a account manager" do
let(:user) { create(:user, :account_manager) }
let!(:project) { create(:project_with_directories, account: user.primary_account) }
scenario "user is associate" do
visit project_path(project)
expect(page).to have_link("Add Folder")
expect(page).to have_content("Shared")
expect(page).to have_content("Financial Documents")
expect(page).to have_content("Salaries")
end
end
end

View File

@@ -0,0 +1,240 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.feature 'User manages contract templates', type: :feature do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
before do
sign_in(current_user)
end
scenario 'creating a new release template' do
visit new_project_contract_template_path(project)
fill_in 'Name', with: 'My Release Template'
select 'Appearance Release', from: 'Release type'
fill_in_trix body_field, with: 'You agree to this release.'
fill_hidden guardian_clause_field, with: 'Your minor agrees to this release.'
select 'All', from: 'Applicable Media'
select 'Other', from: 'Territory'
fill_in 'Describe other territory', with: 'North America only'
select 'In perpetuity', from: 'Term'
select 'None', from: 'Restriction'
click_on 'Create Release Template'
expect(page).to have_content('The release template has been created')
end
scenario 'preview new talent release template without guardian clause' do
visit new_project_contract_template_path(project)
select 'Talent Release', from: 'Release type'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Talent Release')
expect(pdf_body).to have_content('Body text goes here')
expect(pdf_body).to have_content('Guardian')
end
scenario 'preview new talent release template with guardian clause' do
visit new_project_contract_template_path(project)
select 'Talent Release', from: 'Release type'
fill_hidden guardian_clause_field, with: 'Your minor agrees to this release.'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Talent Release')
expect(pdf_body).to have_content('Body text goes here')
expect(pdf_body).to have_content('Guardian')
expect(pdf_body).to have_content('Your minor')
end
scenario 'preview new appearance release template without guardian clause' do
visit new_project_contract_template_path(project)
select 'Appearance Release', from: 'Release type'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Appearance Release')
expect(pdf_body).to have_content('Body text goes here')
expect(pdf_body).to have_content('Guardian')
end
scenario 'preview new appearance release template with guardian clause' do
visit new_project_contract_template_path(project)
select 'Appearance Release', from: 'Release type'
fill_hidden guardian_clause_field, with: 'Your minor agrees to this release.'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Appearance Release')
expect(pdf_body).to have_content('Body text goes here')
expect(pdf_body).to have_content('Guardian')
expect(pdf_body).to have_content('Your minor')
end
scenario 'different release type generates different pdf' do
visit new_project_contract_template_path(project)
select 'Acquired Media Release', from: 'Release type'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Acquired Media Release')
expect(pdf_body).not_to have_content('Guardian')
visit new_project_contract_template_path(project)
select 'Location Release', from: 'Release type'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Location Release')
expect(pdf_body).not_to have_content('Guardian')
visit new_project_contract_template_path(project)
select 'Material Release', from: 'Release type'
click_on 'Preview'
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('PREVIEW ONLY')
expect(pdf_body).to have_content('Material Release')
expect(pdf_body).not_to have_content('Guardian')
end
context 'preventing creation of release template with wrong fee value' do
before do
visit new_project_contract_template_path(project)
fill_in 'Name', with: 'My Release Template'
select 'Appearance Release', from: 'Release type'
fill_in_trix body_field, with: 'You agree to this release.'
fill_hidden guardian_clause_field, with: 'Your minor agrees to this release.'
select 'All', from: 'Applicable Media'
select 'Other', from: 'Territory'
fill_in 'Describe other territory', with: 'North America only'
select 'In perpetuity', from: 'Term'
select 'None', from: 'Restriction'
end
scenario 'Should not allow negative fees' do
fill_in 'Fee', with: '-200'
click_on 'Create Release Template'
expect(page).not_to have_content('The release template has been created')
end
scenario 'Should not allow fees with more than 9 digits' do
fill_in 'Fee', with: '9999999999'
click_on 'Create Release Template'
expect(page).not_to have_content('The release template has been created')
end
end
scenario 'contract template preview is shown before printing' do
create(:appearance_release_contract_template, body: 'Contract legal language', project: project)
visit project_contract_templates_path(project)
click_on 'Manage'
expect(page).to have_content('Print')
click_link 'Print'
expect(page).to have_content preview_heading
expect(page).to have_selector 'embed'
end
scenario 'printing blank release template' do
create(:appearance_release_contract_template, body: 'Contract legal language', project: project)
visit project_contract_templates_path(project)
click_on 'Manage'
expect(page).to have_content('Print')
click_link 'Print'
fill_in 'Number of copies', with: '-1'
click_on t('shared.print')
expect(page).to have_content(t('contract_templates.blank_contracts.create.number_of_copies_invalid_notice'))
fill_in 'Number of copies', with: 2
click_on t('shared.print')
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_body).to have_content('Contract legal language', count: 2)
expect(pdf_body).to have_content('Appearance Release', count: 2)
expect(pdf_body).to have_content('Name: _____', count: 4) #2 times for person name and 2 times for guardian name
expect(pdf_body).to have_content(t 'blank_contracts.pdf.do_not_copy_warning', count: 2)
end
scenario 'archiving an existing release template', js: true do
create(:contract_template, project: project)
visit project_contract_templates_path(project)
expect(page).to have_content('Test template')
click_on 'Manage'
accept_alert do
click_on 'Archive'
end
expect(page).to have_content('The release template has been archived')
expect(page).not_to have_content('Test template')
end
context 'When the user is associate' do
let(:current_user) { create(:user, :associate) }
it 'does not show management buttons for release templates' do
visit project_contract_templates_path(project)
expect(page).not_to have_content('Create New Release Template')
expect(page).not_to have_content('Import Release Template')
expect(page).not_to have_content('Delete')
end
end
context 'When the user is account manager' do
let(:current_user) { create(:user, :account_manager) }
it 'shows archive button for release template' do
create(:contract_template, project: project)
visit project_contract_templates_path(project)
click_on 'Manage'
expect(page).to have_content('Archive')
end
end
private
def preview_heading
t 'blank_contracts.new.preview_heading'
end
def fill_in_trix(id, with:)
find("trix-editor##{id}").click.set(with)
end
def body_field
'contract_template_body'
end
def guardian_clause_field
'contract_template_guardian_clause_trix_input_contract_template'
end
def fill_hidden(id, with:)
find(:xpath, "//input[@id='#{id}']", visible: false).set with
end
end

View File

@@ -0,0 +1,97 @@
require "rails_helper"
RSpec.feature "User can update his profile", type: :feature do
let(:user) { create(:user, :with_name) }
before do
sign_in(user)
end
scenario "user clicks profile dropdown" do
visit signed_in_root_path
click_on "John Doe"
expect(page).to have_link("Profile Settings", href: profile_path)
expect(page).to have_link("Sign Out", href: session_path)
end
scenario "visits profile page" do
visit profile_path
expect(page).to have_content("First name")
expect(page).to have_content("Last name")
end
scenario "updates first and last name" do
visit profile_path
within "form" do
fill_in "First name", with: "John"
fill_in "Last name", with: "Doe"
click_on "Update Profile"
end
expect(page).to have_content("John Doe")
expect(page).to have_content("JD")
end
scenario "updates avatar" do
visit profile_path
within "form" do
attach_file "user[avatar]", Rails.root.join(file_fixture("person_photo.png")), visible: false
fill_in "First name", with: "John"
fill_in "Last name", with: "Doe"
click_on "Update Profile"
end
expect(page).to have_content("Profile has been updated successfully")
expect(page).to have_content("John Doe")
expect(page).to have_photo("person_photo.png")
end
context "user is admin" do
let(:user) { create(:user, :with_name, :admin) }
scenario "admin visits user listing" do
visit admin_users_path
expect(page).to have_content("First Name")
expect(page).to have_content("Last Name")
expect(page).to have_content("John")
expect(page).to have_content("Doe")
end
scenario "admin clicks profile dropdown" do
visit admin_users_path
click_on "John Doe"
expect(page).to have_link("BIG Admin", href: admin_signed_in_root_path)
expect(page).to have_link("Profile Settings", href: profile_path)
expect(page).to have_link("Account Settings", href: account_auths_path)
expect(page).to have_link("Sign Out", href: session_path)
end
end
context "user is account manager" do
let(:user) { create(:user, :with_name, :account_manager) }
scenario "account manager clicks profile dropdown" do
visit signed_in_root_path
click_on "John Doe"
expect(page).to have_link("Profile Settings", href: profile_path)
expect(page).to have_link("Account Settings", href: account_auths_path)
expect(page).to have_link("Sign Out", href: session_path)
end
end
private
def have_photo(filename)
have_selector("img[src*='#{filename}']")
end
end

View File

@@ -0,0 +1,107 @@
require "rails_helper"
RSpec.feature "User manages project custom folders", type: :feature do
let(:user) { create(:user, :manager) }
let(:project) { create(:project, members: user, account: user.primary_account) }
before do
sign_in(user)
end
scenario "creating a new folder" do
visit new_project_directory_path(project)
fill_in "Name", with: "Actors"
select "Videos", from: "Category"
click_on "Create Folder"
expect(page).to have_content("The folder has been created")
end
scenario "updating a folder" do
dir = create(:directory)
visit edit_project_directory_path(project, dir)
fill_in "Name", with: "New Actors"
select "Videos", from: "Category"
click_on "Update Folder"
expect(page).to have_content("The folder has been updated")
end
scenario "deleting an existing folder", js: true do
create(:directory, project: project)
visit project_path(project)
expect(page).to have_content("Payrolls")
click_on "button"
accept_alert do
click_on "Delete Folder"
end
expect(page).to have_content("The folder has been deleted")
end
scenario "adding files to a folder", js: true do
dir = create(:directory)
visit new_file_project_directory_path(project, dir)
expect(page).to have_content("UPLOAD NEW FILES")
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
click_button "Upload Files"
expect(page).to have_content("The folder has been updated")
expect(page).to have_content("person_photo.png")
end
scenario "folder's show page should show uploaded files", js: true do
dir_with_files = create(:directory, :with_files)
visit project_directory_path(project, dir_with_files)
expect(page).to have_content("location_photo.png")
end
scenario "Listed file should have a manage button", js: true do
dir_with_files = create(:directory, :with_files)
visit project_directory_path(project, dir_with_files)
expect(page).to have_content("location_photo.png")
click_on "Manage"
expect(page).to have_link("Download File")
expect(page).to have_link("Delete File")
end
scenario "searching for a file", js: true do
dir_with_many_files = create(:directory, :many_files, project: project)
visit project_directory_path(project, dir_with_many_files)
within "form" do
fill_in "Search Files", with: "location"
click_on "button"
end
expect(page).to have_content("location_photo.png")
expect(page).not_to have_content("material_photo.png")
expect(page).not_to have_content("person_photo.png")
expect(page).to have_field("Search Files", with: "location")
end
scenario "User can delete a file", js: true do
dir_with_files = create(:directory, :with_files)
visit project_directory_path(project, dir_with_files)
click_on "Manage"
accept_alert do
click_on "Delete File"
end
expect(page).to have_content("File deleted successfully")
end
end

View File

@@ -0,0 +1,294 @@
require "rails_helper"
feature "User managing acquired_media releases" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_acquired_media_release_path(project.account, project, contract_template)
by "filling out the form" do
fill_in acquired_media_name_field, with: "Jane Doe"
acquired_media_category_fields
draw_signature file_fixture("signature.png"), "acquired_media_release_signature_base64"
end
click_button "I have read and agree to the above"
expect(AcquiredMediaRelease.last.categories).to include("Artwork")
expect(AcquiredMediaRelease.last.categories).to include("Still Photograph")
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
end
context "when signed in" do
scenario "creating, updating, destroying a release", js: true do
release_data = {
name: "Test Acquired Media Release",
applicable_media: ApplicableMedium.last.label,
territory: Territory.last.label,
term: Term.last.label,
restriction: Restriction.first.label,
restriction_text: "Not available in China",
}
sign_in current_user
visit new_project_acquired_media_release_path(project)
by "attaching only a contract" do
attach_file "acquired_media_release[contract]", Rails.root.join(file_fixture("contract.pdf")), visible: false
click_button create_release_button
expect(page).to have_invalid_field(acquired_media_name_field)
end
by "attaching files" do
drop_file Rails.root.join(file_fixture("video_file.mp4")), type: "file-info-dropzone"
click_button create_release_button
expect(page).to have_invalid_field(acquired_media_name_field)
end
by "filling out the remaining information" do
fill_in_release_fields release_data
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_content("1")
click_on "Manage"
expect(page).to have_link("Download")
end
it_also "updates an existing release" do
click_link "Edit"
within ".dropzone" do
expect(page).to have_filename("video_file.mp4")
end
expect(page).to have_filled_in_data(release_data)
fill_in_release_fields name: "New name"
drop_file Rails.root.join(file_fixture("person_photo.png")), type: "file-info-dropzone"
click_button update_release_button
expect(page).to have_content(update_release_notice)
expect(page).to have_content("New name")
expect(page).to have_content("2")
end
it_also "deletes an existing release" do
click_button "Manage"
accept_alert do
click_link "Delete"
end
expect(page).not_to have_content("New name")
end
end
scenario "viewing the contract PDF" do
acquired_media_release = create(:acquired_media_release_with_contract_template,
:native,
project: project,
person_name: "Jane Doe",
tag_list: "Woman, Brunette",
notes: [
build(:note,
content: "Note 1",
user: build(:user, email: "jane.doe@test.com"),
email: "jane.doe@test.com",
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),
),
build(:note,
content: "Note 2",
user: build(:user, email: "john.doe@test.com"),
email: "john.doe@test.com",
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),
),
],
file_infos:
[
build(:file_info,
filename: "aaa.jpg",
content_type: "image/jpeg"),
build(:file_info,
filename: "bbb.mp4",
content_type: "video/mp4"),
build(:file_info,
filename: "unknown.doc",
content_type: "unknown/file")
]
)
sign_in(current_user)
visit project_acquired_media_releases_path(project)
click_link *view_release_pdf_link_for(acquired_media_release)
expect(content_type).to eq("application/pdf")
expect(pdf_body).to have_content("NOTES")
expect(pdf_body).to have_content("Note 1")
expect(pdf_body).to have_content("jane.doe@test.com")
expect(pdf_body).to have_content("2/21/20 12:00 PM")
expect(pdf_body).to have_content("Note 2")
expect(pdf_body).to have_content("john.doe@test.com")
expect(pdf_body).to have_content("2/20/20 11:00 AM")
expect(pdf_body).to have_content("TAGS")
expect(pdf_body).to have_content("Woman")
expect(pdf_body).to have_content("Brunette")
expect(pdf_body).to have_content("FILES")
expect(pdf_body).to have_content("Photos")
expect(pdf_body).to have_content("Videos")
expect(pdf_body).to have_content("aaa.jpg")
expect(pdf_body).to have_content("bbb.mp4")
expect(pdf_body).to have_content("unknown.doc")
expect(pdf_body).to have_content("Other files")
end
scenario "searching for a release", js: true do
collection1 = create(:acquired_media_release, name: "EDM Music", project: project)
collection2 = create(:acquired_media_release, name: "Classical Music", project: project)
sign_in current_user
visit project_acquired_media_releases_path(project)
within "form#search" do
fill_in "Search", with: "EDM"
click_on "button"
end
expect(page).to have_content("EDM Music")
expect(page).not_to have_content("Classical Music")
expect(page).to have_field("Search", with: "EDM")
end
scenario "edit is visible for non-native release" do
create(:acquired_media_release_with_contract_template, name: "EDM Music", project: project)
sign_in current_user
visit project_acquired_media_releases_path(project)
click_on "Manage"
expect(page).to have_link("Edit", exact: true)
end
scenario "edit is not visible for native release" do
create(:acquired_media_release_with_contract_template, :native, name: "EDM Music", project: project)
sign_in current_user
visit project_acquired_media_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Edit", exact: true)
end
context "when the user is associate" do
let(:current_user) { create(:user, :associate) }
scenario "should not show download" do
collection1 = create(:acquired_media_release_with_contract_template, name: "EDM Music", project: project)
sign_in current_user
visit project_acquired_media_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Download", exact: true)
end
end
end
private
def acquired_media_name_field
"acquired_media_release[name]"
end
def acquired_media_category_fields
find(:css, "#acquired_media_release_categories_artwork").set(true)
find(:css, "#acquired_media_release_categories_still_photograph").set(true)
end
def have_filename(filename)
have_selector("span[data-dz-name]", text: filename)
end
def import_acquired_media_release_link(project)
["Import Release", href: new_project_acquired_media_release_path(project)]
end
def update_acquired_media_release_link(acquired_media_release)
["Edit", href: edit_acquired_media_release_path(acquired_media_release)]
end
def destroy_acquired_media_release_link(acquired_media_release)
["Delete", href: acquired_media_release_path(acquired_media_release)]
end
def fill_in_release_fields(data)
fill_in "acquired_media_release[name]", with: data[:name]
select_exploitable_right "applicable_medium", data[:applicable_medium]
select_exploitable_right "territory", data[:territory]
select_exploitable_right "term", data[:term]
select_exploitable_right "restriction", data[:restriction]
fill_in_exploitable_right_field("applicable_medium", data[:applicable_medium_text])
fill_in_exploitable_right_field("territory", data[:territory_text])
fill_in_exploitable_right_field("term", data[:term_text])
fill_in_exploitable_right_field("restriction", data[:restriction_text])
end
def select_exploitable_right(name, value)
if value.present?
select value, from: "acquired_media_release[#{name}_id]"
end
end
def fill_in_exploitable_right_field(name, text)
if text.present?
fill_in "acquired_media_release[#{name}_text]", with: text
end
end
def view_release_pdf_link_for(acquired_media_release)
["Download", href: acquired_media_release_contracts_path(acquired_media_release, format: "pdf")]
end
def have_filled_in_data(data)
have_field "acquired_media_release[name]", with: data[:name]
have_field "acquired_media_release[acquired_medium_id]", with: data[:acquired_medium]
have_field "acquired_media_release[acquired_medium_text]", with: data[:acquired_medium_text]
have_field "acquired_media_release[territory_id]", with: data[:territory]
have_field "acquired_media_release[territory_text]", with: data[:territory_text]
have_field "acquired_media_release[term_id]", with: data[:term]
have_field "acquired_media_release[term_text]", with: data[:term_text]
have_field "acquired_media_release[restriction_id]", with: data[:restriction]
have_field "acquired_media_release[restriction_text]", with: data[:restriction_text]
end
def create_release_button
t "helpers.submit.acquired_media_release.create"
end
def create_release_notice
t "acquired_media_releases.create.notice"
end
def update_release_button
t "helpers.submit.acquired_media_release.update"
end
def update_release_notice
t "acquired_media_releases.update.notice"
end
def destroy_release_alert
t "acquired_media_releases.destroy.alert"
end
end

View File

@@ -0,0 +1,552 @@
# frozen_string_literal: true
require 'rails_helper'
feature 'User managing appearance releases' do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context 'when signed out' do
scenario 'creating a release for an adult', js: true do
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
project = create(:project, members: current_user, account: current_user.primary_account)
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_appearance_release_path(project.account, project, contract_template)
expect(page).to have_photo_button
fill_in person_first_name_field, with: 'Jane'
fill_in person_last_name_field, with: 'Doe'
fill_in person_address_field, with: '123 Test Lane, New York, NY 10000'
fill_in person_phone_field, with: '555-555-5555'
fill_in person_email_field, with: 'jane.doe@test.com'
fill_in person_date_of_birth, with: '01/01/1999'
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
click_button 'I have read and agree to the above'
expect(page).to have_content(successful_submission_message)
end
scenario 'creating a release for a minor', js: true do
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
project = create(:project, members: current_user, account: current_user.primary_account)
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_appearance_release_path(project.account, project, contract_template)
expect(page).to have_photo_button
expect(page).not_to have_content('GUARDIAN INFORMATION')
expect(page).not_to have_content('GUARDIAN PHOTO')
page.check person_is_minor_checkbox
expect(page).to have_content('GUARDIAN INFORMATION')
expect(page).to have_content('GUARDIAN PHOTO')
fill_in guardian_first_name_field, with: 'Guardian'
fill_in guardian_last_name_field, with: 'Name'
fill_in guardian_phone_field, with: '001101'
fill_in person_first_name_field, with: 'Jane'
fill_in person_last_name_field, with: 'Doe'
fill_in person_address_field, with: '123 Test Lane, New York, NY 10000'
fill_in person_phone_field, with: '555-555-5555'
fill_in person_email_field, with: 'jane.doe@test.com'
fill_in person_date_of_birth, with: '01/01/1999'
attach_file person_photo_field, file_fixture('person_photo.png'), visible: :all
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
click_button 'I have read and agree to the above'
expect(page).to have_content(successful_submission_message)
end
end
context 'when signed in' do
before :each do
sign_in current_user
end
scenario 'editing non native release for adult', js: true do
appearance_release = create(:appearance_release, :non_native, project: project)
visit edit_appearance_release_path(appearance_release)
expect(page).not_to have_content('Guardian Photo')
by 'filling out the form' do
fill_in person_first_name_field, with: 'New John'
fill_in person_last_name_field, with: 'Doe'
fill_in person_email_field, with: 'john.doe@test.com'
select 'Other', from: 'Applicable Media'
fill_in 'Describe other applicable media', with: 'Test'
select 'Other', from: 'Territory'
fill_in 'Describe other territory', with: 'Test'
select 'Other', from: 'Term'
fill_in 'Describe other term', with: 'Test'
select 'Other', from: 'Restriction'
fill_in 'Describe other restrictions', with: 'Test'
end
click_button submit_update_button
expect(page).to have_content successful_update_message
expect(page).to have_content 'New John'
end
scenario 'editing non native release for minor', js: true do
appearance_release = create(:appearance_release, :non_native, :minor, project: project)
visit edit_appearance_release_path(appearance_release)
expect(page).to have_content('Guardian Photo')
by 'filling out the form' do
page.check person_is_minor_checkbox
fill_in guardian_first_name_field, with: 'Guardian'
fill_in guardian_last_name_field, with: 'Name'
fill_in guardian_phone_field, with: '00101'
fill_in person_first_name_field, with: 'New Jane'
fill_in person_last_name_field, with: 'Doe'
fill_in person_email_field, with: 'jane.doe@test.com'
select 'Other', from: 'Applicable Media'
fill_in 'Describe other applicable media', with: 'Test'
select 'Other', from: 'Territory'
fill_in 'Describe other territory', with: 'Test'
select 'Other', from: 'Term'
fill_in 'Describe other term', with: 'Test'
select 'Other', from: 'Restriction'
fill_in 'Describe other restrictions', with: 'Test'
end
expect(page).to have_content 'Guardian Photo'
click_button submit_update_button
expect(page).to have_content successful_update_message
expect(page).to have_content 'New Jane'
end
scenario 'progress bar shows when user imports a release', js: true do
skip "TODO"
visit project_appearance_releases_path(project)
attach_file import_appearance_release_field, Rails.root.join(file_fixture('person_photo.png')), visible: false
expect(page).to have_content importing_label
click_button submit_create_button
expect(page).to have_css('.progress')
end
scenario 'importing a releases works when image is selected', js: true do
visit project_appearance_releases_path(project)
expect(page).to have_content submit_create_button
expect(page).to have_content no_appearance_releases
attach_file import_appearance_release_field, Rails.root.join(file_fixture('person_photo.png')), visible: false
expect(page).to have_content importing_label
click_button submit_create_button
expect(page).not_to have_content no_appearance_releases
expect(page).to have_content /Imported Headshot\s+\d{7}/
end
scenario 'importing a releases works when pdf is selected', js: true do
visit project_appearance_releases_path(project)
expect(page).to have_content submit_create_button
expect(page).to have_content no_appearance_releases
attach_file import_appearance_release_field, Rails.root.join(file_fixture('contract.pdf')), visible: false
expect(page).to have_content importing_label
click_button submit_create_button
expect(page).not_to have_content no_appearance_releases
expect(page).to have_content /Imported Contract\s+\d{7}/
end
scenario 'importing a releases fails when file other than image or pdf is selected', js: true do
visit project_appearance_releases_path(project)
expect(page).to have_content submit_create_button
expect(page).to have_content no_appearance_releases
attach_file import_appearance_release_field, Rails.root.join(file_fixture('audio.mp3')), visible: false
expect(page).to have_content importing_label
click_button submit_create_button
expect(page).to have_content failed_to_import_notice
expect(page).to have_content no_appearance_releases
end
scenario 'user leaving the page is presented with the warning if file upload is in progress', js: true do
skip "Test is inconsistently failing in CI"
visit project_appearance_releases_path(project)
expect(page).to have_content submit_create_button
expect(page).to have_content no_appearance_releases
large_pdf_file = build_large_pdf_file
attach_file import_appearance_release_field, Rails.root.join(large_pdf_file.path), visible: false
page.dismiss_confirm do
first('a', text: 'Files').click
end
expect(page).to have_content importing_label
# Here capybara automatically waits and submit button changes label from Importing... to Import Release again
expect(page).to have_content submit_create_button
first('a', text: 'Files').click
expect(page).not_to have_content no_appearance_releases
end
scenario 'updating a release' do
appearance_release = create(:appearance_release, :non_native, project: project)
visit edit_appearance_release_path(appearance_release)
fill_in person_first_name_field, with: 'New'
fill_in person_last_name_field, with: 'Name'
click_button submit_update_button
expect(page).to have_content(successful_update_message)
expect(page).to have_content('New Name')
end
scenario 'viewing the contract PDF' do
appearance_release = create(:appearance_release_with_contract_template,
:native,
project: project,
person_first_name: 'Jane',
person_last_name: 'Doe',
tag_list: 'Woman, Brunette',
notes: [
build(:note,
content: 'Note 1',
user: build(:user, email: 'jane.doe@test.com'),
email: 'jane.doe@test.com',
created_at: DateTime.new(2020, 2, 21, 12, 0, 0)),
build(:note,
content: 'Note 2',
user: build(:user, email: 'john.doe@test.com'),
email: 'john.doe@test.com',
created_at: DateTime.new(2020, 2, 20, 11, 0, 0))
])
sign_in(current_user)
visit project_appearance_releases_path(project)
click_link *view_release_pdf_link_for(appearance_release)
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_filename).to include('doe-jane')
expect(pdf_body).to have_content('Jane Doe')
expect(pdf_body).to have_content('NOTES')
expect(pdf_body).to have_content('Note 1')
expect(pdf_body).to have_content('jane.doe@test.com')
expect(pdf_body).to have_content('2/21/20 12:00 PM')
expect(pdf_body).to have_content('Note 2')
expect(pdf_body).to have_content('john.doe@test.com')
expect(pdf_body).to have_content('2/20/20 11:00 AM')
expect(pdf_body).to have_content('TAGS')
expect(pdf_body).to have_content('Woman')
expect(pdf_body).to have_content('Brunette')
end
scenario 'viewing contract PDF for a minor without guardian photo' do
appearance_release = create(:appearance_release_with_contract_template, :native, :minor, project: project)
visit project_appearance_releases_path(project)
click_link *view_release_pdf_link_for(appearance_release)
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(appearance_release.name)
expect(pdf_body).to have_content(appearance_release.guardian_name)
expect(pdf_body).to have_content photos_heading.upcase
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
end
scenario 'viewing contract PDF for a minor with guardian photo' do
appearance_release = create(:appearance_release_with_contract_template, :native, :minor_with_guardian_photo, project: project)
visit project_appearance_releases_path(project)
click_link *view_release_pdf_link_for(appearance_release)
expect(content_type).to eq('application/pdf')
expect(content_disposition).to include('inline')
expect(pdf_filename).to include(appearance_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(appearance_release.name)
expect(pdf_body).to have_content(appearance_release.guardian_name)
expect(pdf_body).to have_content photos_heading(2).upcase
expect(pdf_body).to have_content(appearance_release.photo.filename.to_s)
expect(pdf_body).to have_content(appearance_release.guardian_photo.filename.to_s)
end
scenario 'deleting a release', js: true do
appearance_release = create(:appearance_release, project: project)
visit project_appearance_releases_path(project)
click_on 'Manage'
accept_alert do
click_link *destroy_link_for(appearance_release)
end
expect(page).to have_content(successful_destroy_message)
end
scenario 'searching for a release', js: true do
chris = create(:appearance_release, person_first_name: 'Chris', person_last_name: 'Evans', project: project)
robert = create(:appearance_release, person_first_name: 'Robert', person_last_name: 'Downey Jr.', project: project)
visit project_appearance_releases_path(project)
expect(page).to have_content('Chris Evans')
expect(page).to have_content('Robert Downey Jr.')
within 'form#search' do
fill_in 'Search', with: 'Robert'
click_on 'button'
end
expect(page).to have_content('Robert Downey Jr.')
expect(page).not_to have_content('Chris Evans')
expect(page).to have_field('Search', with: 'Robert')
end
scenario 'filtering for a release by complete/incomplete type', js: true do
create(:appearance_release, :without_person_photo, :non_native, person_first_name: 'Chris', person_last_name: 'Evans Incomplete', project: project)
create(:appearance_release, :non_native, person_first_name: 'Chris', person_last_name: 'Evans Complete', project: project)
create(:appearance_release, :without_person_photo, :non_native, person_first_name: 'Robert', person_last_name: 'Downey Jr. Incomplete', project: project)
create(:appearance_release, :non_native, person_first_name: 'Robert', person_last_name: 'Downey Jr. Complete', project: project)
visit project_appearance_releases_path(project)
expect(page).to have_content('Chris Evans Incomplete')
expect(page).to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
click_link filter_type_complete
expect(page).not_to have_content('Chris Evans Incomplete')
expect(page).to have_content('Chris Evans Complete')
expect(page).not_to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
click_link filter_type_incomplete
expect(page).to have_content('Chris Evans Incomplete')
expect(page).not_to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).not_to have_content('Robert Downey Jr. Complete')
click_link filter_type_all
expect(page).to have_content('Chris Evans Incomplete')
expect(page).to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
end
scenario 'filtering for a release by complete/incomplete type works in parallel with search', js: true do
create(:appearance_release, :without_person_photo, :non_native, person_first_name: 'Chris', person_last_name: 'Evans Incomplete', project: project)
create(:appearance_release, :non_native, person_first_name: 'Chris', person_last_name: 'Evans Complete', project: project)
create(:appearance_release, :without_person_photo, :non_native, person_first_name: 'Robert', person_last_name: 'Downey Jr. Incomplete', project: project)
create(:appearance_release, :non_native, person_first_name: 'Robert', person_last_name: 'Downey Jr. Complete', project: project)
visit project_appearance_releases_path(project)
expect(page).to have_content('Chris Evans Incomplete')
expect(page).to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
click_link filter_type_complete
expect(page).not_to have_content('Chris Evans Incomplete')
expect(page).to have_content('Chris Evans Complete')
expect(page).not_to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
within 'form#search' do
fill_in 'Search', with: 'Robert'
click_on 'button'
end
expect(page).not_to have_content('Chris Evans Incomplete')
expect(page).not_to have_content('Chris Evans Complete')
expect(page).not_to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
click_link filter_type_incomplete
expect(page).not_to have_content('Chris Evans Incomplete')
expect(page).not_to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).not_to have_content('Robert Downey Jr. Complete')
click_link filter_type_all
expect(page).not_to have_content('Chris Evans Incomplete')
expect(page).not_to have_content('Chris Evans Complete')
expect(page).to have_content('Robert Downey Jr. Incomplete')
expect(page).to have_content('Robert Downey Jr. Complete')
end
end
context 'when the user is associate' do
let(:current_user) { create(:user, :associate) }
scenario 'should not show download' do
chris = create(:appearance_release_with_contract_template, person_first_name: 'Chris', person_last_name: 'Evans', project: project)
sign_in current_user
visit project_appearance_releases_path(project)
click_on 'Manage'
expect(page).not_to have_link('Download', exact: true)
end
end
private
def build_large_pdf_file
# Generates dummy temp file with approx 50MB
tempfile = Tempfile.new(['large_file', '.pdf'], Rails.root.join('tmp'))
tempfile << '%PDF-1.2'
1_000_000.times do
tempfile << 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
end
tempfile << '%%EOF'
tempfile
end
def filter_type_all
t 'appearance_releases.type_filter_actions.all_releases'
end
def filter_type_complete
t 'appearance_releases.type_filter_actions.complete_releases'
end
def filter_type_incomplete
t 'appearance_releases.type_filter_actions.incomplete_releases'
end
def failed_to_import_notice
t 'appearance_releases.create.failed_import'
end
def importing_label
'Importing...'
end
def no_appearance_releases
t 'appearance_releases.index.empty'
end
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
def have_photo_button
have_selector('.take-photo-button')
end
def person_is_minor_checkbox
'appearance_release_minor'
end
def guardian_first_name_field
'Guardian first name'
end
def guardian_last_name_field
'Guardian last name'
end
def guardian_phone_field
'Guardian phone'
end
def guardian_photo_field
'appearance_release[guardian_photo]'
end
def person_name_field
t('helpers.label.appearance_release.person_name')
end
def person_first_name_field
'Person first name'
end
def person_last_name_field
'Person last name'
end
def person_address_field
t('helpers.label.appearance_release.person_address')
end
def person_email_field
t('helpers.label.appearance_release.person_email')
end
def person_phone_field
t('helpers.label.appearance_release.person_phone')
end
def import_appearance_release_field
'attachments[]'
end
def person_photo_field
'appearance_release[person_photo]'
end
def contract_field
'appearance_release[contract]'
end
def person_date_of_birth
'appearance_release[person_date_of_birth]'
end
def submit_create_button
'Import Release'
end
def submit_update_button
'Save Changes'
end
def edit_link_for(appearance_release)
['Edit', href: edit_appearance_release_path(appearance_release)]
end
def destroy_link_for(appearance_release)
['Delete', href: appearance_release_path(appearance_release)]
end
def view_release_pdf_link_for(appearance_release)
['Download', href: appearance_release_contracts_path(appearance_release, format: 'pdf')]
end
def successful_submission_message
'Your release was successfully submitted. Thank you.'
end
def succesful_create_message
'The release has been imported.'
end
def successful_update_message
'The release has been updated'
end
def successful_destroy_message
'The release has been deleted'
end
end

View File

@@ -0,0 +1,83 @@
require "rails_helper"
feature "User managing broadcasts" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "managing broadcasts" do
before do
sign_in current_user
allow(MuxLiveStream).to receive(:new).and_return(double(id: "id", key: "key", playback_id: "playback_id"))
end
scenario "creating and deleting a broadcast", js: true do
visit new_project_broadcast_path(project)
by "filling out the form" do
fill_in broadcast_name_field, with: "My Broadcast"
end
click_button "Create Live Stream"
expect(page).to have_content("A live stream has been created")
click_on "Manage"
expect(page).to have_link("Copy Stream URL", exact: true)
expect(page).to have_link("Copy Stream Key", exact: true)
expect(page).to have_link("View", exact: true)
expect(page).to have_link("Delete", exact: true)
it_also "Deletes the broadcast" do
allow_any_instance_of(Broadcast).to receive(:destroy_mux_live_stream).and_return(true)
accept_alert do
click_link "Delete"
end
expect(page).to have_content("A live stream has been deleted")
expect(page).not_to have_content("My Broadcast")
end
end
scenario "visit show page of broadcast", js: true do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
recording = create(:broadcast_recording, broadcast: broadcast)
visit project_broadcast_path(project, broadcast)
expect(page).to have_content("Live stream is waiting to begin.")
expect(page).to have_content("Copy URL")
click_on "Files"
expect(page).to have_content("contract.pdf")
click_on "Previous Sessions"
expect(page).to have_content(recording.download_file_name)
end
scenario "visit multi-view broadcast page", js: true do
broadcasts = create_list(:broadcast, 4, :with_stream, project: project)
visit project_broadcasts_path(project)
click_checkboxes
new_window = window_opened_by { click_link "Multi-View" }
within_window new_window do
expect(page).to have_content("Switch View")
click_on "Switch View"
expect(page).to have_link(broadcasts.first.name)
expect(page).to have_link(broadcasts.second.name)
end
end
end
private
def broadcast_name_field
"broadcast[name]"
end
def click_checkboxes
all('input[type="checkbox"]')[1].click
all('input[type="checkbox"]')[2].click
end
end

View File

@@ -0,0 +1,29 @@
require "rails_helper"
feature "User managing downloads" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
before :each do
sign_in current_user
end
scenario "searching for a downlaod", js: true do
create(:download_release_type_appearance, project: project)
create(:download_release_type_music, project: project)
visit project_downloads_path(project)
fill_in "query", with: "Music"
click_on "search-button"
expect(page).to have_content("Music Release")
expect(page).not_to have_content("Appearance Release")
fill_in "query", with: "Natgeo"
click_on "search-button"
expect(page).not_to have_content("Discovery Contract")
expect(page).to have_content("Natgeo Contract")
end
end

View File

@@ -0,0 +1,279 @@
require "rails_helper"
feature "User managing location releases" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
by "filling out the form" do
fill_in location_name_field, with: "Benny's Burritos"
fill_in person_first_name_field, with: "Jane"
fill_in person_last_name_field, with: "Doe"
fill_in person_phone_field, with: "555-555-5555"
fill_in person_email_field, with: "jane.doe@test.com"
fill_in person_address_street1_field, with: "100 Broadway"
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
end
click_button "I have read and agree to the above"
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
end
context "when signed in" do
before do
set_window_size_permanently_to(1000, 1000)
sign_in current_user
end
scenario "creating a release", js: true do
visit new_project_location_release_path(project)
by "attaching only a contract" do
attach_file contract_field, Rails.root.join(file_fixture("contract.pdf")), visible: false
click_button create_release_button
expect(page).to have_invalid_field(location_name_field)
end
by "attaching photos" do
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
click_button create_release_button
expect(page).to have_invalid_field(location_name_field)
end
by "filling out the remaining information" do
fill_in_release_fields name: "Test Location Release"
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_photo("location_photo.png")
click_on "Manage"
expect(page).to have_link("Download")
end
end
scenario "updating an existing release", js: true do
location_release = create(:location_release_with_photo, :non_native, project: project)
visit project_location_releases_path(project)
click_on "Manage"
click_link *update_location_release_link(location_release)
within ".dropzone" do
expect(page).to have_photo("location_photo.png", attr: "alt")
end
fill_in_release_fields name: "New release name"
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "New Test"
click_on update_release_button
expect(page).to have_content(update_release_notice)
expect(page).to have_content("New release name")
end
scenario "deleting an existing release", js: true do
location_release = create(:location_release, project: project)
visit project_location_releases_path(project)
click_on "Manage"
accept_alert do
click_link *destroy_location_release_link(location_release)
end
expect(page).to have_content(destroy_release_alert)
expect(page).not_to have_content(location_release.name)
end
scenario "searching for a release", js: true do
create(:location_release, name: "Cheers", project: project)
create(:location_release, name: "Cipriani", project: project)
visit project_location_releases_path(project)
within "form#search" do
fill_in "Search", with: "Cheers"
click_on "button"
end
expect(page).to have_content("Cheers")
expect(page).not_to have_content("Cipriani")
expect(page).to have_field("Search", with: "Cheers")
end
scenario "adding photos to an existing release", js: true do
create(:location_release, name: "Apple MacBook Air", project: project)
visit project_location_releases_path(project)
expect(page).to have_content("Needs Photo")
click_on "Manage"
click_on "Photos"
expect(page).to have_content("Add Photos")
expect(page).to have_content("Apple MacBook Air")
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
click_on "Save Changes"
expect(page).to have_content("The release has been updated")
expect(page).to have_photo("location_photo.png")
end
end
scenario "viewing the contract PDF" do
location_release = create(:location_release_with_contract_template_and_photo,
:native,
project: project,
name: "Benny's Burritos",
tag_list: "Restaurant",
notes: [
build(:note,
content: "Note 1",
user: build(:user, email: "jane.doe@test.com"),
email: "jane.doe@test.com",
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),
),
build(:note,
content: "Note 2",
user: build(:user, email: "john.doe@test.com"),
email: "john.doe@test.com",
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),
),
]
)
sign_in(current_user)
visit project_location_releases_path(project)
click_link *view_release_pdf_link_for(location_release)
expect(content_type).to eq("application/pdf")
expect(content_disposition).to include("inline")
expect(pdf_filename).to include("benny-s-burritos")
expect(pdf_body).to have_content("Benny's Burritos")
expect(pdf_body).to have_content("NOTES")
expect(pdf_body).to have_content("Note 1")
expect(pdf_body).to have_content("jane.doe@test.com")
expect(pdf_body).to have_content("2/21/20 12:00 PM")
expect(pdf_body).to have_content("Note 2")
expect(pdf_body).to have_content("john.doe@test.com")
expect(pdf_body).to have_content("2/20/20 11:00 AM")
expect(pdf_body).to have_content("TAGS")
expect(pdf_body).to have_content("Restaurant")
expect(pdf_body).to have_content photos_heading.upcase
expect(pdf_body).to have_content("location_photo.png")
end
context "when the user is associate" do
let(:current_user) { create(:user, :associate) }
scenario "should not show download" do
create(:location_release_with_contract_template, name: "Cheers", project: project)
sign_in current_user
visit project_location_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Download", exact: true)
end
end
private
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
def location_name_field
"location_release[name]"
end
def contract_field
"location_release[contract]"
end
def person_first_name_field
"location_release[person_first_name]"
end
def person_last_name_field
"location_release[person_last_name]"
end
def person_email_field
"location_release[person_email]"
end
def person_address_street1_field
"location_release[person_address_street1]"
end
def person_phone_field
"location_release[person_phone]"
end
def have_photo(filename, attr: "src")
have_selector("img[#{attr}*='#{filename}']")
end
def import_location_release_link(project)
["Import Release", href: new_project_location_release_path(project)]
end
def update_location_release_link(location_release)
["Edit", href: edit_location_release_path(location_release)]
end
def destroy_location_release_link(location_release)
["Delete", href: location_release_path(location_release)]
end
def fill_in_release_fields(data)
fill_in "location_release[name]", with: data[:name]
end
def create_release_button
t "helpers.submit.location_release.create"
end
def create_release_notice
t "location_releases.create.notice"
end
def update_release_button
t "helpers.submit.location_release.update"
end
def update_release_notice
t "location_releases.update.notice"
end
def destroy_release_alert
t "location_releases.destroy.alert"
end
def view_release_pdf_link_for(location_release)
["Download", href: location_release_contracts_path(location_release, format: "pdf")]
end
def fill_in_exploitable_rights
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "Test"
select "Other", from: "Territory"
fill_in "Describe other territory", with: "Test"
select "Other", from: "Term"
fill_in "Describe other term", with: "Test"
select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test"
end
end

View File

@@ -0,0 +1,253 @@
require "rails_helper"
feature "User managing material releases" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
by "filling out the form" do
fill_in material_name_field, with: "Pepsi Logo"
fill_in person_first_name_field, with: "Jane"
fill_in person_last_name_field, with: "Doe"
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
end
click_button "I have read and agree to the above"
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
end
context "when signed in" do
before do
sign_in current_user
end
scenario "creating a release", js: true do
visit new_project_material_release_path(project)
by "attaching only a contract" do
attach_file "material_release[contract]", Rails.root.join(file_fixture("contract.pdf")), visible: false
click_button create_release_button
expect(page).to have_invalid_field(material_name_field)
end
by "attaching photos" do
drop_file Rails.root.join(file_fixture("material_photo.png")), type: :dropzone
click_button create_release_button
expect(page).to have_invalid_field(material_name_field)
end
by "filling out the remaining information" do
fill_in_release_fields name: "Apple Laptop"
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_photo("material_photo.png")
click_on "Manage"
expect(page).to have_link("Download")
end
end
scenario "updating an existing release", js: true do
material_release = create(:material_release, :non_native, project: project)
visit project_material_releases_path(project)
click_on "Manage"
click_link *update_material_release_link(material_release)
fill_in_release_fields name: "New release name"
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "New Test"
click_button update_release_button
expect(page).to have_content(update_release_notice)
expect(page).to have_content("New release name")
end
scenario "deleting an existing release", js: true do
material_release = create(:material_release, project: project)
visit project_material_releases_path(project)
click_on "Manage"
accept_alert do
click_link *destroy_material_release_link(material_release)
end
expect(page).to have_content(destroy_release_alert)
expect(page).not_to have_content(material_release.name)
end
scenario "searching for a release", js: true do
create(:material_release, name: "Apple MacBook Air", project: project)
create(:material_release, name: "Microsoft Surface Pro", project: project)
visit project_material_releases_path(project)
within "form#search" do
fill_in "Search", with: "Apple"
click_on "button"
end
expect(page).to have_content("Apple MacBook Air")
expect(page).not_to have_content("Microsoft Surface Pro")
expect(page).to have_field("Search", with: "Apple")
end
scenario "adding photos to an existing release", js: true do
create(:material_release, name: "Apple MacBook Air", project: project)
visit project_material_releases_path(project)
expect(page).to have_content("Needs Photo")
click_on "Manage"
click_on "Photos"
expect(page).to have_content("Add Photos")
expect(page).to have_content("Apple MacBook Air")
drop_file Rails.root.join(file_fixture("material_photo.png")), type: :dropzone
click_on "Save Changes"
expect(page).to have_content("The release has been updated")
expect(page).to have_photo("material_photo.png")
end
scenario "viewing the contract PDF" do
material_release = create(:material_release_with_contract_template_and_photo,
:native,
project: project,
name: "Test Materials",
tag_list: "Soda Can",
notes: [
build(:note,
content: "Note 1",
user: build(:user, email: "jane.doe@test.com"),
email: "jane.doe@test.com",
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),),
build(:note,
content: "Note 2",
user: build(:user, email: "john.doe@test.com"),
email: "john.doe@test.com",
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),),
])
sign_in(current_user)
visit project_material_releases_path(project)
click_link *view_release_pdf_link_for(material_release)
expect(content_type).to eq("application/pdf")
expect(content_disposition).to include("inline")
expect(pdf_filename).to include("test-materials")
expect(pdf_body).to have_content("Test Materials")
expect(pdf_body).to have_content("NOTES")
expect(pdf_body).to have_content("Note 1")
expect(pdf_body).to have_content("jane.doe@test.com")
expect(pdf_body).to have_content("2/21/20 12:00 PM")
expect(pdf_body).to have_content("Note 2")
expect(pdf_body).to have_content("john.doe@test.com")
expect(pdf_body).to have_content("2/20/20 11:00 AM")
expect(pdf_body).to have_content("TAGS")
expect(pdf_body).to have_content("Soda Can")
expect(pdf_body).to have_content photos_heading.upcase
expect(pdf_body).to have_content("material_photo.png")
end
end
context "when the user is associate" do
let(:current_user) { create(:user, :associate) }
scenario "should not show download" do
create(:material_release_with_contract_template, name: "Apple MacBook Air", project: project)
sign_in current_user
visit project_material_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Download", exact: true)
end
end
private
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
def material_name_field
"material_release[name]"
end
def person_first_name_field
"material_release[person_first_name]"
end
def person_last_name_field
"material_release[person_last_name]"
end
def have_photo(filename)
have_selector("img[src*='#{filename}']")
end
def import_material_release_link(project)
["Import Release", href: new_project_material_release_path(project)]
end
def update_material_release_link(material_release)
["Edit", href: edit_material_release_path(material_release)]
end
def destroy_material_release_link(material_release)
["Delete", href: material_release_path(material_release)]
end
def view_release_pdf_link_for(material_release)
["Download", href: material_release_contracts_path(material_release, format: "pdf")]
end
def fill_in_release_fields(data)
fill_in "material_release[name]", with: data[:name]
end
def create_release_button
t "helpers.submit.material_release.create"
end
def create_release_notice
t "material_releases.create.notice"
end
def update_release_button
t "helpers.submit.material_release.update"
end
def update_release_notice
t "material_releases.update.notice"
end
def destroy_release_alert
t "material_releases.destroy.alert"
end
def fill_in_exploitable_rights
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "Test"
select "Other", from: "Territory"
fill_in "Describe other territory", with: "Test"
select "Other", from: "Term"
fill_in "Describe other term", with: "Test"
select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test"
end
end

View File

@@ -0,0 +1,166 @@
require "rails_helper"
feature "User managing music releases" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
scenario "can perform crud actions" do
release_data = attributes_for(:music_release)
sign_in current_user
visit project_music_releases_path(project)
by "creating a release" do
click_link *import_music_release_link(project)
expect(page).to have_content "For optimal accuracy, please ensure music file names match the source file name in the editing sequence."
fill_in_release_fields release_data
fill_in_exploitable_rights
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_content(release_data[:name])
end
and_by "updating an existing release" do
click_link *update_music_release_link(MusicRelease.last)
fill_in_release_fields name: "New release name"
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "New Test"
click_button update_release_button
expect(page).to have_content(update_release_notice)
expect(page).to have_content("New release name")
end
and_by "deleting an existing release" do
click_link *destroy_music_release_link(MusicRelease.last)
expect(page).to have_content(destroy_release_alert)
expect(page).not_to have_content("New release name")
end
end
scenario "creating a music release with validation errors", js: true do
sign_in current_user
visit new_project_music_release_path(project)
by "attaching only a contract" do
attach_file "music_release[contract]", Rails.root.join(file_fixture("contract.pdf")), visible: false
click_button create_release_button
expect(page).to have_invalid_field(music_release_name_field)
end
and_by "attaching files" do
drop_file Rails.root.join(file_fixture("audio.mp3")), type: "file-info-dropzone"
click_button create_release_button
expect(page).to have_invalid_field(music_release_name_field)
end
and_by "filling out the remaining information" do
fill_in_release_fields name: "Big Media OST"
click_button create_release_button
expect(page).to have_content(create_release_notice)
click_on "Manage"
expect(page).to have_link("Download")
end
end
scenario "searching for a release", js: true do
collection1 = create(:music_release, name: "EDM Music", project: project)
collection2 = create(:music_release, name: "Classical Music", project: project)
sign_in current_user
visit project_music_releases_path(project)
within "form#search" do
fill_in "Search", with: "EDM"
click_on "button"
end
expect(page).to have_content("EDM Music")
expect(page).not_to have_content("Classical Music")
expect(page).to have_field("Search", with: "EDM")
end
context "when the user is associate" do
let(:current_user) { create(:user, :associate) }
scenario "should not show download" do
collection1 = create(:music_release, name: "EDM Music", project: project)
sign_in current_user
visit project_music_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Download", exact: true)
end
end
private
def music_release_name_field
"music_release[name]"
end
def import_music_release_link(project)
["Import Release", href: new_project_music_release_path(project)]
end
def update_music_release_link(music_release)
["Edit", href: edit_music_release_path(music_release)]
end
def destroy_music_release_link(music_release)
["Delete", href: music_release_path(music_release)]
end
def fill_in_release_fields(data)
fill_in "music_release[name]", with: data[:name]
fill_in "music_release[person_first_name]", with: data[:person_first_name]
fill_in "music_release[person_last_name]", with: data[:person_last_name]
fill_in "music_release_composers_attributes_0_name", with: "composer name"
fill_in "music_release_composers_attributes_0_affiliation", with: "composer affiliation"
fill_in "music_release_composers_attributes_0_percentage", with: 100
fill_in "music_release_composers_attributes_0_cae_number", with: "CAE123456789"
fill_in "music_release_publishers_attributes_0_name", with: "publisher name"
fill_in "music_release_publishers_attributes_0_affiliation", with: "publisher affiliation"
fill_in "music_release_publishers_attributes_0_percentage", with: 100
end
def create_release_button
t "helpers.submit.music_release.create"
end
def create_release_notice
t "music_releases.create.notice"
end
def update_release_button
t "helpers.submit.music_release.update"
end
def update_release_notice
t "music_releases.update.notice"
end
def destroy_release_alert
t "music_releases.destroy.alert"
end
def fill_in_exploitable_rights
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "Test"
select "Other", from: "Territory"
fill_in "Describe other territory", with: "Test"
select "Other", from: "Term"
fill_in "Describe other term", with: "Test"
select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test"
end
end

View File

@@ -0,0 +1,48 @@
require "rails_helper"
feature "User managing project memberships" do
let(:account) { create(:account) }
scenario "manager invites an existing team member to another project" do
manager = create(:user, :manager, accounts: [account], email: "manager@test.com")
project = create(:project, members: manager, account: account, name: "Project")
another_user = create(:user, accounts: [account], email: "another.user@test.com")
another_project = create(:project, members: [manager, another_user], account: account, name: "Another Project")
sign_in manager
visit project_project_memberships_path(project)
expect(page).to have_content "manager@test.com"
expect(page).not_to have_content "another.user@test.com"
fill_in invite_email_field, with: "another.user@test.com"
click_on "Send Invite"
expect(page).to have_content "User has been invited to the project."
expect(page).to have_content "another.user@test.com"
end
scenario "manager removes an existing team member from a project" do
manager = create(:user, :manager, accounts: [account], email: "manager@test.com")
another_user = create(:user, accounts: [account], email: "another.user@test.com")
project = create(:project, members: [manager, another_user], account: account, name: "Project")
sign_in manager
visit project_project_memberships_path(project)
expect(page).to have_content "manager@test.com"
expect(page).to have_content "another.user@test.com"
expect(page).to have_link("Remove", href: project_membership_path(another_user.project_memberships.first))
click_on "Remove"
expect(page).to have_content "User has been removed from the project."
expect(page).not_to have_content "another.user@test.com"
end
private
def invite_email_field
"project_membership[user_email]"
end
end

View File

@@ -0,0 +1,155 @@
require "rails_helper"
feature "User managing projects" do
let(:user) { create(:user, :account_manager) }
before do
sign_in(user)
end
scenario "creating a new project", js: true do
visit new_project_path
it_also "requires a project name" do
click_on "Create Project"
expect(page).to have_content "can't be blank"
end
fill_in "Name", with: "Avengers"
select "Other", from: "Client"
fill_in "Client name", with: "My Client"
uncheck "Appearance Release"
check "Location Release"
click_on "Create Project"
expect(page).to have_content "The project has been created"
expect(page).to have_content "Avengers"
expect(page).to have_content /My Client/i
expect(page).not_to have_content "Appearance Releases"
expect(page).to have_content "Location Releases"
end
scenario "editing a project", js: true do
project = create(:project, members: user, account: user.primary_account, name: "Avengers", client_name: "Marvel")
visit projects_path
click_on "button"
click_on "Edit"
it_also "requires a project name" do
fill_in "Name", with: ""
click_on "Update Project"
expect(page).to have_content "can't be blank"
end
fill_in "Name", with: "Justice League"
select "Other", from: "Client"
fill_in "Client name", with: "DC"
uncheck "Appearance Release"
check "Location Release"
click_on "Update Project"
expect(page).to have_content "The project has been updated"
expect(page).to have_content "Justice League"
expect(page).to have_content /DC/i
expect(page).not_to have_content "Appearance Releases"
expect(page).to have_content "Location Releases"
end
scenario "deleting a project", js: true do
skip "This functionality is no longer available"
project = create(:project, members: user, name: "Avengers", account: user.primary_account)
create(:appearance_release, project: project)
visit projects_path
expect(page).to have_content("Avengers")
click_on "button"
accept_alert do
click_on "Delete"
end
expect(page).to have_content "The project has been deleted"
expect(page).not_to have_content "Avengers"
end
scenario "all features are enabled" do
project = create(:project, members: user, account: user.primary_account)
enable_all_project_features(project)
visit project_path(project)
expect(page).to have_content("Talent Releases")
expect(page).to have_content("Appearance Releases")
expect(page).to have_content("Acquired Media Releases")
expect(page).to have_content("Material Releases")
expect(page).to have_content("Music Releases")
end
scenario "some features are disabled" do
project = create(:project, members: user, account: user.primary_account)
disable_project_features(project, :material_release, :music_release)
visit project_path(project)
expect(page).to have_content("Talent Releases")
expect(page).to have_content("Appearance Releases")
expect(page).to have_content("Acquired Media Releases")
expect(page).not_to have_content("Material Releases")
expect(page).not_to have_content("Music Releases")
end
# TODO: What about the welcome page when there are no existing projects?
context "for a manager" do
let(:user) { create(:user, :manager) }
let!(:project) { create(:project, members: user, account: user.primary_account) }
scenario "can manage projects" do
visit projects_path
expect(page).not_to have_link("Create New Project")
expect(page).to have_link("Edit", href: edit_project_path(project))
expect(page).not_to have_link("Delete", href: project_path(project))
# expect(page).to have_link("Archive", href: project_archivals_path(project))
end
end
context "for an associate" do
let(:user) { create(:user, :associate) }
let!(:project) { create(:project, members: user, account: user.primary_account) }
scenario "cannot manage projects" do
visit projects_path
expect(page).not_to have_link("Create New Project")
expect(page).not_to have_link("Edit", href: edit_project_path(project))
expect(page).not_to have_link("Delete", href: project_path(project))
# expect(page).not_to have_link("Archive", href: project_archivals_path(project))
end
end
private
def enable_all_project_features(project)
disable_project_features(project)
end
def disable_project_features(project, *features)
defaults = {
appearance_release: true,
location_release: true,
material_release: true,
acquired_media_release: true,
talent_release: true,
music_release: true,
video_analysis: true,
}
disabled_features = Array.wrap(features).each_with_object({}) { |feature, hash| hash[feature] = false }
project.settings(:features).update(defaults.merge(disabled_features))
end
end

View File

@@ -0,0 +1,34 @@
require "rails_helper"
feature "User managing reports" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
before :each do
sign_in current_user
end
scenario "searching for a report", js: true do
create(:video, :published, project: project, name: "My Video", number: "001")
visit project_reports_path(project)
fill_in "query", with: "Production"
click_on "search-button"
expect(page).to have_content "Production Elements Log"
expect(page).not_to have_content "GFX Cue List"
expect(page).not_to have_content "Music Cue Sheet"
expect(page).not_to have_content "BiG Music Cue Sheet"
expect(page).not_to have_content "Issues and Concerns Report"
fill_in "query", with: "Cue"
click_on "search-button"
expect(page).not_to have_content "Production Elements Log"
expect(page).to have_content "GFX Cue List"
expect(page).to have_content "Music Cue Sheet"
expect(page).to have_content "BiG Music Cue Sheet"
expect(page).not_to have_content "Issues and Concerns Report"
end
end

View File

@@ -0,0 +1,379 @@
require "rails_helper"
feature "User managing talent releases" do
let(:current_user) { create(:user, :manager) }
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release for an adult", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_talent_release_path(project.account, project, contract_template)
by "filling out the form" do
fill_in person_first_name_field, with: "Jane"
fill_in person_last_name_field, with: "Doe"
fill_in person_address_field, with: "123 Test Lane, New York, NY 10000"
fill_in person_phone_field, with: "555-555-5555"
fill_in person_email_field, with: "jane.doe@test.com"
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
draw_signature file_fixture("signature.png"), "talent_release_signature_base64"
end
click_button "I have read and agree to the above"
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
scenario "creating a release for a minor", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_talent_release_path(project.account, project, contract_template)
expect(page).not_to have_content("GUARDIAN INFORMATION")
expect(page).not_to have_content("GUARDIAN PHOTO")
page.check person_is_minor_checkbox
expect(page).to have_content("GUARDIAN INFORMATION")
expect(page).to have_content("GUARDIAN PHOTO")
by "filling out the form" do
fill_in guardian_first_name_field, with: "Guardian"
fill_in guardian_last_name_field, with: "Name"
fill_in guardian_phone_field, with: "001101"
fill_in person_first_name_field, with: "Jane"
fill_in person_last_name_field, with: "Doe"
fill_in person_address_field, with: "123 Test Lane, New York, NY 10000"
fill_in person_phone_field, with: "555-555-5555"
fill_in person_email_field, with: "jane.doe@test.com"
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
attach_file guardian_photo_field, file_fixture("hemsworth.jpeg"), visible: :all
draw_signature file_fixture("signature.png"), "talent_release_signature_base64"
end
click_button "I have read and agree to the above"
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
end
context "when signed in" do
before :each do
sign_in current_user
end
scenario "creating a release", js: true do
visit new_project_talent_release_path(project)
by "attaching only a contract" do
attach_file "talent_release[contract]", Rails.root.join(file_fixture("contract.pdf")), visible: false
click_button create_release_button
expect(page).to have_invalid_field("Person first name")
end
by "attaching photos" do
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
click_button create_release_button
expect(page).to have_invalid_field("Person first name")
end
by "filling out the remaining information" do
fill_in person_first_name_field, with: "John"
fill_in person_last_name_field, with: "Doe"
fill_in_exploitable_rights
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_photo("person_photo.png")
click_on "Manage"
expect(page).to have_link("Download")
end
end
scenario "creating a release for minor", js: true do
visit new_project_talent_release_path(project)
expect(page).not_to have_content("Guardian Photo")
page.check person_is_minor_checkbox
expect(page).to have_content("Guardian Photo")
fill_in person_first_name_field, with: "John"
fill_in person_last_name_field, with: "Doe"
fill_in guardian_first_name_field, with: "Guardian"
fill_in guardian_last_name_field, with: "Name"
fill_in guardian_phone_field, with: "01010"
fill_in_exploitable_rights
attach_file "talent_release[contract]", Rails.root.join(file_fixture("contract.pdf")), visible: false
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
attach_file guardian_photo_field, Rails.root.join(file_fixture("hemsworth.jpeg")), visible: false
click_button create_release_button
expect(page).to have_content(create_release_notice)
expect(page).to have_photo("person_photo.png")
end
scenario "updating an existing release" do
talent_release = create(:talent_release, project: project)
visit project_talent_releases_path(project)
click_link *update_talent_release_link(talent_release)
fill_in "talent_release[person_first_name]", with: "New"
fill_in "talent_release[person_last_name]", with: "Release Name"
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "New Test"
click_button update_release_button
expect(page).to have_content(update_release_notice)
expect(page).to have_content("New Release Name")
end
scenario "deleting an existing release" do
talent_release = create(:talent_release, project: project)
visit project_talent_releases_path(project)
click_link *destroy_talent_release_link(talent_release)
expect(page).to have_content(destroy_release_alert)
expect(page).not_to have_content(talent_release.name)
end
scenario "searching for a release", js: true do
create(:talent_release, person_first_name: "Robert Downey Jr.", person_last_name: "Downey Jr.", project: project)
create(:talent_release, person_first_name: "Chris", person_last_name: "Evans", project: project)
visit project_talent_releases_path(project)
within "form#search" do
fill_in "Search", with: "Robert"
click_on "button"
end
expect(page).to have_content("Robert Downey Jr.")
expect(page).not_to have_content("Chris Evans")
expect(page).to have_field("Search", with: "Robert")
end
scenario "adding photos to an existing release", js: true do
create(:talent_release, person_first_name: "Robert", person_last_name: "Downey Jr.", project: project)
visit project_talent_releases_path(project)
click_on "Manage"
click_on "Photos"
expect(page).to have_content("Add Photos")
expect(page).to have_content("Robert Downey Jr.")
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
click_on "Save Changes"
expect(page).to have_content("The release has been updated")
end
scenario "viewing the contract PDF" do
talent_release = create(:talent_release_with_contract_template_and_photos,
:native,
project: project,
person_first_name: "Jane",
person_last_name: "Doe",
tag_list: "Woman, Brunette",
notes: [
build(:note,
content: "Note 1",
user: build(:user, email: "jane.doe@test.com"),
email: "jane.doe@test.com",
created_at: DateTime.new(2020, 2, 21, 12, 0, 0),),
build(:note,
content: "Note 2",
user: build(:user, email: "john.doe@test.com"),
email: "john.doe@test.com",
created_at: DateTime.new(2020, 2, 20, 11, 0, 0),),
])
sign_in(current_user)
visit project_talent_releases_path(project)
click_link *view_release_pdf_link_for(talent_release)
expect(content_type).to eq("application/pdf")
expect(content_disposition).to include("inline")
expect(pdf_filename).to include("doe-jane")
expect(pdf_body).to have_content("Jane Doe")
expect(pdf_body).to have_content("NOTES")
expect(pdf_body).to have_content("Note 1")
expect(pdf_body).to have_content("jane.doe@test.com")
expect(pdf_body).to have_content("2/21/20 12:00 PM")
expect(pdf_body).to have_content("Note 2")
expect(pdf_body).to have_content("john.doe@test.com")
expect(pdf_body).to have_content("2/20/20 11:00 AM")
expect(pdf_body).to have_content("TAGS")
expect(pdf_body).to have_content("Woman")
expect(pdf_body).to have_content("Brunette")
expect(pdf_body).to have_content photos_heading.upcase
expect(pdf_body).to have_content("person_photo.png")
end
scenario "viewing the contract PDF for a minor without guardian photo" do
talent_release = create(:talent_release_with_contract_template, :native, :minor, project: project)
visit project_talent_releases_path(project)
click_link *view_release_pdf_link_for(talent_release)
expect(content_type).to eq("application/pdf")
expect(content_disposition).to include("inline")
expect(pdf_filename).to include(talent_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(talent_release.name)
expect(pdf_body).to have_content(talent_release.guardian_name)
expect(pdf_body).to have_content photos_heading.upcase
talent_release.photos.each do |photo|
expect(pdf_body).to have_content(photo.filename.to_s)
end
end
scenario "viewing the contract PDF for a minor with guardian photo" do
talent_release = create(:talent_release_with_contract_template, :native, :minor_with_guardian_photo, project: project)
visit project_talent_releases_path(project)
click_link *view_release_pdf_link_for(talent_release)
expect(content_type).to eq("application/pdf")
expect(content_disposition).to include("inline")
expect(pdf_filename).to include(talent_release.filename_suffix.parameterize)
expect(pdf_body).to have_content(talent_release.name)
expect(pdf_body).to have_content(talent_release.guardian_name)
expect(pdf_body).to have_content photos_heading(2).upcase
talent_release.photos.each do |photo|
expect(pdf_body).to have_content(photo.filename.to_s)
end
expect(pdf_body).to have_content(talent_release.guardian_photo.filename.to_s)
end
end
context "when the user is associate" do
let(:current_user) { create(:user, :associate) }
scenario "should not show download" do
create(:talent_release_with_contract_template, person_first_name: "Robert", person_last_name: "Downey Jr.", project: project)
sign_in current_user
visit project_talent_releases_path(project)
click_on "Manage"
expect(page).not_to have_link("Download", exact: true)
end
end
private
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
def person_is_minor_checkbox
"talent_release_minor"
end
def guardian_first_name_field
"Guardian first name"
end
def guardian_last_name_field
"Guardian last name"
end
def guardian_phone_field
"Guardian phone"
end
def guardian_photo_field
"talent_release[guardian_photo]"
end
def have_photo_button
have_selector(".take-photo-button")
end
def person_first_name_field
"talent_release[person_first_name]"
end
def person_last_name_field
"talent_release[person_last_name]"
end
def person_address_field
"talent_release[person_address_street1]"
end
def person_email_field
"talent_release[person_email]"
end
def person_phone_field
"talent_release[person_phone]"
end
def import_talent_release_link(project)
["Import Release", href: new_project_talent_release_path(project)]
end
def update_talent_release_link(talent_release)
["Edit", href: edit_talent_release_path(talent_release)]
end
def destroy_talent_release_link(talent_release)
["Delete", href: talent_release_path(talent_release)]
end
def view_release_pdf_link_for(talent_release)
["Download", href: talent_release_contracts_path(talent_release, format: "pdf")]
end
def have_photo(filename)
have_selector("img[src*='#{filename}']", visible: :all)
end
def create_release_button
t "helpers.submit.talent_release.create"
end
def create_release_notice
t "talent_releases.create.notice"
end
def update_release_button
t "helpers.submit.talent_release.update"
end
def update_release_notice
t "talent_releases.update.notice"
end
def destroy_release_alert
t "talent_releases.destroy.alert"
end
def successful_submission_message
"Your release was successfully submitted. Thank you."
end
def fill_in_exploitable_rights
select "Other", from: "Applicable Media"
fill_in "Describe other applicable media", with: "Test"
select "Other", from: "Territory"
fill_in "Describe other territory", with: "Test"
select "Other", from: "Term"
fill_in "Describe other term", with: "Test"
select "Other", from: "Restriction"
fill_in "Describe other restrictions", with: "Test"
end
end

View File

@@ -0,0 +1,118 @@
require "rails_helper"
feature "User managing videos" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
let!(:video) do
create(:video,
:with_graphics_only_edl_file,
:with_audio_only_edl_file,
project: project,
name: "Star Wars",
number: "1",
video_editing_system: "adobe_premiere",)
end
before :each do
sign_in current_user
end
scenario "creating a video", js: true do
visit project_videos_path(project)
click_link "Upload New Video"
expect(page).to have_content "Upload Video"
expect(page).to have_link("Avid")
expect(page).to have_link("Adobe Premiere")
click_link "Adobe Premiere"
expect(page).to have_content "Upload Video"
expect(page).to have_selector "#video_file", visible: :all
expect(page).to have_selector "#video_edl_file", visible: :all
expect(page).to have_selector "#video_graphics_only_edl_file", visible: :all
expect(page).to have_selector "#video_audio_only_edl_file", visible: :all
expect(page).to have_link "click here", href: /mailto:info@bigmedia\.ai/
fill_in_video_fields name: "New name", number: "99"
# TODO: Figure out how to test video gets created and shows up in project page
end
scenario "editing a video", js: true do
create(:video,
:with_graphics_only_edl_file,
:with_audio_only_edl_file,
project: project,
name: "Star Wars",
number: "1",
video_editing_system: "adobe_premiere",)
video_data = {
name: "Star Wars",
number: "1",
}
visit project_videos_path(project)
all('a', :text => /Edit/)[1].click
within "#current-edl-file" do
expect(page).to have_content("sample-edl.edl")
end
within "#current-graphics-only-edl-file" do
expect(page).to have_content("sample-edl.edl")
end
within "#current-audio-only-edl-file" do
expect(page).to have_content("sample-edl.edl")
end
expect(page).to have_filled_in_data(video_data)
fill_in_video_fields name: "New name", number: "99"
accept_alert do
click_button "Save Changes"
end
expect(page).to have_content(update_video_notice)
end
scenario "searching for a video", js: true do
create(:video, project: project, name: "First Video")
create(:video, project: project, name: "Second Video")
visit project_videos_path(project)
fill_in "query", with: "First"
click_on "search-button"
expect(page).to have_content("First Video")
expect(page).not_to have_content("Second Video")
fill_in "query", with: "Second"
click_on "search-button"
expect(page).not_to have_content("First Video")
expect(page).to have_content("Second Video")
end
private
def fill_in_video_fields(data)
fill_in "video[name]", with: data[:name]
fill_in "video[number]", with: data[:number]
end
def have_filled_in_data(data)
have_selector("#video_name[value='#{data[:name]}']")
have_selector("#video_number[value='#{data[:number]}']")
end
def create_video_notice
t "videos.update.notice"
end
def update_video_notice
t "videos.update.notice"
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
require "rails_helper"
feature "User" do
let(:user) { create(:user, :with_name, email: "test@example.com") }
let!(:project) { create(:project, account: user.primary_account, name: "My Video Project") }
context "when signing in" do
scenario "is redirected on success" do
visit "/"
fill_in "Email", with: "test@example.com"
fill_in "Password", with: "password"
check "Remember me"
click_button "Sign In"
expect(page).to have_content "My Video Project"
end
scenario "signing out" do
sign_in user
visit signed_in_root_path
click_on user.full_name
click_link "Sign Out"
expect(page).to have_content "Sign In"
end
end
context "when signed in and accountless" do
before :each do
sign_in(create(:user, :accountless))
end
scenario "goes to accountless information page" do
visit signed_in_root_path
expect(page).to have_content /You are signed in but not added to an account/
end
end
context "when signed in" do
before :each do
sign_in(user)
end
scenario "sees 404 page when navigating to unknown url" do
expect { visit "/foo" }.to raise_exception(ActionController::RoutingError)
end
scenario "gets redirected to project page when navigating to sessions url" do
visit new_session_path
expect(page).to have_content user.primary_account.name
end
scenario "sees project page when navigating to known url" do
visit project_path(project)
expect(page).to have_content "My Video Project"
end
end
context "when not signed in" do
scenario "gets redirected to sign in path when navigating to unknown url" do
expect { visit "/en/foo" }.to raise_exception(ActionController::RoutingError)
end
scenario "gets redirected to sign in path when navigating to known url" do
visit project_path(project)
expect(page.current_path).to eq "/en/session/new"
end
end
end

View File

@@ -0,0 +1,75 @@
require "rails_helper"
feature "User creates tags" do
let(:current_user) { create(:user) }
let(:project) { create(:project, account: current_user.primary_account) }
shared_examples "a taggable collection UI", js: true do
specify do
sign_in current_user
visit polymorphic_path [subject.first.project, subject.first.model_name.plural]
by "adding a tag to multiple releases" do
select_multiple_releases(subject)
submit_tags_modal(subject, tags: "Test tag!")
expect(page).to have_content("Test tag!", count: 5)
end
end
def select_multiple_releases(release)
all('input[type=checkbox]').each do |checkbox|
if !checkbox.checked? then
checkbox.click
end
end
click_link "Tag All"
end
def submit_tags_modal(releases, tags:)
action = url_for([:tag_multiple, releases.first.model_name.plural, only_path: true])
tags_form = "form[action='#{action}']"
within tags_form do
fill_in "Name", with: tags
click_button "Add"
end
end
end
context "for appearance releases" do
subject! { create_list(:appearance_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for talent releases" do
subject! { create_list(:talent_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for location releases" do
subject! { create_list(:location_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for material releases" do
subject! { create_list(:material_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for acquired media releases" do
subject! { create_list(:acquired_media_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
context "for music releases" do
subject! { create_list(:music_release, 5, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
end