2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:project) { create(:project_empty_repo) }
|
2018-11-18 11:00:15 +05:30
|
|
|
let(:project_maintainer) { project.owner }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
sign_in(project_maintainer)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
it 'project maintainer creates a license file from a template' do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_path(project)
|
2019-12-26 22:10:19 +05:30
|
|
|
click_on 'Add LICENSE'
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('New file')
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
expect(current_path).to eq(
|
2017-09-10 17:25:29 +05:30
|
|
|
project_new_blob_path(project, 'master'))
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(find('#file_name').value).to eq('LICENSE')
|
|
|
|
expect(page).to have_selector('.license-selector')
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
select_template('MIT License')
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2016-09-29 09:46:39 +05:30
|
|
|
file_content = first('.file-editor')
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(file_content).to have_content('MIT License')
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(file_content).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
fill_in :commit_message, with: 'Add a LICENSE file', visible: true
|
2017-08-17 22:00:37 +05:30
|
|
|
click_button 'Commit changes'
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
expect(current_path).to eq(
|
2017-09-10 17:25:29 +05:30
|
|
|
project_blob_path(project, 'master/LICENSE'))
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('MIT License')
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2016-06-22 15:30:34 +05:30
|
|
|
|
|
|
|
def select_template(template)
|
|
|
|
page.within('.js-license-selector-wrap') do
|
2019-12-21 20:55:43 +05:30
|
|
|
click_button 'Apply a template'
|
2016-06-22 15:30:34 +05:30
|
|
|
click_link template
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2016-06-22 15:30:34 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|