|
|
@ -48,40 +48,53 @@ describe 'Upload attachment to documents', js: true do |
|
|
|
login_as(user) |
|
|
|
login_as(user) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it 'can upload an image' do |
|
|
|
shared_examples 'can upload an image' do |
|
|
|
visit project_documents_path(project) |
|
|
|
it 'can upload an image' do |
|
|
|
|
|
|
|
visit project_documents_path(project) |
|
|
|
|
|
|
|
|
|
|
|
within '.toolbar-items' do |
|
|
|
within '.toolbar-items' do |
|
|
|
click_on 'Document' |
|
|
|
click_on 'Document' |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
select(category.name, from: 'Category') |
|
|
|
|
|
|
|
fill_in "Title", with: 'New documentation' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adding an image |
|
|
|
|
|
|
|
editor.drag_attachment image_fixture, 'Image uploaded on creation' |
|
|
|
|
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png') |
|
|
|
|
|
|
|
|
|
|
|
select(category.name, from: 'Category') |
|
|
|
click_on 'Create' |
|
|
|
fill_in "Title", with: 'New documentation' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# adding an image |
|
|
|
expect(page).to have_selector('#content img', count: 1) |
|
|
|
editor.drag_attachment image_fixture, 'Image uploaded on creation' |
|
|
|
expect(page).to have_content('Image uploaded on creation') |
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png') |
|
|
|
click_on 'New documentation' |
|
|
|
|
|
|
|
|
|
|
|
click_on 'Create' |
|
|
|
within '.toolbar-items' do |
|
|
|
|
|
|
|
click_on 'Edit' |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('#content img', count: 1) |
|
|
|
editor.drag_attachment image_fixture, 'Image uploaded the second time' |
|
|
|
expect(page).to have_content('Image uploaded on creation') |
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png', count: 2) |
|
|
|
|
|
|
|
|
|
|
|
click_on 'New documentation' |
|
|
|
click_on 'Save' |
|
|
|
|
|
|
|
|
|
|
|
within '.toolbar-items' do |
|
|
|
expect(page).to have_selector('#content img', count: 2) |
|
|
|
click_on 'Edit' |
|
|
|
expect(page).to have_content('Image uploaded on creation') |
|
|
|
|
|
|
|
expect(page).to have_content('Image uploaded the second time') |
|
|
|
|
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png', count: 2) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
editor.drag_attachment image_fixture, 'Image uploaded the second time' |
|
|
|
context 'with direct uploads (Regression #34285)', with_direct_uploads: true do |
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png', count: 2) |
|
|
|
before do |
|
|
|
|
|
|
|
allow_any_instance_of(Attachment).to receive(:diskfile).and_return Struct.new(:path).new(image_fixture.to_s) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
click_on 'Save' |
|
|
|
it_behaves_like 'can upload an image' |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector('#content img', count: 2) |
|
|
|
context 'internal upload', with_direct_uploads: false do |
|
|
|
expect(page).to have_content('Image uploaded on creation') |
|
|
|
it_behaves_like 'can upload an image' |
|
|
|
expect(page).to have_content('Image uploaded the second time') |
|
|
|
|
|
|
|
expect(page).to have_selector('attachment-list-item', text: 'image.png', count: 2) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|