diff options
Diffstat (limited to 'spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb')
-rw-r--r-- | spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb index 55b9f38d8e7..b0ccb5fca94 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -5,10 +5,14 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file', :js do include Spec::Support::Helpers::Features::EditorLiteSpecHelpers + let(:params) { {} } + let(:filename) { '.gitlab-ci.yml' } + + let_it_be(:project) { create(:project, :repository) } + before do - project = create(:project, :repository) sign_in project.owner - visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') + visit project_new_blob_path(project, 'master', file_name: filename, **params) end it 'user can pick a template from the dropdown' do @@ -29,4 +33,38 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file', :js expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project') expect(editor_get_value).to have_content('jekyll build -d test') end + + context 'when template param is provided' do + let(:params) { { template: 'Jekyll' } } + + it 'uses the given template' do + wait_for_requests + + expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template') + expect(editor_get_value).to have_content('This file is a template, and might need editing before it works on your project') + expect(editor_get_value).to have_content('jekyll build -d test') + end + end + + context 'when provided template param is not a valid template name' do + let(:params) { { template: 'non-existing-template' } } + + it 'leaves the editor empty' do + wait_for_requests + + expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Apply a template') + expect(editor_get_value).to have_content('') + end + end + + context 'when template is not available for the given file' do + let(:filename) { 'Dockerfile' } + let(:params) { { template: 'Jekyll' } } + + it 'leaves the editor empty' do + wait_for_requests + + expect(editor_get_value).to have_content('') + end + end end |