Upstream sync

This commit is contained in:
Senad Uka
2020-06-11 16:56:29 +02:00
parent dc9ba08e1b
commit 5f5e6c18b5
60 changed files with 1218 additions and 134 deletions

View File

@@ -0,0 +1,91 @@
require "rails_helper"
RSpec.describe MedicalReleasesController, type: :controller do
render_views
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
before do
sign_in user
end
describe "#index" do
it "responds successfully" do
get :index, params: { project_id: project }
expect(response).to be_successful
end
it "renders content" do
release = create(:medical_release, project: project,
person_first_name: "My",
person_last_name: "Release",
person_phone: "5551234567",
person_email: "jane.doe@test.com")
create(:note, notable: release, content: "Some notes here")
get :index, params: { project_id: project }
expect(response.body).to have_content "My Release"
expect(response.body).to have_content "Some notes here"
expect(response.body).to have_content "Manage"
end
context "when there are no medical releases" do
it "renders an empty message" do
get :index, params: { project_id: project }
expect(response.body).to have_content("Medical releases will appear here")
end
end
context "when there are many records" do
it "paginates the table" do
create_list(:medical_release, 20, project: project)
get :index, params: { project_id: project }
expect(response.body).to have_link("2", href: project_medical_releases_path(project, page: 2))
end
end
context "for xhr request" do
it "filters the releases by a query param" do
medical_releases = [
create(:medical_release, person_name: "Adam Sandler", project: project),
create(:medical_release, person_name: "Zoe Perry", project: project),
]
get :index, params: { project_id: project, query: "Zoe" }, xhr: true
expect(response.body).not_to have_content("Adam Sandler")
expect(response.body).to have_content("Zoe Perry")
end
end
end
describe "#destroy" do
let!(:medical_release) { create(:medical_release, project: project) }
it "responds with redirect" do
delete :destroy, params: { project_id: project, id: medical_release }
expect(response).to be_redirect
expect(response).to redirect_to [project, :medical_releases]
end
it "sets the flash" do
delete :destroy, params: { project_id: project, id: medical_release }
expect(flash.alert).not_to be_nil
end
it "destroys the record" do
expect {
delete :destroy, params: { project_id: project, id: medical_release }
}.to change(MedicalRelease, :count).by(-1)
end
end
end

View File

@@ -7,6 +7,15 @@ describe Public::LocationReleasesController do
render_views
describe "#create" do
it "allows photos param" do
contract_template = create(:contract_template, project: project)
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, location_release: location_release_params_with_photos }
expect(response).to be_successful
expect(LocationRelease.last.photos.attached?).to eq true
end
it "logs analytics" do
contract_template = create(:contract_template, project: project)
@@ -67,6 +76,10 @@ describe Public::LocationReleasesController do
attributes_for(:location_release, :native).except(:signature).merge(signature_param).merge(person_address_params)
end
def location_release_params_with_photos
attributes_for(:location_release, :native, :with_photo).except(:signature).merge(signature_param)
end
def person_address_params
{
person_address_street1: "123 Broadway",

View File

@@ -7,6 +7,15 @@ describe Public::MaterialReleasesController do
render_views
describe "#create" do
it "allows photos param" do
contract_template = create(:contract_template, project: project)
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, material_release: material_release_params_with_photos }
expect(response).to be_successful
expect(MaterialRelease.last.photos.attached?).to eq true
end
it "logs analytics" do
contract_template = create(:contract_template, project: project)
@@ -65,6 +74,11 @@ describe Public::MaterialReleasesController do
attributes_for(:material_release, :native).except(:signature).merge(signature_param)
end
def material_release_params_with_photos
attributes_for(:material_release, :native, :with_photo).except(:signature).merge(signature_param)
end
def signature_param
file = file_fixture("signature.png")
data_uri = Base64Image.from_image(file).data_uri

View File

@@ -0,0 +1,71 @@
require "rails_helper"
RSpec.describe Public::MedicalReleasesController, type: :controller do
let(:user) { create(:user) }
let(:project) { create(:project, account: user.primary_account) }
render_views
describe "#create" do
it "logs analytics" do
contract_template = create(:contract_template, project: project)
expect {
post :create, params: { account_id: project.account.to_param, project_id: project, contract_template_id: contract_template, medical_release: medical_release_params }
}.to(
have_enqueued_job(TrackAnalyticsJob)
.with(nil, nil, :track_create_native_release, release_type: "MedicalRelease", account: project.account, user_agent: "Rails Testing", user_ip: "0.0.0.0")
)
end
it "displays validation errors" do
contract_template = create(:contract_template, project: project)
sign_in(user)
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, medical_release: { person_address_city: "Albuquerque" } }
body = CGI.unescape_html(response.body)
expect(body).to match /Person first name can't be blank/
expect(body).to match /Person last name can't be blank/
expect(body).to match />can't be blank</
end
it "responds with success " do
contract_template = create(:contract_template, project: project)
post :create, params: { account_id: user.primary_account.to_param, project_id: project, contract_template_id: contract_template, medical_release: medical_release_params }
expect(response).to be_successful
end
it "runs attach contract to releasable job" do
contract_template = create(:contract_template, project: project)
expect {
post :create, params: { account_id: project.account.to_param, project_id: project, contract_template_id: contract_template, medical_release: medical_release_params }
}.to(
have_enqueued_job(AttachContractToReleasableJob)
.with(MedicalRelease.last)
)
end
end
private
def medical_release_params
attributes_for(:medical_release, :native).except(:signature).merge(signature_param, photos_param)
end
def photos_param
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
photo = Rack::Test::UploadedFile.new(path, "image/png")
{ photos: [photo] }
end
def signature_param
file = file_fixture("signature.png")
data_uri = Base64Image.from_image(file).data_uri
{ signature_base64: data_uri }
end
end

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
require 'zoom_gateway'
RSpec.describe Public::ZoomMeetingsController, type: :controller do
let(:user) { create(:user) }

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
require 'zoom_gateway'
RSpec.describe ZoomMeetingsController, type: :controller do
let(:user) { create(:user) }

View File

@@ -1,82 +0,0 @@
require "rails_helper"
RSpec.describe ZoomNotificationsController, type: :controller do
render_views
let!(:zoom_meeting) { create(:zoom_meeting, api_meeting_id: 'meeting_id') }
let(:started_status) { {event: 'meeting.started', payload: {object: {id: 'meeting_id' }}} }
let(:ended_status) { {event: 'meeting.ended', payload: {object: {id: 'meeting_id' }}} }
let(:wrong_meeting_id) { {payload: {object: {id: 'wrong_id' }}} }
let(:authorization_header) { {'Authorization' => 'xxx-xxx-xxx'} }
let(:wrong_authorization_header) { {'Authorization' => 'yyy-yyy-yyy'} }
before do
allow(ENV).to receive(:[]).with('ZOOM_VERIFICATION_TOKEN').and_return('xxx-xxx-xxx')
end
describe '#create' do
context 'with no authorization key' do
it 'raises 403 response' do
post :create, params: started_status
expect(response).to have_http_status(403)
end
end
context 'with wrong authorization key' do
it 'raises 403 response' do
request.headers.merge!(wrong_authorization_header)
post :create, params: started_status
expect(response).to have_http_status(403)
end
end
context 'authorized' do
before do
request.headers.merge!(authorization_header)
end
context 'with wrong meeting id' do
it 'raises RecordNotFound' do
expect {
post :create, params: wrong_meeting_id
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
context 'with right meeting id' do
it 'responds with 200' do
post :create, params: started_status
expect(response).to have_http_status(200)
end
it 'assigns the zoom meeting' do
post :create, params: started_status
expect(assigns(:zoom_meeting)).to eq(zoom_meeting)
end
it 'updates the zoom_meeting when started status is received in notification' do
post :create, params: started_status
expect(zoom_meeting.reload).to be_started
end
it 'updates the zoom_meeting when ended status is received in notification' do
post :create, params: ended_status
expect(zoom_meeting.reload).to be_ended
end
it 'updates the recording when recording complete notification is received' do
expect {
post :create, params: recording_complete
}.to change { zoom_meeting.recording }
end
end
end
end
end

View File

@@ -0,0 +1,101 @@
require "rails_helper"
RSpec.describe ZoomNotificationsController, type: :controller do
render_views
let!(:zoom_meeting) { create(:zoom_meeting, api_meeting_id: 'meeting_id') }
let(:started_status) { {event: 'meeting.started', payload: {object: {id: 'meeting_id' }}} }
let(:ended_status) { {event: 'meeting.ended', payload: {object: {id: 'meeting_id' }}} }
let(:wrong_meeting_id) { {event: 'meeting.started', payload: {object: {id: 'wrong_id' }}} }
let(:recording_complete) { {event: 'recording.completed', payload: {object: {id: 'meeting_id', recording_files: [Object.new]}}} }
let(:authorization_header) { {'Authorization' => 'xxx-xxx-xxx'} }
let(:wrong_authorization_header) { {'Authorization' => 'yyy-yyy-yyy'} }
before do
allow(ENV).to receive(:[]).with('ZOOM_VERIFICATION_TOKEN').and_return('xxx-xxx-xxx')
end
describe '#create' do
context 'with no authorization key' do
it 'raises 403 response' do
post :create, params: started_status
expect(response).to have_http_status(403)
end
end
context 'with wrong authorization key' do
it 'raises 403 response' do
request.headers.merge!(wrong_authorization_header)
post :create, params: started_status
expect(response).to have_http_status(403)
end
end
context 'authorized' do
before do
request.headers.merge!(authorization_header)
end
context 'user hooks' do
before(:each) { ZoomUser.create api_id: 'zoom_user_id' }
it 'deletes the user from db if user.deleted is passed with existing user id' do
expect {
post :create, params: {event: 'user.deleted', payload: {object: {id: 'zoom_user_id'}}}
}.to change { ZoomUser.count }.by(-1)
end
it 'does not do anything if user.deleted is passed with non-existing user' do
expect {
post :create, params: {event: 'user.deleted', payload: {object: {id: 'wrong-user-id'}}}
}.not_to change { ZoomUser.count }
end
end
context 'meeting hooks' do
context 'with wrong meeting id' do
it 'raises RecordNotFound' do
expect {
post :create, params: wrong_meeting_id
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
context 'with right meeting id' do
it 'responds with 200' do
post :create, params: started_status
expect(response).to have_http_status(200)
end
it 'assigns the zoom meeting' do
post :create, params: started_status
expect(assigns(:zoom_meeting)).to eq(zoom_meeting)
end
it 'updates the zoom_meeting when started status is received in notification' do
post :create, params: started_status
expect(zoom_meeting.reload).to be_started
end
it 'updates the zoom_meeting when ended status is received in notification' do
post :create, params: ended_status
expect(zoom_meeting.reload).to be_ended
end
it 'updates the recording when recording complete notification is received' do
expect(AttachRecordingToZoomMeetingJob).to receive(:perform_later)
post :create, params: recording_complete
end
end
end
end
end
end

View File

@@ -16,6 +16,10 @@ FactoryBot.define do
release_type "talent"
end
factory :medical_release_contract_template do
release_type "medical"
end
factory :material_release_contract_template do
release_type "material"
end

View File

@@ -15,6 +15,13 @@ FactoryBot.define do
end
end
trait :with_photo do
photos do
path = Rails.root.join("spec", "fixtures", "files", "location_photo.png")
[Rack::Test::UploadedFile.new(path, "image/png")]
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")

View File

@@ -15,6 +15,14 @@ FactoryBot.define do
end
end
trait :with_photo do
photos do
path = Rails.root.join("spec", "fixtures", "files", "material_photo.png")
[Rack::Test::UploadedFile.new(path, "image/png")]
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")

View File

@@ -0,0 +1,47 @@
FactoryBot.define do
factory :medical_release do
association :project
person_first_name "Jane"
person_last_name "Doe"
photos [Rack::Test::UploadedFile.new(Rails.root.join("spec", "fixtures", "files", "person_photo.png"), "image/png")]
trait :native do
person_phone "123-555-6789"
signature do
path = Rails.root.join("spec", "fixtures", "files", "signature.png")
Rack::Test::UploadedFile.new(path, "image/png")
end
end
trait :non_native do
contract do
path = Rails.root.join("spec", "fixtures", "files", "contract.pdf")
Rack::Test::UploadedFile.new(path, "application/pdf")
end
end
factory :medical_release_with_contract_template do
after(:build) do |medical_release, _|
medical_release.contract_template = build(:medical_release_contract_template)
end
end
factory :medical_release_with_contract_template_and_photos do
after(:build) do |medical_release, _|
medical_release.contract_template = build(:medical_release_contract_template)
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
medical_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
factory :medical_release_with_photo do
after(:build) do |medical_release, _|
path = Rails.root.join("spec", "fixtures", "files", "person_photo.png")
medical_release.photos.attach Rack::Test::UploadedFile.new(path, "image/png")
end
end
end
end

View File

@@ -1,4 +1,3 @@
require 'zoom_gateway'
FactoryBot.define do
factory :zoom_user do
account_number ZoomGateway.ACCOUNT_NUMBER

View File

@@ -103,4 +103,10 @@ feature "User creates notes" do
it_behaves_like "a notable collection UI"
end
context "for medical releases" do
subject! { create(:medical_release, project: project, notes: []) }
it_behaves_like "a notable collection UI"
end
end

View File

@@ -86,4 +86,10 @@ feature "User creates tags" do
it_behaves_like "a taggable collection UI"
end
context "for medical releases" do
subject! { create(:medical_release, project: project, tags: []) }
it_behaves_like "a taggable collection UI"
end
end

View File

@@ -5,6 +5,13 @@ feature "User managing acquired_media releases" do
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "United States is default country" do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_acquired_media_release_path(project.account, project, contract_template)
expect(country_field_value).to eq "US"
end
scenario "creating a release", js: true do
contract_template = create(:contract_template, project: project)
@@ -205,6 +212,10 @@ feature "User managing acquired_media releases" do
private
def country_field_value
find_field("acquired_media_release[person_address_country]").value
end
def acquired_media_name_field
"acquired_media_release[name]"
end

View File

@@ -5,7 +5,14 @@ feature "User managing location releases" do
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release", js: true do
scenario "United States is default country" do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
expect(country_field_value).to eq "US"
end
scenario "creating a release without photos", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
@@ -21,10 +28,31 @@ feature "User managing location releases" do
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
end
click_button "I have read and agree to the above"
click_button submit_release_button
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
scenario "creating a release with photos", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_location_release_path(project.account, project, contract_template)
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"
fill_in filming_hours_field, with: "04:00 - 22:00"
draw_signature file_fixture("signature.png"), "location_release_signature_base64"
drop_file Rails.root.join(file_fixture("location_photo.png")), type: :dropzone
click_button submit_release_button
expect(page).to have_content("Your release was successfully submitted. Thank you.")
expect(LocationRelease.last.photos.attached?).to eq true
end
end
context "when signed in" do
@@ -195,6 +223,10 @@ feature "User managing location releases" do
private
def country_field_value
find_field("location_release[person_address_country]").value
end
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
@@ -255,6 +287,10 @@ feature "User managing location releases" do
t "helpers.submit.location_release.create"
end
def submit_release_button
t("shared.submit_release_long")
end
def create_release_notice
t "location_releases.create.notice"
end

View File

@@ -5,7 +5,14 @@ feature "User managing material releases" do
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "creating a release", js: true do
scenario "United States is default country" do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
expect(country_field_value).to eq "US"
end
scenario "creating a release without photos", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
@@ -17,10 +24,27 @@ feature "User managing material releases" do
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
end
click_button "I have read and agree to the above"
click_button submit_release_button
expect(page).to have_content("Your release was successfully submitted. Thank you.")
end
scenario "creating a release with photos", js: true do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
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"
drop_file Rails.root.join(file_fixture("material_photo.png")), type: :dropzone
click_button submit_release_button
expect(page).to have_content("Your release was successfully submitted. Thank you.")
expect(MaterialRelease.last.photos.attached?).to eq true
end
end
context "when signed in" do
@@ -180,6 +204,10 @@ feature "User managing material releases" do
private
def country_field_value
find_field("material_release[person_address_country]").value
end
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end
@@ -224,6 +252,10 @@ feature "User managing material releases" do
t "helpers.submit.material_release.create"
end
def submit_release_button
t 'shared.submit_release_long'
end
def create_release_notice
t "material_releases.create.notice"
end

View File

@@ -5,6 +5,13 @@ feature "User managing talent releases" do
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
context "when signed out" do
scenario "United States is default country" do
contract_template = create(:contract_template, project: project)
visit new_account_project_contract_template_talent_release_path(project.account, project, contract_template)
expect(country_field_value).to eq "US"
end
scenario "creating a release for an adult", js: true do
contract_template = create(:contract_template, project: project)
@@ -274,6 +281,10 @@ feature "User managing talent releases" do
private
def country_field_value
find_field("talent_release[person_address_country]").value
end
def photos_heading(photos_count = 1)
t 'contracts.photos.heading', count: photos_count
end

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
require 'zoom_gateway'
RSpec.describe ZoomGateway do
let(:roles_list_response) { {"roles" => [{"name" => 'pro-directme-host', "id" => "host_role_id"}, {"name" => 'basic-directme-host', "id" => "host_role_id"}]} }
@@ -10,7 +9,7 @@ RSpec.describe ZoomGateway do
let(:meeting_hash) { {"id" => "meeting_id", "start_url" => "https://start_url", "join_url" => "https://join_url"} }
let(:gateway) { ZoomGateway.new }
describe "constants" do
describe "pseudo-constants" do
context '.USER_TYPE_NAME' do
it 'defaults to "basic"' do
expect(ZoomGateway.USER_TYPE_NAME).to eq('basic')
@@ -65,6 +64,15 @@ RSpec.describe ZoomGateway do
end
end
context '.ACCOUNT_NUMBER' do
it 'depends on ENV["ZOOM_ACCOUNT_NUMBER"]' do
stub_env_variable('ZOOM_ACCOUNT_NUMBER', 'xxx-yyy-zzz')
expect(ZoomGateway.ACCOUNT_NUMBER).to eq('xxx-yyy-zzz')
end
end
end
describe 'static methods' do
context '.enable_recordings?' do
it 'is truthy when ZOOM_ENABLE_RECORDINGS is set to true' do
stub_env_variable('ZOOM_ENABLE_RECORDINGS', 'true')
@@ -80,10 +88,9 @@ RSpec.describe ZoomGateway do
end
end
context '.ACCOUNT_NUMBER' do
it 'depends on ENV["ZOOM_ACCOUNT_NUMBER"]' do
stub_env_variable('ZOOM_ACCOUNT_NUMBER', 'xxx-yyy-zzz')
expect(ZoomGateway.ACCOUNT_NUMBER).to eq('xxx-yyy-zzz')
context '.host_role_name' do
it 'returns given name with -directme-host prefix' do
expect(ZoomGateway.host_role_name('prefix')).to eq('prefix-directme-host')
end
end
end

View File

@@ -130,7 +130,8 @@ RSpec.describe Account do
User,
Broadcast,
Account,
ZoomMeeting
ZoomMeeting,
MedicalRelease
]
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|

View File

@@ -13,6 +13,7 @@ describe ContractTemplate do
it { is_expected.to have_many(:appearance_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:location_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:material_releases).dependent(:restrict_with_error) }
it { is_expected.to have_many(:medical_releases).dependent(:restrict_with_error) }
end
describe 'validations' do

View File

@@ -0,0 +1,53 @@
require "rails_helper"
RSpec.describe MedicalRelease do
it_behaves_like "a contractable"
it_behaves_like "a notable"
it_behaves_like "a photoable"
it_behaves_like "a releasable"
describe "validations" do
it { is_expected.to validate_presence_of(:person_first_name) }
it { is_expected.to validate_presence_of(:person_last_name) }
context "for #person_email" do
it { is_expected.to allow_value("test@test.com", nil).for(:person_email) }
it { is_expected.not_to allow_values("foo", "test@foo", "N/A").for(:person_email) }
end
context "for native releases" do
it { is_expected.to validate_attachment_of(:signature).on(:native) }
end
context "for non-native releases" do
it { is_expected.to validate_attachment_of(:contract).on(:non_native) }
end
end
describe "attachments" do
it { is_expected.to respond_to(:signature) }
end
describe "#uses_edl?" do
it { is_expected.not_to be_uses_edl }
end
describe "#contract_file_name" do
it "includes project name, signed at date, release type, release number and person name" do
release = create(:medical_release_with_contract_template, id: 100, signed_at: Date.new(2020, 2, 10), person_first_name: "John", person_last_name: "Doe")
expect(release.contract_file_name).to eq("my-video-project_medical_2020.02.10_1_doe-john")
end
context "when signed at is nil" do
it "uses the created at date" do
release = create(:medical_release_with_contract_template,
signed_at: nil,
created_at: DateTime.new(2020, 2, 10, 12, 0, 0),
person_first_name: "John", person_last_name: "Doe")
expect(release.contract_file_name).to eq("my-video-project_medical_2020.02.10_1_doe-john")
end
end
end
end

View File

@@ -1,5 +1,4 @@
require "rails_helper"
require "zoom_gateway"
RSpec.describe Project, type: :model do
describe "associations" do
@@ -10,6 +9,7 @@ RSpec.describe Project, type: :model do
it { is_expected.to have_many(:material_releases).dependent(:destroy) }
it { is_expected.to have_many(:music_releases).dependent(:destroy) }
it { is_expected.to have_many(:talent_releases).dependent(:destroy) }
it { is_expected.to have_many(:medical_releases).dependent(:destroy) }
it { is_expected.to have_many(:videos).dependent(:destroy) }
it { is_expected.to have_many(:contract_templates).dependent(:destroy) }
it { is_expected.to have_many(:project_memberships).dependent(:destroy) }

View File

@@ -1,5 +1,4 @@
require 'rails_helper'
require 'zoom_gateway'
RSpec.describe ZoomMeeting, type: :model do
let(:zoom_meeting) { build(:zoom_meeting, api_meeting_id: nil) }

View File

@@ -1,4 +1,3 @@
require 'zoom_gateway'
require 'rails_helper'
RSpec.describe ZoomUser, type: :model do

View File

@@ -0,0 +1,37 @@
require "rails_helper"
describe MedicalReleasePolicy do
let(:user_context) { build(:user_context) }
subject { described_class }
permissions :create? do
it { is_expected.to permit(:create) }
end
permissions :show? do
it { is_expected.to permit(:show) }
end
permissions :update? do
context "for a native release" do
it { is_expected.not_to permit(user_context, build(:medical_release, :native)) }
end
context "for a non-native release" do
it { is_expected.to permit(user_context, build(:medical_release, :non_native)) }
end
end
permissions :destroy? do
it { is_expected.to permit(:destroy) }
end
permissions :edit_photos? do
it { is_expected.to permit(:edit_photos) }
end
permissions :update_photos? do
it { is_expected.to permit(:update_photos) }
end
end