debian-mirror-gitlab/spec/features/projects/files/user_uploads_files_spec.rb

62 lines
1.5 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2018-10-15 14:42:47 +05:30
describe 'Projects > Files > User uploads files' do
2017-09-10 17:25:29 +05:30
include DropzoneHelper
2018-10-15 14:42:47 +05:30
let(:user) { create(:user) }
let(:project) { create(:project, :repository, name: 'Shop', creator: user) }
2017-09-10 17:25:29 +05:30
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
before do
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-09-10 17:25:29 +05:30
sign_in(user)
end
2020-04-22 19:07:51 +05:30
context 'when a user has write access' do
2017-09-10 17:25:29 +05:30
before do
2020-04-22 19:07:51 +05:30
visit(project_tree_path(project))
2017-09-10 17:25:29 +05:30
end
2020-04-22 19:07:51 +05:30
include_examples 'it uploads and commit a new text file'
2018-03-17 18:26:18 +05:30
2020-04-22 19:07:51 +05:30
include_examples 'it uploads and commit a new image file'
2018-10-15 14:42:47 +05:30
2020-04-22 19:07:51 +05:30
it 'uploads a file to a sub-directory', :js do
click_link 'files'
2018-10-15 14:42:47 +05:30
2020-04-22 19:07:51 +05:30
page.within('.repo-breadcrumb') do
expect(page).to have_content('files')
2018-10-15 14:42:47 +05:30
end
2017-09-10 17:25:29 +05:30
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')
2020-04-22 19:07:51 +05:30
page.within('.repo-breadcrumb') do
expect(page).to have_content('files')
expect(page).to have_content('doc_sample.txt')
end
end
end
2018-03-17 18:26:18 +05:30
2020-04-22 19:07:51 +05:30
context 'when a user does not have write access' do
before do
project2.add_reporter(user)
2017-09-10 17:25:29 +05:30
2020-04-22 19:07:51 +05:30
visit(project_tree_path(project2))
2017-09-10 17:25:29 +05:30
end
2020-04-22 19:07:51 +05:30
include_examples 'it uploads and commit a new file to a forked project'
2017-09-10 17:25:29 +05:30
end
end