Compare commits
5 Commits
allow-unde
...
enable-big
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
057bdfe882 | ||
|
|
545d12f427 | ||
|
|
ac7e67c20e | ||
|
|
9bafbe36db | ||
|
|
3db230de9b |
@@ -1,4 +1,30 @@
|
||||
// Do not allow file attachments in rich text content
|
||||
addEventListener("trix-file-accept", function(event) {
|
||||
event.preventDefault();
|
||||
})
|
||||
});
|
||||
|
||||
Trix.config.textAttributes.underline = {
|
||||
style: { "textDecoration": "underline" },
|
||||
inheritable: true,
|
||||
parser: function (element) {
|
||||
var style = window.getComputedStyle(element);
|
||||
return style.textDecoration === "underline";
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('trix-initialize', function (e) {
|
||||
const trix = e.target;
|
||||
const toolBar = trix.toolbarElement;
|
||||
|
||||
// // Creation of the button
|
||||
const button = document.createElement("button");
|
||||
button.setAttribute("type", "button");
|
||||
button.setAttribute("class", "trix-button trix-button--icon trix-button--icon-underline");
|
||||
button.setAttribute("data-trix-attribute", "underline");
|
||||
button.setAttribute("title", "underline");
|
||||
button.setAttribute("tabindex", "-1");
|
||||
button.innerText = "U";
|
||||
|
||||
// Attachment of the button to the toolBar
|
||||
toolBar.querySelector('.trix-button-group--text-tools').appendChild(button);
|
||||
});
|
||||
@@ -461,3 +461,10 @@ a[data-behavior=seekable-timecode] {
|
||||
border-color: transparent;
|
||||
border-bottom: 3px solid #ff0000;
|
||||
}
|
||||
|
||||
//Trix underline style
|
||||
trix-toolbar {
|
||||
.trix-button--icon-underline::before {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z'/%3E%3C/svg%3E");
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,10 @@ u {
|
||||
margin-right: -30px;
|
||||
}
|
||||
|
||||
.embed-person-photo {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.do-not-copy-warning {
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class AccountSessionsController < ApplicationController
|
||||
skip_before_action :redirect_locked_accounts
|
||||
def update
|
||||
authorize :account_session, :update?
|
||||
session[:active_account] = account_session_params[:account_id]
|
||||
|
||||
31
app/controllers/admin/account_locks_controller.rb
Normal file
31
app/controllers/admin/account_locks_controller.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
class Admin::AccountLocksController < Admin::ApplicationController
|
||||
before_action :set_account
|
||||
|
||||
def create
|
||||
authorize :account_lock, :create?
|
||||
@account.update(locked: true)
|
||||
redirect_to admin_accounts_path, notice: 'Account locked'
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize :account_lock, :destroy?
|
||||
@account.update(locked: false)
|
||||
redirect_to admin_accounts_path, notice: 'Account unlocked'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
if params[:account_id].present?
|
||||
@account = Account.find_by(slug: params[:account_id])
|
||||
else
|
||||
failure_redirect
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
failure_redirect
|
||||
end
|
||||
|
||||
def failure_redirect
|
||||
redirect_to admin_accounts_path, alert: 'Failed to find the account'
|
||||
end
|
||||
end
|
||||
@@ -13,6 +13,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
include SetCurrentRequestDetails
|
||||
before_action :redirect_accountless
|
||||
before_action :redirect_locked_accounts
|
||||
|
||||
private
|
||||
|
||||
@@ -29,6 +30,12 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_locked_accounts
|
||||
if Current.user && !Current.user.admin? && Current.account.present? && Current.account.locked?
|
||||
redirect_to locked_account_path
|
||||
end
|
||||
end
|
||||
|
||||
def signed_in_as_admin?
|
||||
signed_in? && current_user.admin?
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ class ContractsController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.pdf { send_contract_pdf }
|
||||
|
||||
if Rails.env.development?
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
format.html { render_sample_html }
|
||||
end
|
||||
end
|
||||
|
||||
10
app/controllers/locked_accounts_controller.rb
Normal file
10
app/controllers/locked_accounts_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class LockedAccountsController < ApplicationController
|
||||
skip_before_action :redirect_locked_accounts
|
||||
skip_after_action :verify_policy_scoped
|
||||
|
||||
def index
|
||||
unless Current.account.locked?
|
||||
redirect_to projects_path
|
||||
end
|
||||
end
|
||||
end
|
||||
9
app/policies/account_lock_policy.rb
Normal file
9
app/policies/account_lock_policy.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class AccountLockPolicy < ApplicationPolicy
|
||||
def create?
|
||||
user.admin?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user.admin?
|
||||
end
|
||||
end
|
||||
@@ -30,6 +30,11 @@
|
||||
<%= link_to fa_icon("arrow-right", text: "Overview"), admin_account_path(account), class: "dropdown-item" %>
|
||||
<%= link_to fa_icon("pencil", text: "Edit"), edit_admin_account_path(account), class: "dropdown-item" %>
|
||||
<%= link_to fa_icon("arrow-right", text: "Account Managers"), account_auths_path({ account_id: account.id}), class: "dropdown-item" %>
|
||||
<% if account.locked? %>
|
||||
<%= link_to fa_icon("unlock", text: "Unlock Account"), [:admin, account, :lock], method: :delete, class: "dropdown-item" %>
|
||||
<% else %>
|
||||
<%= link_to fa_icon("lock", text: "Lock Account"), [:admin, account, :lock], method: :post, class: "dropdown-item" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -4,19 +4,31 @@
|
||||
</div>
|
||||
<hr>
|
||||
<% end %>
|
||||
<% if preview %>
|
||||
<h1>PREVIEW ONLY</h1>
|
||||
<% end %>
|
||||
<% if contract_template.body.present? %>
|
||||
<%= contract_template.body %>
|
||||
<br/>
|
||||
<% end %>
|
||||
<% if releasable.minor? && contract_template.guardian_clause.present? %>
|
||||
<p class="text-left"><strong>Guardian Clause</strong></p>
|
||||
<%= contract_template.guardian_clause %>
|
||||
<% end %>
|
||||
|
||||
<% if releasable.respond_to?(:question_1_answer) %>
|
||||
<div class="page">
|
||||
<% if preview %>
|
||||
<h1>PREVIEW ONLY</h1>
|
||||
<% end %>
|
||||
|
||||
<% if releasable.model_name == "AppearanceRelease" && releasable.person_photo.attached? %>
|
||||
<div class="embed-person-photo">
|
||||
<%= image_tag releasable.photos.first.variant(auto_orient: true, resize: "200x200"), id: "top-person-photo" %>
|
||||
</div>
|
||||
<hr>
|
||||
<% end %>
|
||||
|
||||
<% if contract_template.body.present? %>
|
||||
<%= contract_template.body %>
|
||||
<br/>
|
||||
<% end %>
|
||||
|
||||
<% if releasable.minor? && contract_template.guardian_clause.present? %>
|
||||
<p class="text-left"><strong>Guardian Clause</strong></p>
|
||||
<%= contract_template.guardian_clause %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if contract_template.present? && contract_template.has_questionnaire? %>
|
||||
<div class="page">
|
||||
<%= render "contracts/questionnaire", releasable: releasable, contract_template: contract_template, preview: preview %>
|
||||
</div>
|
||||
|
||||
1
app/views/locked_accounts/index.html.erb
Normal file
1
app/views/locked_accounts/index.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<p><%= t '.account_locked_message' %></p>
|
||||
@@ -1651,3 +1651,6 @@ en:
|
||||
edit: Edit
|
||||
report: Report
|
||||
generating: Generating...
|
||||
locked_accounts:
|
||||
index:
|
||||
account_locked_message: This account is locked. Please contact a BIG admin.
|
||||
|
||||
@@ -705,3 +705,6 @@ es:
|
||||
production_elements_logs: Production Elements Logs, and more (ES)
|
||||
reduces_labor_cost: Reduces labor costs (ES)
|
||||
simplifies_cue_sheets: Simplifies Music Cue Sheets, Graphic Cue Sheets (ES)
|
||||
locked_accounts:
|
||||
index:
|
||||
account_locked_message: This account is locked. Please contact a BIG admin. (ES)
|
||||
|
||||
@@ -30,7 +30,9 @@ Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
mount Sidekiq::Web => '/background_queue', as: :background_queue
|
||||
|
||||
resources :accounts, only: [:index, :new, :create, :edit, :update, :show]
|
||||
resources :accounts, only: [:index, :new, :create, :edit, :update, :show] do
|
||||
resource :account_lock, path: :lock, as: :lock, only: [:create, :destroy]
|
||||
end
|
||||
resources :users, only: [:index, :new, :create, :edit, :update, :destroy] do
|
||||
resource :masquerade, only: :create
|
||||
end
|
||||
@@ -48,7 +50,9 @@ Rails.application.routes.draw do
|
||||
scope "(:locale)", locale: AVAILABLE_LOCALES_REGEX do
|
||||
resource :account_session, only: [:update]
|
||||
resource :session, only: [:destroy]
|
||||
resource :account, only: [:new, :create, :update]
|
||||
resource :account, only: [:new, :create, :update] do
|
||||
get 'locked' => 'locked_accounts#index'
|
||||
end
|
||||
resources :account_auths, only: [:index, :create, :update, :destroy]
|
||||
resources :projects, shallow: true do
|
||||
resources :acquired_media_releases, except: [:show], concerns: [:contractable, :notable, :file_uploadable]
|
||||
|
||||
5
db/migrate/20200908085319_add_locked_to_accounts.rb
Normal file
5
db/migrate/20200908085319_add_locked_to_accounts.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddLockedToAccounts < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :accounts, :locked, :boolean, default: false
|
||||
end
|
||||
end
|
||||
@@ -95,7 +95,8 @@ CREATE TABLE public.accounts (
|
||||
slug character varying,
|
||||
plan_uid character varying,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
locked boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
@@ -4027,6 +4028,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20200812060406'),
|
||||
('20200819070738'),
|
||||
('20200820082501'),
|
||||
('20200824171649');
|
||||
('20200824171649'),
|
||||
('20200908085319');
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,22 @@ FactoryBot.define do
|
||||
amendment_clause "Amendment Legal Language"
|
||||
end
|
||||
|
||||
trait :with_questionnaire_legal_text do
|
||||
questionnaire_legal_text "Questionnaire Legal Text"
|
||||
end
|
||||
|
||||
trait :with_one_question do
|
||||
question_1_text "Is this a question?"
|
||||
end
|
||||
|
||||
trait :with_exhibits do
|
||||
exhibit_a_legal_text "Exhibit A legal text"
|
||||
exhibit_b_legal_text "Exhibit B legal text"
|
||||
|
||||
exhibit_a_question_text "Exhibit A question text"
|
||||
exhibit_b_question_text "Exhibit B question text"
|
||||
end
|
||||
|
||||
factory :appearance_release_contract_template do
|
||||
release_type "appearance"
|
||||
end
|
||||
|
||||
@@ -30,6 +30,24 @@ feature "Admin managing accounts" do
|
||||
expect(page).to have_content "Created at less than a minute ago"
|
||||
end
|
||||
|
||||
scenario "locks and unlocks account" do
|
||||
sign_in current_user
|
||||
visit admin_signed_in_root_path
|
||||
expect(Account.last.locked?).to eq false
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Unlock Account"
|
||||
click_link "Lock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq true
|
||||
|
||||
click_button "Manage"
|
||||
expect(page).not_to have_content "Lock Account"
|
||||
click_link "Unlock Account"
|
||||
|
||||
expect(Account.last.locked?).to eq false
|
||||
end
|
||||
|
||||
scenario "sees videos for an account in the system" do
|
||||
visit_account_overview_page
|
||||
|
||||
|
||||
@@ -386,6 +386,13 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(ct.signature_legal_text.id).not_to eq ContractTemplate.last.signature_legal_text.id
|
||||
end
|
||||
|
||||
scenario 'trix editor has underline button', js: true do
|
||||
visit new_project_contract_template_path(project)
|
||||
|
||||
select 'Appearance Release', from: 'Release type'
|
||||
expect(page).to have_selector("button[data-trix-attribute='underline']")
|
||||
end
|
||||
|
||||
context 'When the user is associate' do
|
||||
let(:current_user) { create(:user, :associate) }
|
||||
|
||||
|
||||
@@ -544,7 +544,7 @@ feature 'User managing appearance releases' do
|
||||
expect(pdf_body).to have_content('Guardian Email')
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF when exhibit A is signed" do
|
||||
scenario "viewing the contract PDF when exhibit A is signed and without questionnaire" do
|
||||
contract_template = create(:appearance_release_contract_template, project: project, exhibit_a_legal_text: "Exhibit A legal text", exhibit_a_question_text: "Exhibit A question text")
|
||||
appearance_release = create(:appearance_release,
|
||||
:amendment_signed,
|
||||
@@ -566,10 +566,122 @@ feature 'User managing appearance releases' do
|
||||
|
||||
expect(pdf_body).to have_content("John Doe")
|
||||
|
||||
expect(pdf_body).to have_content "Exhibit A"
|
||||
expect(pdf_body).to have_content exhibit_a_heading
|
||||
expect(pdf_body).to have_content "Exhibit A legal text"
|
||||
expect(pdf_body).to have_content "Exhibit A question text"
|
||||
expect(pdf_body).to have_content "Answer to exhibit A question"
|
||||
|
||||
expect(pdf_body).not_to have_content questionnaire_heading
|
||||
expect(pdf_body).not_to have_content exhibit_b_heading
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF when exhibit B is signed and without questionnaire" do
|
||||
contract_template = create(:appearance_release_contract_template, project: project, exhibit_b_legal_text: "Exhibit B legal text", exhibit_b_question_text: "Exhibit B question text")
|
||||
appearance_release = create(:appearance_release,
|
||||
:amendment_signed,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
person_first_name: "John",
|
||||
person_last_name: "Doe",
|
||||
exhibit_b_answer: "Answer to exhibit B question"
|
||||
)
|
||||
|
||||
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-john")
|
||||
|
||||
expect(pdf_body).to have_content("John Doe")
|
||||
|
||||
expect(pdf_body).to have_content exhibit_b_heading
|
||||
expect(pdf_body).to have_content "Exhibit B legal text"
|
||||
expect(pdf_body).to have_content "Exhibit B question text"
|
||||
expect(pdf_body).to have_content "Answer to exhibit B question"
|
||||
|
||||
expect(pdf_body).not_to have_content questionnaire_heading
|
||||
expect(pdf_body).not_to have_content exhibit_a_heading
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF with questionnaire and without exhibits" do
|
||||
contract_template = create(:appearance_release_contract_template, :with_questionnaire_legal_text, :with_one_question, project: project)
|
||||
appearance_release = create(:appearance_release,
|
||||
:amendment_signed,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
person_first_name: "John",
|
||||
person_last_name: "Doe",
|
||||
question_1_answer: "Yes"
|
||||
)
|
||||
|
||||
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-john")
|
||||
|
||||
expect(pdf_body).to have_content questionnaire_heading
|
||||
expect(pdf_body).to have_content contract_template.question_1_text
|
||||
expect(pdf_body).to have_content appearance_release.question_1_answer
|
||||
|
||||
expect(pdf_body).not_to have_content exhibit_a_heading
|
||||
expect(pdf_body).not_to have_content exhibit_b_heading
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF with questionnaire and with exhibits" do
|
||||
contract_template = create(:appearance_release_contract_template,
|
||||
:with_questionnaire_legal_text,
|
||||
:with_one_question,
|
||||
:with_exhibits,
|
||||
project: project)
|
||||
appearance_release = create(:appearance_release,
|
||||
:amendment_signed,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
person_first_name: "John",
|
||||
person_last_name: "Doe",
|
||||
question_1_answer: "Yes",
|
||||
exhibit_a_answer: "Exhibit A answer",
|
||||
exhibit_b_answer: "Exhibit B answer"
|
||||
)
|
||||
|
||||
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-john")
|
||||
|
||||
expect(pdf_body).to have_content questionnaire_heading
|
||||
expect(pdf_body).to have_content contract_template.question_1_text
|
||||
expect(pdf_body).to have_content appearance_release.question_1_answer
|
||||
|
||||
expect(pdf_body).to have_content exhibit_a_heading
|
||||
expect(pdf_body).to have_content contract_template.exhibit_a_legal_text.to_plain_text
|
||||
expect(pdf_body).to have_content contract_template.exhibit_a_question_text
|
||||
expect(pdf_body).to have_content appearance_release.exhibit_a_answer
|
||||
|
||||
expect(pdf_body).to have_content exhibit_b_heading
|
||||
expect(pdf_body).to have_content contract_template.exhibit_b_legal_text.to_plain_text
|
||||
expect(pdf_body).to have_content contract_template.exhibit_b_question_text
|
||||
expect(pdf_body).to have_content appearance_release.exhibit_b_answer
|
||||
end
|
||||
|
||||
scenario "viewing the contract PDF - it shows person photo on first page if person photo is attached" do
|
||||
appearance_release = create(:appearance_release_with_contract_template, :native, :minor_with_guardian_photo, project: project)
|
||||
|
||||
visit view_release_pdf_html_preview_link_for(appearance_release)
|
||||
|
||||
person_photo_url = url_for(appearance_release.person_photo.variant(auto_orient: true, resize: "200x200")).to_s
|
||||
expect(page).to have_selector("#top-person-photo[src^='#{person_photo_url}']")
|
||||
end
|
||||
|
||||
scenario 'deleting a release', js: true do
|
||||
@@ -908,6 +1020,10 @@ feature 'User managing appearance releases' do
|
||||
['Download', href: appearance_release_contracts_path(appearance_release, format: 'pdf')]
|
||||
end
|
||||
|
||||
def view_release_pdf_html_preview_link_for(appearance_release)
|
||||
appearance_release_contracts_path(appearance_release)
|
||||
end
|
||||
|
||||
def successful_submission_message
|
||||
'Your release was successfully submitted. Thank you.'
|
||||
end
|
||||
@@ -987,4 +1103,16 @@ feature 'User managing appearance releases' do
|
||||
def amendment_signature_label
|
||||
t 'contracts.amendment_page.description_labels.amendment_signature'
|
||||
end
|
||||
|
||||
def questionnaire_heading
|
||||
t 'contracts.questionnaire.heading.appearance_release'
|
||||
end
|
||||
|
||||
def exhibit_a_heading
|
||||
t 'contracts.exhibit_a_page.heading.appearance_release'
|
||||
end
|
||||
|
||||
def exhibit_b_heading
|
||||
t 'contracts.exhibit_b_page.heading.appearance_release'
|
||||
end
|
||||
end
|
||||
|
||||
34
spec/features/user_managing_locked_account_spec.rb
Normal file
34
spec/features/user_managing_locked_account_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require "rails_helper"
|
||||
|
||||
feature "User managing locked account" do
|
||||
let(:user) { create(:user, :account_manager) }
|
||||
let(:project) { create(:project) }
|
||||
|
||||
before do
|
||||
sign_in(user)
|
||||
user.accounts.first.update(locked: true)
|
||||
end
|
||||
|
||||
scenario "user is redirected to custom landing page when opens projects index page" do
|
||||
paths = [
|
||||
projects_path,
|
||||
project_path(project),
|
||||
project_task_requests_path(project),
|
||||
project_contract_templates_path(project),
|
||||
project_broadcasts_path(project),
|
||||
project_videos_path(project),
|
||||
]
|
||||
|
||||
paths.each do |path|
|
||||
visit path
|
||||
|
||||
expect(page).to have_content locked_account_warning
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def locked_account_warning
|
||||
t 'locked_accounts.index.account_locked_message'
|
||||
end
|
||||
end
|
||||
@@ -244,11 +244,32 @@ feature "User managing medical releases" do
|
||||
expect(pdf_filename).to include("doe-john")
|
||||
|
||||
expect(pdf_body).to have_content("John Doe")
|
||||
expect(pdf_body).to have_content "MEDICAL QUESTIONNAIRE"
|
||||
expect(pdf_body).to have_content questionnaire_heading.upcase
|
||||
expect(pdf_body).to have_content "Question 1 text"
|
||||
expect(pdf_body).to have_content "Question 1 answer"
|
||||
expect(pdf_body).to have_content "Questionnaire legal text"
|
||||
end
|
||||
|
||||
scenario 'viewing contract PDF without medical questionnaire' do
|
||||
contract_template = create(:medical_release_contract_template, project: project)
|
||||
medical_release = create(:medical_release,
|
||||
:native,
|
||||
contract_template: contract_template,
|
||||
project: project,
|
||||
person_first_name: "John",
|
||||
person_last_name: "Doe",
|
||||
)
|
||||
|
||||
sign_in(current_user)
|
||||
visit project_medical_releases_path(project)
|
||||
click_link *view_release_pdf_link_for(medical_release)
|
||||
|
||||
expect(content_type).to eq("application/pdf")
|
||||
expect(content_disposition).to include("inline")
|
||||
expect(pdf_filename).to include("doe-john")
|
||||
|
||||
expect(pdf_body).not_to have_content questionnaire_heading.upcase
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is manager(project manager)" do
|
||||
@@ -499,4 +520,8 @@ feature "User managing medical releases" do
|
||||
def dummy_signature_legal_text
|
||||
'Some signature legal language'
|
||||
end
|
||||
|
||||
def questionnaire_heading
|
||||
t 'contracts.questionnaire.heading.medical_release'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,7 +80,7 @@ feature "User managing misc releases" do
|
||||
end
|
||||
|
||||
|
||||
scenario 'viewing the contract PDF' do
|
||||
scenario 'viewing the contract PDF with questionnaire' do
|
||||
misc_release = create(:misc_release,
|
||||
:native,
|
||||
contract_template: build(:misc_release_contract_template, question_1_text: 'Q1'),
|
||||
@@ -121,10 +121,30 @@ feature "User managing misc releases" do
|
||||
expect(pdf_body).to have_content('Woman')
|
||||
expect(pdf_body).to have_content('Brunette')
|
||||
expect(pdf_body).not_to have_content('Guardian Email')
|
||||
expect(pdf_body).to have_content('QUESTIONNAIRE')
|
||||
expect(pdf_body).to have_content questionnaire_heading.upcase
|
||||
expect(pdf_body).to have_content('Q1')
|
||||
expect(pdf_body).to have_content('A1')
|
||||
end
|
||||
|
||||
scenario 'viewing the contract PDF without questionnaire' do
|
||||
misc_release = create(:misc_release,
|
||||
:native,
|
||||
contract_template: build(:misc_release_contract_template),
|
||||
project: project,
|
||||
person_first_name: 'Jane',
|
||||
person_last_name: 'Doe'
|
||||
)
|
||||
|
||||
sign_in(current_user)
|
||||
visit project_misc_releases_path(project)
|
||||
click_link *view_release_pdf_link_for(misc_release)
|
||||
|
||||
expect(content_type).to eq('application/pdf')
|
||||
expect(content_disposition).to include('inline')
|
||||
expect(pdf_filename).to include('doe-jane')
|
||||
|
||||
expect(pdf_body).not_to have_content questionnaire_heading.upcase
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is manager(project manager)" do
|
||||
@@ -215,4 +235,8 @@ feature "User managing misc releases" do
|
||||
def view_release_pdf_link_for(release)
|
||||
['Download', href: misc_release_contracts_path(release, format: 'pdf')]
|
||||
end
|
||||
|
||||
def questionnaire_heading
|
||||
t 'contracts.questionnaire.heading.misc_release'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user