summaryrefslogtreecommitdiff
path: root/spec/features/tags/master_deletes_tag_spec.rb
blob: ccfafe6db7d5d3427adad86d079ab7bd91b4f89f (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
require 'spec_helper'

feature 'Master deletes tag', feature: true do
  let(:user) { create(:user) }
  let(:project) { create(:project, namespace: user.namespace) }

  before do
    project.team << [user, :master]
    login_with(user)
    visit namespace_project_tags_path(project.namespace, project)
  end

  context 'from the tags list page', js: true do
    scenario 'deletes the tag' do
      expect(page).to have_content 'v1.1.0'

      delete_first_tag

      expect(page).not_to have_content 'v1.1.0'
    end
  end

  context 'from a specific tag page' do
    scenario 'deletes the tag' do
      click_on 'v1.0.0'
      expect(current_path).to eq(
        namespace_project_tag_path(project.namespace, project, 'v1.0.0'))

      click_on 'Delete tag'

      expect(current_path).to eq(
        namespace_project_tags_path(project.namespace, project))
      expect(page).not_to have_content 'v1.0.0'
    end
  end

  context 'when pre-receive hook fails', js: true do
    before do
      allow_any_instance_of(GitHooksService).to receive(:execute)
        .and_raise(GitHooksService::PreReceiveError, 'Do not delete tags')
    end

    scenario 'shows the error message' do
      delete_first_tag

      expect(page).to have_content('Do not delete tags')
    end
  end

  def delete_first_tag
    page.within('.content') do
      first('.btn-remove').click
    end
  end
end