BigW Consortium Gitlab

projects_spec.rb 3.72 KB
Newer Older
gitlabhq committed
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) }
gitlabhq committed
7

randx committed
8
    before do
9
      login_as(:admin)
randx committed
10 11
    end

12 13 14 15 16 17 18 19 20 21 22 23 24
    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
      expect(page).to have_css('.project-home-desc > p > img')
    end

    it 'sanitizes unwanted tags' do
Douwe Maan committed
25
      project.update_attribute(:description, "```\ncode\n```")
26
      visit path
Douwe Maan committed
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 47
  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

    it 'should remove fork' do
48
      expect(page).to have_content 'Remove fork relationship'
49

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

Douwe Maan committed
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 60 61 62 63 64 65 66 67 68
  describe 'removal', js: true do
    let(:user)    { create(:user) }
    let(:project) { create(:project, namespace: user.namespace) }

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

    it 'should remove project' do
69
      expect { remove_with_confirm('Remove project', project.path) }.to change {Project.count}.by(-1)
randx committed
70 71
    end
  end
Dmitriy Zaporozhets committed
72

Phil Hughes committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86
  describe 'project title' do
    include WaitForAjax

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

    before do
      login_with(user)
      project.team.add_user(user, Gitlab::Access::MASTER)
      visit namespace_project_path(project.namespace, project)
    end

    it 'click toggle and show dropdown', js: true do
      find('.js-projects-dropdown-toggle').click
Phil Hughes committed
87
      expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 1)
88
    end
89 90
  end

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
  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)
        project.team.add_user(user, Gitlab::Access::MASTER)
        project2.team.add_user(user, Gitlab::Access::MASTER)
        visit namespace_project_issue_path(project.namespace, project, issue)
      end

      it 'click toggle and show dropdown' do
        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

118 119 120
  def remove_with_confirm(button_text, confirm_with)
    click_button button_text
    fill_in 'confirm_name_input', with: confirm_with
Dmitriy Zaporozhets committed
121 122
    click_button 'Confirm'
  end
gitlabhq committed
123
end