PageRenderTime 44ms CodeModel.GetById 23ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/features/tags/developer_creates_tag_spec.rb

https://gitlab.com/tnir/gitlab-ce
Ruby | 97 lines | 75 code | 21 blank | 1 comment | 0 complexity | 9b9f6ec78d12aa7714a32f5fe498444a MD5 | raw file
 1# frozen_string_literal: true
 2
 3require 'spec_helper'
 4
 5describe 'Developer creates tag' do
 6  let(:user) { create(:user) }
 7  let(:group) { create(:group) }
 8  let(:project) { create(:project, :repository, namespace: group) }
 9
10  before do
11    project.add_developer(user)
12    sign_in(user)
13  end
14
15  context 'from tag list' do
16    before do
17      visit project_tags_path(project)
18    end
19
20    it 'with an invalid name displays an error' do
21      create_tag_in_form(tag: 'v 1.0', ref: 'master')
22
23      expect(page).to have_content 'Tag name invalid'
24    end
25
26    it 'with an invalid reference displays an error' do
27      create_tag_in_form(tag: 'v2.0', ref: 'foo')
28
29      expect(page).to have_content 'Target foo is invalid'
30    end
31
32    it 'that already exists displays an error' do
33      create_tag_in_form(tag: 'v1.1.0', ref: 'master')
34
35      expect(page).to have_content 'Tag v1.1.0 already exists'
36    end
37
38    it 'with multiline message displays the message in a <pre> block' do
39      create_tag_in_form(tag: 'v3.0', ref: 'master', message: "Awesome tag message\n\n- hello\n- world")
40
41      expect(current_path).to eq(
42        project_tag_path(project, 'v3.0'))
43      expect(page).to have_content 'v3.0'
44      page.within 'pre.wrap' do
45        expect(page).to have_content "Awesome tag message - hello - world"
46      end
47    end
48
49    it 'with multiline release notes parses the release note as Markdown' do
50      create_tag_in_form(tag: 'v4.0', ref: 'master', desc: "Awesome release notes\n\n- hello\n- world")
51
52      expect(current_path).to eq(
53        project_tag_path(project, 'v4.0'))
54      expect(page).to have_content 'v4.0'
55      page.within '.description' do
56        expect(page).to have_content 'Awesome release notes'
57        expect(page).to have_selector('ul li', count: 2)
58      end
59    end
60
61    it 'opens dropdown for ref', :js do
62      click_link 'New tag'
63      ref_row = find('.form-group:nth-of-type(2) .col-sm-10')
64      page.within ref_row do
65        ref_input = find('[name="ref"]', visible: false)
66        expect(ref_input.value).to eq 'master'
67        expect(find('.dropdown-toggle-text')).to have_content 'master'
68
69        find('.js-branch-select').click
70
71        expect(find('.dropdown-menu')).to have_content 'empty-branch'
72      end
73    end
74  end
75
76  context 'from new tag page' do
77    before do
78      visit new_project_tag_path(project)
79    end
80
81    it 'description has emoji autocomplete', :js do
82      find('#release_description').native.send_keys('')
83      fill_in 'release_description', with: ':'
84
85      expect(page).to have_selector('.atwho-view')
86    end
87  end
88
89  def create_tag_in_form(tag:, ref:, message: nil, desc: nil)
90    click_link 'New tag'
91    fill_in 'tag_name', with: tag
92    find('#ref', visible: false).set(ref)
93    fill_in 'message', with: message unless message.nil?
94    fill_in 'release_description', with: desc unless desc.nil?
95    click_button 'Create tag'
96  end
97end