admin_projects_spec.rb 2.9 KB
Newer Older
G
gitlabhq 已提交
1 2 3
require 'spec_helper'

describe "Admin::Projects" do
N
Nihad Abbasov 已提交
4
  before do
5 6 7
    @project = create(:project,
                      name: "LeGiT",
                      code: "LGT")
G
gitlabhq 已提交
8 9 10 11
    login_as :admin
  end

  describe "GET /admin/projects" do
N
Nihad Abbasov 已提交
12
    before do
G
gitlabhq 已提交
13 14 15 16 17 18 19
      visit admin_projects_path
    end

    it "should be ok" do
      current_path.should == admin_projects_path
    end

N
Nihad Abbasov 已提交
20
    it "should have projects list" do
G
gitlabhq 已提交
21 22 23 24
      page.should have_content(@project.name)
    end
  end

N
Nihad Abbasov 已提交
25 26
  describe "GET /admin/projects/:id" do
    before do
G
gitlabhq 已提交
27
      visit admin_projects_path
S
Saito 已提交
28
      click_link "#{@project.name}"
G
gitlabhq 已提交
29 30
    end

N
Nihad Abbasov 已提交
31
    it "should have project info" do
G
gitlabhq 已提交
32 33 34 35 36
      page.should have_content(@project.code)
      page.should have_content(@project.name)
    end
  end

N
Nihad Abbasov 已提交
37 38
  describe "GET /admin/projects/:id/edit" do
    before do
G
gitlabhq 已提交
39 40 41 42
      visit admin_projects_path
      click_link "edit_project_#{@project.id}"
    end

N
Nihad Abbasov 已提交
43
    it "should have project edit page" do
R
randx 已提交
44 45
      page.should have_content("Project name")
      page.should have_content("URL")
G
gitlabhq 已提交
46 47 48
    end

    describe "Update project" do
N
Nihad Abbasov 已提交
49
      before do
50 51
        fill_in "project_name", with: "Big Bang"
        fill_in "project_code", with: "BB1"
R
randx 已提交
52
        click_button "Save Project"
G
gitlabhq 已提交
53 54 55
        @project.reload
      end

N
Nihad Abbasov 已提交
56
      it "should show page with  new data" do
G
gitlabhq 已提交
57 58 59 60
        page.should have_content("BB1")
        page.should have_content("Big Bang")
      end

N
Nihad Abbasov 已提交
61
      it "should change project entry" do
G
gitlabhq 已提交
62 63 64 65 66 67 68
        @project.name.should == "Big Bang"
        @project.code.should == "BB1"
      end
    end
  end

  describe "GET /admin/projects/new" do
N
Nihad Abbasov 已提交
69
    before do
G
gitlabhq 已提交
70 71 72 73 74
      visit admin_projects_path
      click_link "New Project"
    end

    it "should be correct path" do
N
Nihad Abbasov 已提交
75
      current_path.should == new_admin_project_path
G
gitlabhq 已提交
76 77 78
    end

    it "should have labels for new project" do
R
randx 已提交
79 80 81
      page.should have_content("Project name is")
      page.should have_content("Git Clone")
      page.should have_content("URL")
G
gitlabhq 已提交
82 83 84 85
    end
  end

  describe "POST /admin/projects" do
N
Nihad Abbasov 已提交
86
    before do
G
gitlabhq 已提交
87
      visit new_admin_project_path
88 89
      fill_in 'project_name', with: 'NewProject'
      fill_in 'project_code', with: 'NPR'
D
Dmitriy Zaporozhets 已提交
90
      fill_in 'project_path', with: 'gitlabhq_1'
R
randx 已提交
91
      expect { click_button "Create project" }.to change { Project.count }.by(1)
G
gitlabhq 已提交
92 93 94 95 96 97 98 99 100 101 102 103
      @project = Project.last
    end

    it "should be correct path" do
      current_path.should == admin_project_path(@project)
    end

    it "should show project" do
      page.should have_content(@project.name)
      page.should have_content(@project.path)
    end
  end
D
Dmitriy Zaporozhets 已提交
104

D
Dmitriy Zaporozhets 已提交
105 106
  describe "Add new team member" do
    before do
107
      @new_user = create(:user)
D
Dmitriy Zaporozhets 已提交
108 109 110
      visit admin_project_path(@project)
    end

D
Dmitriy Zaporozhets 已提交
111
    it "should create new user" do
112
      select @new_user.name, from: "user_ids"
D
Dmitriy Zaporozhets 已提交
113 114 115 116 117
      expect { click_button "Add" }.to change { UsersProject.count }.by(1)
      page.should have_content @new_user.name
      current_path.should == admin_project_path(@project)
    end
  end
G
gitlabhq 已提交
118
end