mirror of https://github.com/docusealco/docuseal
				
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							67 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
	
	
							67 lines
						
					
					
						
							1.5 KiB
						
					
					
				| # 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
 |