2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-11 13:49:25 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do
|
2020-10-14 12:08:58 +00:00
|
|
|
include WebIdeSpecHelpers
|
|
|
|
|
2017-12-19 18:36:53 +00:00
|
|
|
let(:project) { create(:project_empty_repo) }
|
2018-07-11 14:36:08 +00:00
|
|
|
let(:project_maintainer) { project.owner }
|
2017-12-19 18:36:53 +00:00
|
|
|
|
2018-04-06 12:40:33 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
sign_in(project_maintainer)
|
2016-04-11 13:49:25 +00:00
|
|
|
end
|
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
it 'allows project maintainer creates a license file from a template in Web IDE' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_path(project)
|
2019-11-18 18:06:53 +00:00
|
|
|
click_on 'Add LICENSE'
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
expect(current_path).to eq("/-/ide/project/#{project.full_path}/edit/master/-/LICENSE")
|
|
|
|
|
|
|
|
expect(page).to have_selector('.qa-file-templates-bar')
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2016-06-15 07:12:42 +00:00
|
|
|
select_template('MIT License')
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
expect(ide_editor_value).to have_content('MIT License')
|
|
|
|
expect(ide_editor_value).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
|
|
|
|
|
|
|
|
ide_commit
|
|
|
|
|
2020-11-06 12:09:17 +00:00
|
|
|
expect(current_path).to eq("/-/ide/project/#{project.full_path}/tree/master/-/LICENSE/")
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
expect(page).to have_content('All changes are committed')
|
2016-04-11 13:49:25 +00:00
|
|
|
|
2020-10-14 12:08:58 +00:00
|
|
|
license_file = project.repository.blob_at('master', 'LICENSE').data
|
|
|
|
expect(license_file).to have_content('MIT License')
|
|
|
|
expect(license_file).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
|
2016-04-11 13:49:25 +00:00
|
|
|
end
|
2016-06-15 07:12:42 +00:00
|
|
|
|
|
|
|
def select_template(template)
|
2020-10-14 12:08:58 +00:00
|
|
|
click_button 'Choose a template...'
|
|
|
|
click_button template
|
|
|
|
wait_for_requests
|
2016-06-15 07:12:42 +00:00
|
|
|
end
|
2016-04-11 13:49:25 +00:00
|
|
|
end
|