2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'User wants to create a file' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
background do
|
|
|
|
project.team << [user, :master]
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in user
|
|
|
|
visit project_new_blob_path(project, project.default_branch)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def submit_new_file(options)
|
|
|
|
file_name = find('#file_name')
|
|
|
|
file_name.set options[:file_name] || 'README.md'
|
|
|
|
|
|
|
|
file_content = find('#file-content')
|
|
|
|
file_content.set options[:file_content] || 'Some content'
|
|
|
|
|
|
|
|
click_button 'Commit changes'
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'file name contains Chinese characters' do
|
|
|
|
submit_new_file(file_name: '测试.md')
|
|
|
|
expect(page).to have_content 'The file has been successfully created.'
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'directory name contains Chinese characters' do
|
|
|
|
submit_new_file(file_name: '中文/测试.md')
|
|
|
|
expect(page).to have_content 'The file has been successfully created'
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'file name contains directory traversal' do
|
|
|
|
submit_new_file(file_name: '../README.md')
|
|
|
|
expect(page).to have_content 'Path cannot include directory traversal'
|
|
|
|
end
|
|
|
|
end
|