BigW Consortium Gitlab

admin_projects_spec.rb 3.23 KB
Newer Older
gitlabhq committed
1 2
require 'spec_helper'

3
describe "Admin::Projects", feature: true  do
4 5 6 7 8
  include Select2Helper

  let(:user) { create :user }
  let!(:project) { create(:project) }
  let!(:current_user) do
gitlabhq committed
9 10 11 12
    login_as :admin
  end

  describe "GET /admin/projects" do
13
    let!(:archived_project) { create :project, :public, :archived }
14

Nihad Abbasov committed
15
    before do
16
      visit admin_projects_path
gitlabhq committed
17 18
    end

19
    it "is ok" do
20
      expect(current_path).to eq(admin_projects_path)
gitlabhq committed
21 22
    end

23 24 25 26 27 28 29 30 31 32 33 34
    it 'renders projects list without archived project' do
      expect(page).to have_content(project.name)
      expect(page).not_to have_content(archived_project.name)
    end

    it 'renders all projects', js: true do
      find(:css, '#sort-projects-dropdown').click
      click_link 'Show archived projects'

      expect(page).to have_content(project.name)
      expect(page).to have_content(archived_project.name)
      expect(page).to have_xpath("//span[@class='label label-warning']", text: 'archived')
gitlabhq committed
35 36 37
    end
  end

38
  describe "GET /admin/projects/:namespace_id/:id" do
Nihad Abbasov committed
39
    before do
40
      visit admin_projects_path
41 42 43 44 45
      click_link "#{project.name}"
    end

    it do
      expect(current_path).to eq admin_namespace_project_path(project.namespace, project)
gitlabhq committed
46 47
    end

48
    it "has project info" do
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      expect(page).to have_content(project.path)
      expect(page).to have_content(project.name)
      expect(page).to have_content(project.name_with_namespace)
      expect(page).to have_content(project.creator.name)
    end
  end

  describe 'transfer project' do
    before do
      create(:group, name: 'Web')

      allow_any_instance_of(Projects::TransferService).
        to receive(:move_uploads_to_new_namespace).and_return(true)
    end

    it 'transfers project to group web', js: true do
      visit admin_namespace_project_path(project.namespace, project)

      click_button 'Search for Namespace'
      click_link 'group: web'
      click_button 'Transfer'

      expect(page).to have_content("Web / #{project.name}")
      expect(page).to have_content('Namespace: Web')
    end
  end

  describe 'add admin himself to a project' do
    before do
      project.team << [user, :master]
    end

    it 'adds admin a to a project as developer', js: true do
      visit namespace_project_project_members_path(project.namespace, project)

      page.within '.users-project-form' do
        select2(current_user.id, from: '#user_ids', multiple: true)
        select 'Developer', from: 'access_level'
      end

      click_button 'Add to project'

      page.within '.content-list' do
        expect(page).to have_content(current_user.name)
        expect(page).to have_content('Developer')
      end
    end
  end

  describe 'admin remove himself from a project' do
    before do
      project.team << [user, :master]
      project.team << [current_user, :developer]
    end

    it 'removes admin from the project' do
      visit namespace_project_project_members_path(project.namespace, project)

      page.within '.content-list' do
        expect(page).to have_content(current_user.name)
        expect(page).to have_content('Developer')
      end

112
      find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-remove').click
113 114

      expect(page).not_to have_selector(:css, '.content-list')
gitlabhq committed
115 116 117
    end
  end
end