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

user_view_commits_spec.rb « commits « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b58d7cf374162bcc510ea2efe6172ca43064d8db (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Commit > User view commits', feature_category: :source_code_management do
  let_it_be(:user) { create(:user) }
  let_it_be(:group) { create(:group, :public) }

  shared_examples 'can view commits' do
    it 'displays the correct number of commits per day in the header' do
      expect(first('.js-commit-header').find('.commits-count').text).to eq('1 commit')
    end

    it 'lists the correct number of commits' do
      expect(page).to have_selector('#commits-list > li:nth-child(2) > ul', count: 1)
    end
  end

  describe 'Commits List' do
    context 'when project is public' do
      let(:project) { create(:project, :public, :repository, group: group) }

      before do
        visit project_commits_path(project)
      end

      it_behaves_like 'can view commits'
    end

    context 'when project is public with private repository' do
      let(:project) { create(:project, :public, :repository, :repository_private, group: group) }

      context 'and user is an inherited member from the group' do
        context 'and user is a guest' do
          before do
            group.add_guest(user)
            sign_in(user)
            visit project_commits_path(project)
          end

          it_behaves_like 'can view commits'
        end
      end
    end

    context 'when project is private' do
      let(:project) { create(:project, :private, :repository, group: group) }

      context 'and user is an inherited member from the group' do
        context 'and user is a guest' do
          before do
            group.add_guest(user)
            sign_in(user)
            visit project_commits_path(project)
          end

          it 'renders not found' do
            expect(page).to have_title('Not Found')
            expect(page).to have_content('Page Not Found')
          end
        end
      end
    end
  end
end