generate unique uuids for cloned templates
This commit is contained in:
committed by
Pete Matsyburka
parent
8898dcc054
commit
baaf1f510f
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :template_folder do
|
||||
account
|
||||
|
||||
author factory: %i[user]
|
||||
name { Faker::Book.title }
|
||||
|
||||
trait :with_templates do
|
||||
after(:create) do |template_folder|
|
||||
create_list(:template, 2, folder: template_folder, account: template_folder.account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -74,5 +74,70 @@ RSpec.describe 'Template' do
|
||||
expect(page).to have_current_path(edit_template_path(template), ignore_query: true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'clone a template and move it to a new folder' do
|
||||
click_link 'Clone'
|
||||
|
||||
within '#modal' do
|
||||
fill_in 'template[name]', with: 'New Template Name'
|
||||
click_link 'Change Folder'
|
||||
fill_in 'folder_name', with: 'New Folder Name'
|
||||
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.to change { Template.active.count }.by(1).and change { TemplateFolder.active.count }.by(1)
|
||||
|
||||
template = Template.last
|
||||
|
||||
expect(template.name).to eq('New Template Name')
|
||||
expect(template.folder.name).to eq('New Folder Name')
|
||||
expect(page).to have_current_path(edit_template_path(template), ignore_query: true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'clones a template and moves it to an existing folder' do
|
||||
template_folder = create(:template_folder, :with_templates, account:, author: user)
|
||||
|
||||
click_link 'Clone'
|
||||
|
||||
within '#modal' do
|
||||
template_folder.reload
|
||||
fill_in 'template[name]', with: 'New Template Name'
|
||||
click_link 'Change Folder'
|
||||
end
|
||||
|
||||
within '.autocomplete' do
|
||||
find('div', text: template_folder.name).click
|
||||
end
|
||||
|
||||
within '#modal' do
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.not_to(change { TemplateFolder.active.count })
|
||||
end
|
||||
|
||||
template = Template.last
|
||||
expect(template.name).to eq('New Template Name')
|
||||
expect(template.folder.name).to eq(template_folder.name)
|
||||
expect(page).to have_current_path(edit_template_path(template), ignore_query: true)
|
||||
end
|
||||
|
||||
it 'moves a template' do
|
||||
find('[data-tip="Move"]', visible: false).hover
|
||||
find('[data-tip="Move"]').click
|
||||
|
||||
within '#modal' do
|
||||
fill_in 'name', with: 'New Folder Name'
|
||||
|
||||
expect do
|
||||
click_button 'Move'
|
||||
end.to change { TemplateFolder.active.count }.by(1)
|
||||
|
||||
template_folder = TemplateFolder.last
|
||||
|
||||
expect(template_folder.name).to eq('New Folder Name')
|
||||
expect(page).to have_current_path(template_path(template), ignore_query: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user