diff options
author | Fabian Schneider <fabbbbbi+git@googlemail.com> | 2018-03-31 13:10:16 +0200 |
---|---|---|
committer | Fabian Schneider <fabbbbbi+git@googlemail.com> | 2018-04-08 11:00:25 +0200 |
commit | d2482f15e19695e2f89284d9a0219c6b4b4f401c (patch) | |
tree | 663d14b98a2fc9946c5d75ffc476e4850e5bdf32 /spec/features/projects/files | |
parent | dd552d06f6e39d5e6138a33bd7c1bffb2d3dbb1d (diff) | |
download | gitlab-ce-d2482f15e19695e2f89284d9a0219c6b4b4f401c.tar.gz |
Fix template selector menu visibility
Diffstat (limited to 'spec/features/projects/files')
-rw-r--r-- | spec/features/projects/files/template_selector_menu_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/features/projects/files/template_selector_menu_spec.rb b/spec/features/projects/files/template_selector_menu_spec.rb new file mode 100644 index 00000000000..b549a69ddf3 --- /dev/null +++ b/spec/features/projects/files/template_selector_menu_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +feature 'Template selector menu', :js do + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in user + end + + context 'editing a non-matching file' do + before do + create_and_edit_file('README.md') + end + + scenario 'is not displayed' do + check_template_selector_menu_display(false) + end + + context 'user toggles preview' do + before do + click_link 'Preview' + end + + scenario 'template selector menu is not displayed' do + check_template_selector_menu_display(false) + click_link 'Write' + check_template_selector_menu_display(false) + end + end + end + + context 'editing a matching file' do + before do + visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) + end + + scenario 'is displayed' do + check_template_selector_menu_display(true) + end + + context 'user toggles preview' do + before do + click_link 'Preview' + end + + scenario 'template selector menu is hidden and shown correctly' do + check_template_selector_menu_display(false) + click_link 'Write' + check_template_selector_menu_display(true) + end + end + end +end + +def check_template_selector_menu_display(is_visible) + count = is_visible ? 1 : 0 + expect(page).to have_css('.template-selectors-menu', count: count) +end + +def create_and_edit_file(file_name) + visit project_new_blob_path(project, 'master', file_name: file_name) + click_button "Commit changes" + visit project_edit_blob_path(project, File.join(project.default_branch, file_name)) +end |