projects_spec.rb 3.6 KB
Newer Older
G
gitlabhq 已提交
1 2 3 4 5 6
require 'spec_helper'

describe "Projects" do
  before { login_as :user }

  describe "GET /projects" do
N
Nihad Abbasov 已提交
7
    before do
G
gitlabhq 已提交
8 9 10 11
      visit projects_path
    end

    it "should be on projects page" do
N
Nihad Abbasov 已提交
12
      current_path.should == projects_path
G
gitlabhq 已提交
13 14 15
    end

    it "should have link to new project" do
N
Nihad Abbasov 已提交
16
      page.should have_content("New Project")
G
gitlabhq 已提交
17 18 19 20
    end
  end

  describe "GET /projects/new" do
N
Nihad Abbasov 已提交
21
    before do
G
gitlabhq 已提交
22 23 24 25 26
      visit projects_path
      click_link "New Project"
    end

    it "should be correct path" do
N
Nihad Abbasov 已提交
27
      current_path.should == new_project_path
G
gitlabhq 已提交
28 29 30
    end

    it "should have labels for new project" do
N
Nihad Abbasov 已提交
31 32 33
      page.should have_content("Name")
      page.should have_content("Path")
      page.should have_content("Description")
G
gitlabhq 已提交
34 35 36 37
    end
  end

  describe "POST /projects" do
N
Nihad Abbasov 已提交
38
    before do
G
gitlabhq 已提交
39 40 41
      visit new_project_path
      fill_in 'Name', :with => 'NewProject'
      fill_in 'Code', :with => 'NPR'
G
gitlabhq 已提交
42
      fill_in 'Path', :with => 'newproject'
G
gitlabhq 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
      expect { click_button "Create Project" }.to change { Project.count }.by(1)
      @project = Project.last
    end

    it "should be correct path" do
      current_path.should == 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

    it "should init repo instructions" do
      page.should have_content("git remote")
      page.should have_content(@project.url_to_repo)
    end
  end

  describe "GET /projects/show" do
N
Nihad Abbasov 已提交
64
    before do
G
gitlabhq 已提交
65 66 67 68 69 70 71 72 73 74
      @project = Factory :project
      @project.add_access(@user, :read)

      visit project_path(@project)
    end

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

N
Nihad Abbasov 已提交
75
    it "should beahave like dashboard" do
G
gitlabhq 已提交
76
      page.should have_content("History")
G
gitlabhq 已提交
77 78
    end

G
gitlabhq 已提交
79 80 81
  end

  describe "GET /projects/team" do
N
Nihad Abbasov 已提交
82
    before do
G
gitlabhq 已提交
83 84 85 86 87 88 89 90 91 92 93 94
      @project = Factory :project
      @project.add_access(@user, :read)

      visit team_project_path(@project,
                              :path => ValidCommit::BLOB_FILE_PATH,
                              :commit_id => ValidCommit::ID)
    end

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

N
Nihad Abbasov 已提交
95
    it "should have as as team member" do
G
gitlabhq 已提交
96 97 98 99 100
      page.should have_content(@user.name)
    end
  end

  describe "GET /projects/:id/edit" do
N
Nihad Abbasov 已提交
101
    before do
G
gitlabhq 已提交
102 103 104 105 106 107 108 109 110 111 112
      @project = Factory :project
      @project.add_access(@user, :admin, :read)

      visit edit_project_path(@project)
    end

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

    it "should have labels for new project" do
N
Nihad Abbasov 已提交
113 114 115
      page.should have_content("Name")
      page.should have_content("Path")
      page.should have_content("Description")
G
gitlabhq 已提交
116 117 118 119
    end
  end

  describe "PUT /projects/:id" do
N
Nihad Abbasov 已提交
120
    before do
G
gitlabhq 已提交
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
      @project = Factory :project
      @project.add_access(@user, :admin, :read)

      visit edit_project_path(@project)

      fill_in 'Name', :with => 'Awesome'
      fill_in 'Path', :with => 'legit'
      fill_in 'Description', :with => 'Awesome project'
      click_button "Update Project"
      @project = @project.reload
    end

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

    it "should show project" do
      page.should have_content("Awesome")
    end
  end

  #describe "DELETE /projects/:id", :js => true do
N
Nihad Abbasov 已提交
143
    #before do
G
gitlabhq 已提交
144 145 146 147 148 149
      #@project = Factory :project
      #@project.add_access(@user, :read, :admin)
      #visit projects_path
    #end

    #it "should be correct path" do
N
Nihad Abbasov 已提交
150
      #expect { click_link "Destroy" }.to change {Project.count}.by(1)
G
gitlabhq 已提交
151 152 153
    #end
  #end
end