projects_spec.rb 4.6 KB
Newer Older
G
gitlabhq 已提交
1 2
require 'spec_helper'

3
feature 'Project', feature: true do
4 5 6
  describe 'description' do
    let(:project) { create(:project) }
    let(:path)    { namespace_project_path(project.namespace, project) }
G
gitlabhq 已提交
7

R
randx 已提交
8
    before do
9
      login_as(:admin)
R
randx 已提交
10 11
    end

12 13 14 15 16 17 18 19 20
    it 'parses Markdown' do
      project.update_attribute(:description, 'This is **my** project')
      visit path
      expect(page).to have_css('.project-home-desc > p > strong')
    end

    it 'passes through html-pipeline' do
      project.update_attribute(:description, 'This project is the :poop:')
      visit path
E
Eric Eastwood 已提交
21
      expect(page).to have_css('.project-home-desc > p > gl-emoji')
22 23 24
    end

    it 'sanitizes unwanted tags' do
D
Douwe Maan 已提交
25
      project.update_attribute(:description, "```\ncode\n```")
26
      visit path
D
Douwe Maan 已提交
27
      expect(page).not_to have_css('.project-home-desc code')
28 29 30 31 32 33 34 35 36
    end

    it 'permits `rel` attribute on links' do
      project.update_attribute(:description, 'https://google.com/')
      visit path
      expect(page).to have_css('.project-home-desc a[rel]')
    end
  end

37 38 39 40 41 42 43 44 45 46
  describe 'remove forked relationship', js: true do
    let(:user)    { create(:user) }
    let(:project) { create(:project, namespace: user.namespace) }

    before do
      login_with user
      create(:forked_project_link, forked_to_project: project)
      visit edit_namespace_project_path(project.namespace, project)
    end

47
    it 'removes fork' do
48
      expect(page).to have_content 'Remove fork relationship'
49

50
      remove_with_confirm('Remove fork relationship', project.path)
51

D
Douwe Maan 已提交
52
      expect(page).to have_content 'The fork relationship has been removed.'
53
      expect(project.forked?).to be_falsey
54
      expect(page).not_to have_content 'Remove fork relationship'
55 56 57
    end
  end

58 59
  describe 'removal', js: true do
    let(:user)    { create(:user) }
U
ubudzisz 已提交
60
    let(:project) { create(:project, namespace: user.namespace, name: 'project1') }
61 62 63 64 65 66 67

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

U
ubudzisz 已提交
68
    it 'removes a project' do
69
      expect { remove_with_confirm('Remove project', project.path) }.to change {Project.count}.by(-1)
U
ubudzisz 已提交
70 71 72 73
      expect(page).to have_content "Project 'project1' will be deleted."
      expect(Project.all.count).to be_zero
      expect(project.issues).to be_empty
      expect(project.merge_requests).to be_empty
R
randx 已提交
74 75
    end
  end
D
Dmitriy Zaporozhets 已提交
76

P
Phil Hughes 已提交
77 78 79 80 81 82 83 84
  describe 'project title' do
    include WaitForAjax

    let(:user)    { create(:user) }
    let(:project) { create(:project, namespace: user.namespace) }

    before do
      login_with(user)
85
      project.add_user(user, Gitlab::Access::MASTER)
P
Phil Hughes 已提交
86 87 88
      visit namespace_project_path(project.namespace, project)
    end

89
    it 'clicks toggle and shows dropdown', js: true do
P
Phil Hughes 已提交
90
      find('.js-projects-dropdown-toggle').click
P
Phil Hughes 已提交
91
      expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 1)
92
    end
D
Drew Blessing 已提交
93 94
  end

P
Phil Hughes 已提交
95 96 97 98 99 100 101 102 103
  describe 'project title' do
    let(:user)    { create(:user) }
    let(:project) { create(:project, namespace: user.namespace) }
    let(:project2) { create(:project, namespace: user.namespace, path: 'test') }
    let(:issue) { create(:issue, project: project) }

    context 'on issues page', js: true do
      before do
        login_with(user)
104 105
        project.add_user(user, Gitlab::Access::MASTER)
        project2.add_user(user, Gitlab::Access::MASTER)
P
Phil Hughes 已提交
106 107 108
        visit namespace_project_issue_path(project.namespace, project, issue)
      end

109
      it 'clicks toggle and shows dropdown' do
P
Phil Hughes 已提交
110 111 112 113 114 115 116 117 118 119 120 121
        find('.js-projects-dropdown-toggle').click
        expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 2)

        page.within '.dropdown-menu-projects' do
          click_link project.name_with_namespace
        end

        expect(page).to have_content project.name
      end
    end
  end

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
  describe 'tree view (default view is set to Files)' do
    let(:user) { create(:user, project_view: 'files') }
    let(:project) { create(:forked_project_with_submodules) }

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

    it 'has working links to files' do
      click_link('PROCESS.md')

      expect(page.status_code).to eq(200)
    end

    it 'has working links to directories' do
      click_link('encoding')

      expect(page.status_code).to eq(200)
    end

    it 'has working links to submodules' do
      click_link('645f6c4c')

      expect(page.status_code).to eq(200)
    end
  end

151 152 153
  def remove_with_confirm(button_text, confirm_with)
    click_button button_text
    fill_in 'confirm_name_input', with: confirm_with
D
Dmitriy Zaporozhets 已提交
154 155
    click_button 'Confirm'
  end
G
gitlabhq 已提交
156
end