Compare commits
25 Commits
only-accou
...
match-impo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa4660d819 | ||
|
|
2238338710 | ||
|
|
3650d6022c | ||
|
|
16d4d7511c | ||
|
|
c83e6cae0e | ||
|
|
fbd07a6ea6 | ||
|
|
badc3786dd | ||
|
|
47b68e86e6 | ||
|
|
f6e6d5d049 | ||
|
|
eeec214cc8 | ||
|
|
dc7f50b932 | ||
|
|
1d1df4a1da | ||
|
|
dbda554cd7 | ||
|
|
62019bcc37 | ||
|
|
3307f0ebe8 | ||
|
|
29d3fa258a | ||
|
|
9a96bf708d | ||
|
|
ffc93b470b | ||
|
|
2a6305b417 | ||
|
|
ed312c186f | ||
|
|
c903a2dcde | ||
|
|
f2283782e8 | ||
|
|
21e8933471 | ||
|
|
94c0dc3732 | ||
|
|
dafef462b2 |
@@ -8,16 +8,11 @@ $(document).on "turbolinks:load", ->
|
|||||||
# Called when the subscription has been terminated by the server
|
# Called when the subscription has been terminated by the server
|
||||||
|
|
||||||
received: (data) ->
|
received: (data) ->
|
||||||
|
return unless document.querySelector("meta[name=broadcast-token][content='#{broadcastToken}']")
|
||||||
switch data.event
|
switch data.event
|
||||||
when "broadcast_stream_update"
|
when "broadcast_stream_update" then @refreshBroadcastVideo(data)
|
||||||
return unless document.querySelector("meta[name=broadcast-token][current=true][content='#{broadcastToken}']")
|
when "stream_recording_ready" then @showBroadcastRecordings(data)
|
||||||
@refreshBroadcastVideo(data)
|
when "file_upload_update" then @refreshBroadcastFilesTab(data)
|
||||||
when "stream_recording_ready"
|
|
||||||
return unless document.querySelector("meta[name=broadcast-token][current=true][content='#{broadcastToken}']")
|
|
||||||
@showBroadcastRecordings(data)
|
|
||||||
when "file_upload_update"
|
|
||||||
return unless document.querySelector("meta[name=broadcast-token][content='#{broadcastToken}']")
|
|
||||||
@refreshBroadcastFilesTab(data)
|
|
||||||
|
|
||||||
refreshBroadcastVideo: (data) ->
|
refreshBroadcastVideo: (data) ->
|
||||||
$("#broadcast_updates").html data.status_content
|
$("#broadcast_updates").html data.status_content
|
||||||
|
|||||||
@@ -24,12 +24,8 @@ class Api::BroadcastsController < Api::ApiController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
file_params.each do |file|
|
file_params.each do |file|
|
||||||
if file.is_a?(String)
|
file[:io] = StringIO.new(Base64.decode64(file[:io]))
|
||||||
@broadcast.files.attach(file)
|
@broadcast.files.attach(io: file[:io], filename: file[:filename])
|
||||||
else
|
|
||||||
file[:io] = StringIO.new(Base64.decode64(file[:io]))
|
|
||||||
@broadcast.files.attach(file.to_h.symbolize_keys)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@broadcast.save!
|
@broadcast.save!
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,15 @@
|
|||||||
class Api::DirectUploadsController < Api::ApiController
|
class Api::DirectUploadsController < Api::ApiController
|
||||||
include ActiveStorage::SetCurrent
|
include ActiveStorage::SetCurrent
|
||||||
|
|
||||||
deserializable_resource :direct_upload, only: [:create]
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
blob = ActiveStorage::Blob.create_before_direct_upload!(blob_params)
|
blob = ActiveStorage::Blob.create_before_direct_upload!(blob_args)
|
||||||
render jsonapi: DirectUpload.new(blob)
|
render jsonapi: DirectUpload.new(blob)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def blob_params
|
def blob_args
|
||||||
params.
|
params.require(:blob).permit(:filename, :byte_size, :checksum, :content_type, :metadata).to_h.symbolize_keys
|
||||||
require(:direct_upload).
|
|
||||||
permit(:type, :filename, :byte_size, :checksum, :content_type, :metadata).
|
|
||||||
except(:type).
|
|
||||||
to_h.symbolize_keys
|
|
||||||
end
|
|
||||||
|
|
||||||
class DeserializableDirectUpload < JSONAPI::Deserializable::Resource
|
|
||||||
attributes :filename, :byte_size, :checksum, :content_type, :metadata
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class SerializableDirectUpload < JSONAPI::Serializable::Resource
|
class SerializableDirectUpload < JSONAPI::Serializable::Resource
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ class Public::BroadcastsController < Public::BaseController
|
|||||||
|
|
||||||
def set_broadcast
|
def set_broadcast
|
||||||
@broadcast = Broadcast.find_by_token(params[:token])
|
@broadcast = Broadcast.find_by_token(params[:token])
|
||||||
|
|
||||||
unless @broadcast.present?
|
|
||||||
redirect_to [:new, :session], alert: t(".alert")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class MultiViewBroadcast
|
class MultiViewBroadcast
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ class ReleaseTemplateImportsController < ApplicationController
|
|||||||
|
|
||||||
templates = []
|
templates = []
|
||||||
filtered_contract_templates.each do |contract_template|
|
filtered_contract_templates.each do |contract_template|
|
||||||
next if contract_template.duplicated? ||
|
next if contract_template.duplicated? || contract_template.project == @project
|
||||||
contract_template.archived? ||
|
|
||||||
contract_template.project == @project
|
|
||||||
|
|
||||||
already_imported = contract_template.duplicates.non_archived.pluck(:project_id).include?(@project.id)
|
already_imported = contract_template.duplicates.non_archived.pluck(:project_id).include?(@project.id)
|
||||||
templates << OpenStruct.new(template: contract_template, already_imported?: already_imported)
|
templates << OpenStruct.new(template: contract_template, already_imported?: already_imported)
|
||||||
|
|||||||
@@ -29,10 +29,6 @@ class Contract
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def medical_release?
|
|
||||||
@releasable.instance_of?(MedicalRelease)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def contract_template
|
def contract_template
|
||||||
|
|||||||
@@ -51,10 +51,6 @@ class ContractTemplate < ApplicationRecord
|
|||||||
parent.present?
|
parent.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def archived?
|
|
||||||
archived_at.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def archive
|
def archive
|
||||||
update(archived_at: Time.zone.now)
|
update(archived_at: Time.zone.now)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class HeadshotCollection
|
|||||||
collection_uid: collection_uid.to_s,
|
collection_uid: collection_uid.to_s,
|
||||||
bucket_name: aws_bucket_name,
|
bucket_name: aws_bucket_name,
|
||||||
ids_to_images: map_ids_to_images,
|
ids_to_images: map_ids_to_images,
|
||||||
}.reject { |k, v| v.blank? && k != :ids_to_images }
|
}.reject { |_, v| v.blank? }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
class ContractPolicy < ApplicationPolicy
|
class ContractPolicy < ApplicationPolicy
|
||||||
def show?
|
def show?
|
||||||
if record.respond_to?(:medical_release?) && record.medical_release?
|
user.manager? || user.account_manager?
|
||||||
user.account_manager?
|
|
||||||
else
|
|
||||||
user.manager? || user.account_manager?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class MedicalReleasePolicy < ReleasePolicy
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
user.account_manager?
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def update?
|
def update?
|
||||||
@@ -31,11 +31,7 @@ class MedicalReleasePolicy < ReleasePolicy
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_single?
|
|
||||||
user.account_manager?
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_multiple?
|
def download_multiple?
|
||||||
download_single?
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,9 +22,6 @@
|
|||||||
<%= form.text_field :guardian_last_name, required: appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
<%= form.text_field :guardian_last_name, required: appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
||||||
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
|
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
|
||||||
<%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= bootstrap_form_for model, layout: :inline, remote: true do |form| %>
|
<%= bootstrap_form_for model, layout: :inline, remote: true do |form| %>
|
||||||
<%= form.file_field :files, direct_upload: true, multiple: true, accept: "*", hide_label: true, required: true, wrapper_class: "w-65 mr-2", id: "broadcast_files_#{token}" %>
|
<%= form.file_field :files, direct_upload: true, multiple: true, accept: "*", hide_label: true, wrapper_class: "w-65 mr-2", id: "broadcast_files_#{token}" %>
|
||||||
<%= form.button fa_icon("upload", text: "Add File"), class: "btn btn-primary", type: :submit, data: { disable_with: fa_icon("spinner", text: "Adding File") } %>
|
<%= form.button fa_icon("upload", text: "Add File"), class: "btn btn-primary", type: :submit, data: { disable_with: fa_icon("spinner", text: "Adding File") } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
<meta name="project-id" content="<%= @project.id %>">
|
<meta name="project-id" content="<%= @project.id %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @broadcast %>
|
<% if @broadcast %>
|
||||||
<meta name="broadcast-token" current="true" content="<%= @broadcast.token %>">
|
<meta name="broadcast-token" content="<%= @broadcast.token %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<% # Subscribe to Action Cable for every broadcast including those in multi-view %>
|
<% # Subscribe to Action Cable for every broadcast including those in multi-view %>
|
||||||
<% @multi_view_broadcasts.each do |multi_view_broadcast| %>
|
<% @multi_view_broadcasts.each do |multi_view_broadcast| %>
|
||||||
<% if multi_view_broadcast.token != @broadcast.token %>
|
<% if multi_view_broadcast.token != @broadcast.token %>
|
||||||
<meta name="broadcast-token" current="false" content="<%= multi_view_broadcast.token %>">
|
<meta name="broadcast-token" content="<%= multi_view_broadcast.token %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<% if policy(medical_release.tags).new? %>
|
<% if policy(medical_release.tags).new? %>
|
||||||
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, medical_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, medical_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(MedicalRelease).download_single? && policy(Contract).show? && (medical_release.contract.attached? || medical_release.contract_template.present?) %>
|
<% if policy(Contract).show? && (medical_release.contract.attached? || medical_release.contract_template.present?) %>
|
||||||
<%= link_to fa_icon("download fw", text: "Download"), [medical_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
<%= link_to fa_icon("download fw", text: "Download"), [medical_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(medical_release).destroy? %>
|
<% if policy(medical_release).destroy? %>
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
|
||||||
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
|
||||||
<%= form.phone_field :person_phone, required: true, wrapper_class: "col-sm-6" %>
|
<%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.email_field :person_email, required: true, wrapper_class: "col-sm-6" %>
|
<%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
|
||||||
<%= form.date_field :person_date_of_birth, required: true, wrapper_class: "col-sm-6", placeholder: Date.current %>
|
<%= form.date_field :person_date_of_birth, wrapper_class: "col-sm-6", placeholder: Date.current %>
|
||||||
<%= form.text_field :person_address, required: true, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :person_address, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -74,13 +74,13 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.text_field :guardian_first_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
<%= form.text_field :guardian_first_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
||||||
<%= form.text_field :guardian_last_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
<%= form.text_field :guardian_last_name, required: @appearance_release.minor?, wrapper_class: "col-sm-3" %>
|
||||||
<%= form.phone_field :guardian_phone, required: @appearance_release.minor?, wrapper_class: "col-sm-6" %>
|
<%= form.phone_field :guardian_phone, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.text_field :guardian_email, required: @appearance_release.minor?, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :guardian_email, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= form.text_field :guardian_address, required: @appearance_release.minor?, wrapper_class: "col-sm-6" %>
|
<%= form.text_field :guardian_address, wrapper_class: "col-sm-6" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<div class="hidden-file-input">
|
<div class="hidden-file-input">
|
||||||
<%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @appearance_release.guardian_photo.attached? %>
|
<%= form.hidden_field :guardian_photo, value: form.object.guardian_photo.signed_id if @appearance_release.guardian_photo.attached? %>
|
||||||
<%= form.file_field :guardian_photo, required: @appearance_release.minor?, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @appearance_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
<%= form.file_field :guardian_photo, hide_label: true, data: { ujs_target: "guardian-photo-input" }, accept: @appearance_release.class.face_photo_acceptable_content_types.join(","), direct_upload: true %>
|
||||||
</div>
|
</div>
|
||||||
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %>
|
<%= button_tag t(".photo.take_photo"), type: "button", class: "btn btn-lg btn-primary take-photo-button", data: { behavior: "take-guardian-photo" } %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= bootstrap_form_for model, url: broadcast_url(token: token), layout: :inline, remote: true do |form| %>
|
<%= bootstrap_form_for model, url: broadcast_url(token: token), layout: :inline, remote: true do |form| %>
|
||||||
<%= form.file_field :files, direct_upload: true, multiple: true, accept: "*", hide_label: true, required: true, wrapper_class: "w-65 mr-2", id: "broadcast_files_#{token}" %>
|
<%= form.file_field :files, direct_upload: true, multiple: true, accept: "*", hide_label: true, wrapper_class: "w-65 mr-2", id: "broadcast_files_#{token}" %>
|
||||||
<%= form.button fa_icon("upload", text: "Add File"), class: "btn btn-primary", type: :submit, data: { disable_with: fa_icon("spinner", text: "Adding File") } %>
|
<%= form.button fa_icon("upload", text: "Add File"), class: "btn btn-primary", type: :submit, data: { disable_with: fa_icon("spinner", text: "Adding File") } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -814,9 +814,6 @@ en:
|
|||||||
warning: If your photo appears sideways, it will be autocorrected when you submit your release.
|
warning: If your photo appears sideways, it will be autocorrected when you submit your release.
|
||||||
signature:
|
signature:
|
||||||
heading: Sign Below
|
heading: Sign Below
|
||||||
broadcasts:
|
|
||||||
show:
|
|
||||||
alert: That broadcast is no longer available
|
|
||||||
location_releases:
|
location_releases:
|
||||||
create:
|
create:
|
||||||
notice: Your release has been signed. Thank you!
|
notice: Your release has been signed. Thank you!
|
||||||
|
|||||||
@@ -128,26 +128,6 @@ RSpec.describe Api::BroadcastsController, type: :controller do
|
|||||||
expect(included.first.dig("id")).to eq broadcast.files.first.id.to_s
|
expect(included.first.dig("id")).to eq broadcast.files.first.id.to_s
|
||||||
expect(included.first.dig("type")).to eq 'active_storage_attachment'
|
expect(included.first.dig("type")).to eq 'active_storage_attachment'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when files param contains a signed_id string" do
|
|
||||||
it "adds that file to the broadcast" do
|
|
||||||
project = create(:project, name: 'first', account_id: current_user.primary_account.id)
|
|
||||||
broadcast = create(:broadcast, :with_stream, skip_create_callback: true, project: project, status: 'created')
|
|
||||||
blob = ActiveStorage::Blob.create_after_upload!(io: StringIO.new("Hello"), filename: "hello.txt", content_type: "text/plain")
|
|
||||||
|
|
||||||
sign_in_to_api(current_user)
|
|
||||||
patch :update, params: { project_id: project, id: broadcast, broadcast: { files: [blob.signed_id] } }
|
|
||||||
|
|
||||||
relationships = JSON.parse(response.body).dig('data', 'relationships')
|
|
||||||
included = JSON.parse(response.body).dig('included')
|
|
||||||
|
|
||||||
expect(relationships.keys).to include('files')
|
|
||||||
expect(included.size).to eq 1
|
|
||||||
expect(included.first.dig("id")).to eq broadcast.files.first.id.to_s
|
|
||||||
expect(included.first.dig("type")).to eq 'active_storage_attachment'
|
|
||||||
expect(included.first.dig("attributes", "filename")).to eq 'hello.txt'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ RSpec.describe Api::DirectUploadsController, type: :controller do
|
|||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
it 'returns data for a direct upload' do
|
it 'returns data for a direct upload' do
|
||||||
post :create, params: { direct_upload: direct_upload_params }
|
post :create, params: { blob: blob_params }
|
||||||
|
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
expect(response_body_data_attributes).to include('id', 'key', 'signed_id', 'url', 'headers')
|
expect(response_body_data_attributes).to include('id', 'key', 'signed_id', 'url', 'headers')
|
||||||
@@ -19,7 +19,7 @@ RSpec.describe Api::DirectUploadsController, type: :controller do
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def direct_upload_params
|
def blob_params
|
||||||
file = file_fixture("video_file.mp4")
|
file = file_fixture("video_file.mp4")
|
||||||
checksum = Digest::MD5.base64digest(StringIO.new(file.read).to_s)
|
checksum = Digest::MD5.base64digest(StringIO.new(file.read).to_s)
|
||||||
|
|
||||||
|
|||||||
@@ -63,55 +63,4 @@ RSpec.describe ContractsController, type: :controller do
|
|||||||
|
|
||||||
it_behaves_like "a contracts controller"
|
it_behaves_like "a contracts controller"
|
||||||
end
|
end
|
||||||
|
|
||||||
context "for medical releases" do
|
|
||||||
let(:native_releasable) { create(:medical_release_with_contract_template, :native) }
|
|
||||||
let(:non_native_releasable) { create(:medical_release_with_contract_template, :non_native) }
|
|
||||||
|
|
||||||
describe "#show when user is account manager" do
|
|
||||||
it_behaves_like "a contracts controller"
|
|
||||||
end
|
|
||||||
|
|
||||||
shared_examples "a medical contracts controller for non-authorized users" do
|
|
||||||
describe "#show" do
|
|
||||||
context "for a native release" do
|
|
||||||
it "responds with not authorized error" do
|
|
||||||
pdf_body = Tempfile.new
|
|
||||||
allow_any_instance_of(Contract).to receive(:to_pdf).and_return(pdf_body)
|
|
||||||
|
|
||||||
expect {
|
|
||||||
get :show, params: { format: :pdf, "#{native_releasable.model_name.singular}_id" => native_releasable }
|
|
||||||
}.to raise_exception(Pundit::NotAuthorizedError)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "for a non-native release" do
|
|
||||||
it "responds with the attached contract" do
|
|
||||||
contract = double(:contract, service_url: "http://example.org/contract.pdf")
|
|
||||||
allow_any_instance_of(non_native_releasable.class).to receive(:contract).and_return(contract)
|
|
||||||
|
|
||||||
expect {
|
|
||||||
get :show, params: { format: :pdf, "#{non_native_releasable.model_name.singular}_id" => non_native_releasable }
|
|
||||||
}.to raise_exception(Pundit::NotAuthorizedError)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#show when user is project manager" do
|
|
||||||
let(:manager_user) { create(:user, :manager) }
|
|
||||||
before do
|
|
||||||
sign_in manager_user
|
|
||||||
end
|
|
||||||
it_behaves_like "a medical contracts controller for non-authorized users"
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#show when user is associate" do
|
|
||||||
let(:associate_user) { create(:user, :associate) }
|
|
||||||
before do
|
|
||||||
sign_in associate_user
|
|
||||||
end
|
|
||||||
it_behaves_like "a medical contracts controller for non-authorized users"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ FactoryBot.define do
|
|||||||
guardian_clause "Is the signer a minor?"
|
guardian_clause "Is the signer a minor?"
|
||||||
fee "$0.00"
|
fee "$0.00"
|
||||||
|
|
||||||
trait :archived do
|
|
||||||
archived_at Time.zone.now
|
|
||||||
end
|
|
||||||
|
|
||||||
factory :appearance_release_contract_template do
|
factory :appearance_release_contract_template do
|
||||||
release_type "appearance"
|
release_type "appearance"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ require 'rails_helper'
|
|||||||
RSpec.feature 'User manages contract templates', type: :feature do
|
RSpec.feature 'User manages contract templates', type: :feature do
|
||||||
let(:current_user) { create(:user, :manager) }
|
let(:current_user) { create(:user, :manager) }
|
||||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
||||||
let(:project2) { create(:project, members: current_user, account: current_user.primary_account, name: 'New project') }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(current_user)
|
sign_in(current_user)
|
||||||
@@ -192,21 +191,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
|||||||
expect(page).not_to have_content('Test template')
|
expect(page).not_to have_content('Test template')
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'archived contract templates from other projects are not shown when importing contract templates' do
|
|
||||||
create(:contract_template, :archived, project: project2, name: 'Archived template')
|
|
||||||
create(:contract_template, project: project2, name: 'Active template')
|
|
||||||
create(:contract_template, project: project)
|
|
||||||
|
|
||||||
visit project_contract_templates_path(project)
|
|
||||||
expect(page).to have_content('Test template')
|
|
||||||
|
|
||||||
click_on import_template_button
|
|
||||||
|
|
||||||
expect(page).not_to have_content('Test template')
|
|
||||||
expect(page).not_to have_content('Archived template')
|
|
||||||
expect(page).to have_content('Active template')
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'When the user is associate' do
|
context 'When the user is associate' do
|
||||||
let(:current_user) { create(:user, :associate) }
|
let(:current_user) { create(:user, :associate) }
|
||||||
|
|
||||||
@@ -214,7 +198,7 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
|||||||
visit project_contract_templates_path(project)
|
visit project_contract_templates_path(project)
|
||||||
|
|
||||||
expect(page).not_to have_content('Create New Release Template')
|
expect(page).not_to have_content('Create New Release Template')
|
||||||
expect(page).not_to have_content(import_template_button)
|
expect(page).not_to have_content('Import Release Template')
|
||||||
expect(page).not_to have_content('Delete')
|
expect(page).not_to have_content('Delete')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -234,14 +218,6 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def import_template_button
|
|
||||||
t 'contract_templates.index.actions.import'
|
|
||||||
end
|
|
||||||
|
|
||||||
def import_selected_templates_button
|
|
||||||
t 'release_template_imports.new.actions.import'
|
|
||||||
end
|
|
||||||
|
|
||||||
def preview_heading
|
def preview_heading
|
||||||
t 'blank_contracts.new.preview_heading'
|
t 'blank_contracts.new.preview_heading'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -65,8 +65,6 @@ feature 'User managing appearance releases' do
|
|||||||
expect(page).to have_content('Guardian email is not an email')
|
expect(page).to have_content('Guardian email is not an email')
|
||||||
|
|
||||||
fill_in guardian_email_field, with: 'valid@email.com'
|
fill_in guardian_email_field, with: 'valid@email.com'
|
||||||
fill_in guardian_address_field, with: '123 Test Lane, New York, NY 10000'
|
|
||||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
|
||||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||||
click_button submit_release_button
|
click_button submit_release_button
|
||||||
|
|
||||||
@@ -470,10 +468,6 @@ feature 'User managing appearance releases' do
|
|||||||
'Guardian email'
|
'Guardian email'
|
||||||
end
|
end
|
||||||
|
|
||||||
def guardian_address_field
|
|
||||||
'Guardian address'
|
|
||||||
end
|
|
||||||
|
|
||||||
def guardian_photo_field
|
def guardian_photo_field
|
||||||
'appearance_release[guardian_photo]'
|
'appearance_release[guardian_photo]'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ feature "User managing broadcasts" do
|
|||||||
scenario "visit show page of broadcast", js: true do
|
scenario "visit show page of broadcast", js: true do
|
||||||
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
|
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
|
||||||
recording = create(:broadcast_recording, broadcast: broadcast)
|
recording = create(:broadcast_recording, broadcast: broadcast)
|
||||||
|
|
||||||
visit project_broadcast_path(project, broadcast)
|
visit project_broadcast_path(project, broadcast)
|
||||||
|
|
||||||
expect(page).to have_content("Live stream is waiting to begin.")
|
expect(page).to have_content("Live stream is waiting to begin.")
|
||||||
expect(page).to have_content("Copy URL")
|
expect(page).to have_content("Copy URL")
|
||||||
|
|
||||||
within "#files" do
|
within "#files" do
|
||||||
expect(page).to have_content("contract.pdf")
|
expect(page).to have_content("contract.pdf")
|
||||||
end
|
end
|
||||||
@@ -54,17 +54,6 @@ feature "User managing broadcasts" do
|
|||||||
expect(page).to have_content(recording.download_file_name)
|
expect(page).to have_content(recording.download_file_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "form will not submit if user clicks Add files without selected files", js: true do
|
|
||||||
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
|
|
||||||
|
|
||||||
visit project_broadcast_path(project, broadcast)
|
|
||||||
|
|
||||||
expect(page).to have_content("Live stream is waiting to begin.")
|
|
||||||
expect(page).to have_content add_file_button
|
|
||||||
|
|
||||||
click_on add_file_button
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "visit multi-view broadcast page", js: true do
|
scenario "visit multi-view broadcast page", js: true do
|
||||||
broadcast_one = create(:broadcast, :with_stream, :with_files, name: "Broadcast 1", project: project)
|
broadcast_one = create(:broadcast, :with_stream, :with_files, name: "Broadcast 1", project: project)
|
||||||
broadcast_two = create(:broadcast, :with_stream, :with_files, name: "Broadcast 2", project: project)
|
broadcast_two = create(:broadcast, :with_stream, :with_files, name: "Broadcast 2", project: project)
|
||||||
@@ -91,13 +80,8 @@ feature "User managing broadcasts" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_file_button
|
|
||||||
'Add File'
|
|
||||||
end
|
|
||||||
|
|
||||||
def broadcast_name_field
|
def broadcast_name_field
|
||||||
"broadcast[name]"
|
"broadcast[name]"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
|
|
||||||
feature "User managing medical releases" do
|
|
||||||
let(:current_user) { create(:user) }
|
|
||||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
|
||||||
|
|
||||||
context "when signed in as account manager" do
|
|
||||||
before do
|
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download All is visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).to have_content download_all_button
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download action in Manage menu is visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).to have_link("Download", exact: true, count: 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is possible" do
|
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
click_link *view_release_pdf_link_for(native_release)
|
|
||||||
expect(content_type).to eq('application/pdf')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the user is manager(project manager)" do
|
|
||||||
let(:current_user) { create(:user, :manager) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download All is not visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).not_to have_content download_all_button
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download action in Manage menu is not visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).to have_link("Download", exact: true, count: 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is not possible" do
|
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
link = medical_release_contracts_path(native_release, format: 'pdf')
|
|
||||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Downloading PDF of non native medical release is not possible" do
|
|
||||||
non_native_release = create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
link = medical_release_contracts_path(non_native_release, format: 'pdf')
|
|
||||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the user is associate" do
|
|
||||||
let(:current_user) { create(:user, :associate) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
sign_in current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download All is not visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).not_to have_content download_all_button
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Download action in Manage menu is not visible" do
|
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
expect(page).to have_link("Download", exact: true, count: 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is not possible" do
|
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
link = medical_release_contracts_path(native_release, format: 'pdf')
|
|
||||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario "Downloading PDF of non native medical release is not possible" do
|
|
||||||
non_native_release = create(:medical_release_with_contract_template, :non_native, project: project)
|
|
||||||
|
|
||||||
visit project_medical_releases_path(project)
|
|
||||||
|
|
||||||
link = medical_release_contracts_path(non_native_release, format: 'pdf')
|
|
||||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def download_all_button
|
|
||||||
'Download All'
|
|
||||||
end
|
|
||||||
|
|
||||||
def download_action
|
|
||||||
'Download'
|
|
||||||
end
|
|
||||||
|
|
||||||
def manage_button
|
|
||||||
t 'medical_releases.medical_release.actions.manage'
|
|
||||||
end
|
|
||||||
|
|
||||||
def view_release_pdf_link_for(release)
|
|
||||||
['Download', href: medical_release_contracts_path(release, format: 'pdf')]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -97,18 +97,6 @@ describe HeadshotCollection do
|
|||||||
expect(hash.keys).not_to include(:collection_uid)
|
expect(hash.keys).not_to include(:collection_uid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there are no releasables" do
|
|
||||||
it "includes a blank hash value for the ids_to_images key" do
|
|
||||||
releases = []
|
|
||||||
collection = HeadshotCollection.new(nil, releases)
|
|
||||||
|
|
||||||
hash = collection.to_hash
|
|
||||||
|
|
||||||
expect(hash.keys).to include(:ids_to_images)
|
|
||||||
expect(hash[:ids_to_images]).to eq(Hash.new)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe MedicalReleasePolicy do
|
describe MedicalReleasePolicy do
|
||||||
let(:user) { create(:user) }
|
let(:user_context) { build(:user_context) }
|
||||||
let(:user_context) { create(:user_context, user: user, account: user.primary_account) }
|
|
||||||
|
|
||||||
subject { described_class }
|
subject { described_class }
|
||||||
|
|
||||||
@@ -10,28 +9,8 @@ describe MedicalReleasePolicy do
|
|||||||
it { is_expected.to permit(:create) }
|
it { is_expected.to permit(:create) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "for an account manager" do
|
permissions :show? do
|
||||||
let(:user) { create(:user, :account_manager) }
|
it { is_expected.to permit(:show) }
|
||||||
|
|
||||||
permissions :show? do
|
|
||||||
it { is_expected.to permit(user_context, :show) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "for an associate" do
|
|
||||||
let(:user) { create(:user, :associate) }
|
|
||||||
|
|
||||||
permissions :show? do
|
|
||||||
it { is_expected.not_to permit(user_context, :show) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "for a manager" do
|
|
||||||
let(:user) { create(:user, :manager) }
|
|
||||||
|
|
||||||
permissions :show? do
|
|
||||||
it { is_expected.not_to permit(user_context, :show) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
permissions :update? do
|
permissions :update? do
|
||||||
|
|||||||
Reference in New Issue
Block a user