groups_spec.rb 3.2 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Group', feature: true do
4 5 6 7
  before do
    login_as(:admin)
  end

8 9 10 11 12 13
  matcher :have_namespace_error_message do
    match do |page|
      page.has_content?("Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-' or end in '.', '.git' or '.atom'.")
    end
  end

14 15
  describe 'create a group' do
    before { visit new_group_path }
16

17 18 19 20
    describe 'with space in group path' do
      it 'renders new group form with validation errors' do
        fill_in 'Group path', with: 'space group'
        click_button 'Create group'
21

22 23 24
        expect(current_path).to eq(groups_path)
        expect(page).to have_namespace_error_message
      end
25 26
    end

27 28 29 30
    describe 'with .atom at end of group path' do
      it 'renders new group form with validation errors' do
        fill_in 'Group path', with: 'atom_group.atom'
        click_button 'Create group'
31

32 33 34
        expect(current_path).to eq(groups_path)
        expect(page).to have_namespace_error_message
      end
35 36
    end

37 38 39 40
    describe 'with .git at end of group path' do
      it 'renders new group form with validation errors' do
        fill_in 'Group path', with: 'git_group.git'
        click_button 'Create group'
41

42 43 44
        expect(current_path).to eq(groups_path)
        expect(page).to have_namespace_error_message
      end
45 46 47
    end
  end

48
  describe 'group edit' do
S
Stan Hu 已提交
49 50
    let(:group) { create(:group) }
    let(:path)  { edit_group_path(group) }
51
    let(:new_name) { 'new-name' }
S
Stan Hu 已提交
52

53
    before { visit path }
S
Stan Hu 已提交
54

55 56
    it 'saves new settings' do
      fill_in 'group_name', with: new_name
S
Stan Hu 已提交
57 58 59
      click_button 'Save group'

      expect(page).to have_content 'successfully updated'
60 61 62 63 64
      expect(find('#group_name').value).to eq(new_name)

      page.within ".navbar-gitlab" do
        expect(page).to have_content new_name
      end
S
Stan Hu 已提交
65 66 67 68 69 70 71 72 73
    end

    it 'removes group' do
      click_link 'Remove Group'

      expect(page).to have_content "scheduled for deletion"
    end
  end

74
  describe 'group page with markdown description' do
75 76 77 78 79
    let(:group) { create(:group) }
    let(:path)  { group_path(group) }

    it 'parses Markdown' do
      group.update_attribute(:description, 'This is **my** group')
80

81
      visit path
82

83
      expect(page).to have_css('.group-home-desc > p > strong')
84 85 86 87
    end

    it 'passes through html-pipeline' do
      group.update_attribute(:description, 'This group is the :poop:')
88

89
      visit path
90

91
      expect(page).to have_css('.group-home-desc > p > img')
92 93 94 95
    end

    it 'sanitizes unwanted tags' do
      group.update_attribute(:description, '# Group Description')
96

97
      visit path
98

99
      expect(page).not_to have_css('.group-home-desc h1')
100 101 102 103
    end

    it 'permits `rel` attribute on links' do
      group.update_attribute(:description, 'https://google.com/')
104

105
      visit path
106

107
      expect(page).to have_css('.group-home-desc a[rel]')
108 109
    end
  end
110 111 112 113 114 115 116 117

  describe 'group page with nested groups', js: true do
    let!(:group) { create(:group) }
    let!(:nested_group) { create(:group, parent: group) }
    let!(:path)  { group_path(group) }

    it 'has nested groups tab with nested groups inside' do
      visit path
118
      click_link 'Subgroups'
119 120 121 122

      expect(page).to have_content(nested_group.full_name)
    end
  end
123
end