Welcome to mirror list, hosted at ThFree Co, Russian Federation.

maintainer_deletes_protected_tag_spec.rb « tags « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0bf9645c2fbd7a04ed87d5bcab351cf64a466522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Maintainer deletes protected tag', :js do
  let(:user) { create(:user) }
  let(:group) { create(:group) }
  let(:project) { create(:project, :repository, namespace: group) }
  let(:tag_name) { 'v1.1.1' }

  before do
    project.add_maintainer(user)
    sign_in(user)
    create(:protected_tag, project: project, name: tag_name)
    visit project_tags_path(project)
  end

  context 'from the tags list page' do
    it 'deletes the tag' do
      expect(page).to have_content "#{tag_name} protected"

      page.find('.content .flex-row', text: tag_name).find('.js-delete-tag-button').click
      assert_modal_content(tag_name)
      confirm_delete_tag(tag_name)

      expect(page).not_to have_content tag_name
    end
  end

  context 'from a specific tag page' do
    before do
      click_on tag_name
    end

    it 'deletes the tag' do
      expect(page).to have_current_path(project_tag_path(project, tag_name), ignore_query: true)

      page.find('.js-delete-tag-button').click
      assert_modal_content(tag_name)
      confirm_delete_tag(tag_name)

      expect(page).to have_current_path(project_tags_path(project), ignore_query: true)
      expect(page).not_to have_content tag_name
    end
  end

  def assert_modal_content(tag_name)
    within '.modal' do
      expect(page).to have_content("Please type the following to confirm: #{tag_name}")
      expect(page).to have_field('delete_tag_input')
      expect(page).to have_button('Yes, delete protected tag', disabled: true)
    end
  end

  def confirm_delete_tag(tag_name)
    within '.modal' do
      fill_in('delete_tag_input', with: tag_name)
      click_button('Yes, delete protected tag')
      wait_for_requests
    end
  end
end