2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-12 08:45:42 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
describe 'Projects > Files > User uploads files' do
|
2017-07-12 08:45:42 -04:00
|
|
|
include DropzoneHelper
|
|
|
|
|
2018-04-16 20:19:08 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :repository, name: 'Shop', creator: user) }
|
2017-07-12 08:45:42 -04:00
|
|
|
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-07-12 08:45:42 -04:00
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2020-03-23 17:09:46 -04:00
|
|
|
context 'when a user has write access' do
|
2017-07-12 08:45:42 -04:00
|
|
|
before do
|
2020-03-23 17:09:46 -04:00
|
|
|
visit(project_tree_path(project))
|
2017-07-12 08:45:42 -04:00
|
|
|
end
|
|
|
|
|
2020-03-23 17:09:46 -04:00
|
|
|
include_examples 'it uploads and commit a new text file'
|
2017-07-12 08:45:42 -04:00
|
|
|
|
2020-03-23 17:09:46 -04:00
|
|
|
include_examples 'it uploads and commit a new image file'
|
2020-04-02 08:08:18 -04:00
|
|
|
|
|
|
|
it 'uploads a file to a sub-directory', :js do
|
|
|
|
click_link 'files'
|
|
|
|
|
|
|
|
page.within('.repo-breadcrumb') do
|
|
|
|
expect(page).to have_content('files')
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.add-to-tree').click
|
|
|
|
click_link('Upload file')
|
|
|
|
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
|
|
|
|
|
|
|
|
page.within('#modal-upload-blob') do
|
|
|
|
fill_in(:commit_message, with: 'New commit message')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button('Upload file')
|
|
|
|
|
|
|
|
expect(page).to have_content('New commit message')
|
|
|
|
|
|
|
|
page.within('.repo-breadcrumb') do
|
|
|
|
expect(page).to have_content('files')
|
|
|
|
expect(page).to have_content('doc_sample.txt')
|
|
|
|
end
|
|
|
|
end
|
2017-07-12 08:45:42 -04:00
|
|
|
end
|
|
|
|
|
2020-03-23 17:09:46 -04:00
|
|
|
context 'when a user does not have write access' do
|
2017-07-12 08:45:42 -04:00
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project2.add_reporter(user)
|
2017-07-12 08:45:42 -04:00
|
|
|
|
2020-03-23 17:09:46 -04:00
|
|
|
visit(project_tree_path(project2))
|
2017-07-12 08:45:42 -04:00
|
|
|
end
|
2020-03-23 17:09:46 -04:00
|
|
|
|
|
|
|
include_examples 'it uploads and commit a new file to a forked project'
|
2017-07-12 08:45:42 -04:00
|
|
|
end
|
|
|
|
end
|