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
G
gitlabhq 已提交
5 6 7 8 9 10 11
    @project = Factory :project,
      :name => "LeGiT",
      :code => "LGT"
    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
G
gitlabhq 已提交
44 45 46 47 48
      page.should have_content("Name")
      page.should have_content("Code")
    end

    describe "Update project" do
N
Nihad Abbasov 已提交
49
      before do
G
gitlabhq 已提交
50 51 52 53 54 55
        fill_in "project_name", :with => "Big Bang"
        fill_in "project_code", :with => "BB1"
        click_button "Save"
        @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
N
Nihad Abbasov 已提交
79 80 81
      page.should have_content("Name")
      page.should have_content("Path")
      page.should have_content("Description")
G
gitlabhq 已提交
82 83 84 85
    end
  end

  describe "POST /admin/projects" do
N
Nihad Abbasov 已提交
86
    before do
G
gitlabhq 已提交
87 88 89
      visit new_admin_project_path
      fill_in 'Name', :with => 'NewProject'
      fill_in 'Code', :with => 'NPR'
90
      fill_in 'Path', :with => 'gitlabhq_1'
91
      fill_in 'Description', :with => 'New Project Description'
G
gitlabhq 已提交
92 93 94 95 96 97 98 99 100 101 102 103 104 105
      expect { click_button "Save" }.to change { Project.count }.by(1)
      @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)
      page.should have_content(@project.description)
    end
  end
D
Dmitriy Zaporozhets 已提交
106 107 108 109 110 111 112 113 114 115 116 117 118 119

  describe "Add new team member" do 
    before do 
      @new_user = Factory :user
      visit admin_project_path(@project)
    end

    it "should create new user" do 
      select @new_user.name, :from => "user_ids"
      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 已提交
120
end