add optional shared link to templates
This commit is contained in:
committed by
Pete Matsyburka
parent
c91b4a765b
commit
e77b5fa2c9
Vendored
BIN
Binary file not shown.
@@ -83,13 +83,15 @@ describe 'Templates API' do
|
||||
end
|
||||
|
||||
describe 'PUT /api/templates' do
|
||||
it 'update a template' do
|
||||
template = create(:template, account:,
|
||||
author:,
|
||||
folder:,
|
||||
external_id: SecureRandom.base58(10),
|
||||
preferences: template_preferences)
|
||||
let(:template) do
|
||||
create(:template, account:,
|
||||
author:,
|
||||
folder:,
|
||||
external_id: SecureRandom.base58(10),
|
||||
preferences: template_preferences)
|
||||
end
|
||||
|
||||
it 'updates a template' do
|
||||
put "/api/templates/#{template.id}", headers: { 'x-auth-token': author.access_token.token }, params: {
|
||||
name: 'Updated Template Name',
|
||||
external_id: '123456'
|
||||
@@ -106,6 +108,24 @@ describe 'Templates API' do
|
||||
updated_at: template.updated_at
|
||||
}.to_json))
|
||||
end
|
||||
|
||||
it "enables the template's shared link" do
|
||||
expect do
|
||||
put "/api/templates/#{template.id}", headers: { 'x-auth-token': author.access_token.token }, params: {
|
||||
shared_link: true
|
||||
}.to_json
|
||||
end.to change { template.reload.shared_link }.from(false).to(true)
|
||||
end
|
||||
|
||||
it "disables the template's shared link" do
|
||||
template.update(shared_link: true)
|
||||
|
||||
expect do
|
||||
put "/api/templates/#{template.id}", headers: { 'x-auth-token': author.access_token.token }, params: {
|
||||
shared_link: false
|
||||
}.to_json
|
||||
end.to change { template.reload.shared_link }.from(true).to(false)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /api/templates/:id' do
|
||||
@@ -206,6 +226,7 @@ describe 'Templates API' do
|
||||
name: 'sample-document'
|
||||
}
|
||||
],
|
||||
shared_link: template.shared_link,
|
||||
author_id: author.id,
|
||||
archived_at: nil,
|
||||
created_at: template.created_at,
|
||||
|
||||
@@ -5,7 +5,9 @@ RSpec.describe 'Signing Form' do
|
||||
let(:author) { create(:user, account:) }
|
||||
|
||||
context 'when the template form link is opened' do
|
||||
let(:template) { create(:template, account:, author:, except_field_types: %w[phone payment stamp]) }
|
||||
let(:template) do
|
||||
create(:template, shared_link: true, account:, author:, except_field_types: %w[phone payment stamp])
|
||||
end
|
||||
|
||||
before do
|
||||
visit start_form_path(slug: template.slug)
|
||||
@@ -811,7 +813,9 @@ RSpec.describe 'Signing Form' do
|
||||
end
|
||||
|
||||
context 'when the template requires multiple submitters' do
|
||||
let(:template) { create(:template, submitter_count: 2, account:, author:, only_field_types: %w[text]) }
|
||||
let(:template) do
|
||||
create(:template, shared_link: true, submitter_count: 2, account:, author:, only_field_types: %w[text])
|
||||
end
|
||||
|
||||
context 'when default signer details are not defined' do
|
||||
it 'shows an explanation error message if a logged-in user associated with the template account opens the link' do
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'Template Share Link' do
|
||||
let!(:account) { create(:account) }
|
||||
let!(:author) { create(:user, account:) }
|
||||
let!(:template) { create(:template, account:, author:) }
|
||||
|
||||
before do
|
||||
sign_in(author)
|
||||
end
|
||||
|
||||
context 'when the template is not shareable' do
|
||||
before do
|
||||
visit template_path(template)
|
||||
end
|
||||
|
||||
it 'makes the template shareable' do
|
||||
click_on 'Link'
|
||||
|
||||
expect do
|
||||
within '#modal' do
|
||||
check 'template_shared_link'
|
||||
end
|
||||
end.to change { template.reload.shared_link }.from(false).to(true)
|
||||
end
|
||||
|
||||
it 'makes the template shareable when copying the shareable link' do
|
||||
click_on 'Link'
|
||||
|
||||
expect do
|
||||
within '#modal' do
|
||||
find('clipboard-copy').click
|
||||
end
|
||||
end.to change { template.reload.shared_link }.from(false).to(true)
|
||||
end
|
||||
|
||||
it 'copies the shareable link without changing its status' do
|
||||
template.update(shared_link: true)
|
||||
|
||||
click_on 'Link'
|
||||
|
||||
expect do
|
||||
within '#modal' do
|
||||
find('clipboard-copy').click
|
||||
end
|
||||
end.not_to(change { template.reload.shared_link })
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the template is already shareable' do
|
||||
before do
|
||||
template.update(shared_link: true)
|
||||
visit template_path(template)
|
||||
end
|
||||
|
||||
it 'makes the template unshareable' do
|
||||
click_on 'Link'
|
||||
|
||||
expect do
|
||||
within '#modal' do
|
||||
uncheck 'template_shared_link'
|
||||
end
|
||||
end.to change { template.reload.shared_link }.from(true).to(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user