summaryrefslogtreecommitdiff
path: root/spec/features/tags/master_views_tags_spec.rb
blob: 922ac15a2ebcd2974a23de7e68bac3484f83ec39 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require 'spec_helper'

feature 'Master views tags', feature: true do
  let(:user) { create(:user) }

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

  context 'when project has no tags' do
    let(:project) { create(:project_empty_repo) }
    before do
      visit namespace_project_path(project.namespace, project)
      click_on 'README'
      fill_in :commit_message, with: 'Add a README file', visible: true
      # Remove pre-receive hook so we can push without auth
      FileUtils.rm_f(File.join(project.repository.path, 'hooks', 'pre-receive'))
      click_button 'Commit changes'
      visit namespace_project_tags_path(project.namespace, project)
    end

    scenario 'displays a specific message' do
      expect(page).to have_content 'Repository has no tags yet.'
    end
  end

  context 'when project has tags' do
    let(:project) { create(:project, namespace: user.namespace) }
    let(:repository) { project.repository }

    before do
      visit namespace_project_tags_path(project.namespace, project)
    end

    scenario 'avoids a N+1 query in branches index' do
      control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_tags_path(project.namespace, project) }.count

      %w(one two three four five).each { |tag| repository.add_tag(user, tag, 'master', 'foo') }

      expect { visit namespace_project_tags_path(project.namespace, project) }.not_to exceed_query_limit(control_count)
    end

    scenario 'views the tags list page' do
      expect(page).to have_content 'v1.0.0'
    end

    scenario 'views a specific tag page' do
      click_on 'v1.0.0'

      expect(current_path).to eq(
        namespace_project_tag_path(project.namespace, project, 'v1.0.0'))
      expect(page).to have_content 'v1.0.0'
      expect(page).to have_content 'This tag has no release notes.'
    end

    describe 'links on the tag page' do
      scenario 'has a button to browse files' do
        click_on 'v1.0.0'

        expect(current_path).to eq(
          namespace_project_tag_path(project.namespace, project, 'v1.0.0'))

        click_on 'Browse files'

        expect(current_path).to eq(
          namespace_project_tree_path(project.namespace, project, 'v1.0.0'))
      end

      scenario 'has a button to browse commits' do
        click_on 'v1.0.0'

        expect(current_path).to eq(
          namespace_project_tag_path(project.namespace, project, 'v1.0.0'))

        click_on 'Browse commits'

        expect(current_path).to eq(
          namespace_project_commits_path(project.namespace, project, 'v1.0.0'))
      end
    end
  end
end