projects_spec.rb 3.98 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2 3 4 5 6
require 'spec_helper'

describe "Projects" do
  before { login_as :user }

  describe "GET /projects" do
Nihad Abbasov's avatar
Nihad Abbasov committed
7
    before do
gitlabhq's avatar
gitlabhq committed
8 9
      @project = Factory :project
      @project.add_access(@user, :read)
gitlabhq's avatar
gitlabhq committed
10 11 12 13
      visit projects_path
    end

    it "should be on projects page" do
Nihad Abbasov's avatar
Nihad Abbasov committed
14
      current_path.should == projects_path
gitlabhq's avatar
gitlabhq committed
15 16 17
    end

    it "should have link to new project" do
gitlabhq's avatar
fixes  
gitlabhq committed
18
      page.should have_content("Create new project")
gitlabhq's avatar
gitlabhq committed
19
    end
gitlabhq's avatar
gitlabhq committed
20 21 22 23

    it "should have project" do 
      page.should have_content(@project.name)
    end
gitlabhq's avatar
gitlabhq committed
24 25 26
  end

  describe "GET /projects/new" do
Nihad Abbasov's avatar
Nihad Abbasov committed
27
    before do
gitlabhq's avatar
gitlabhq committed
28
      visit projects_path
gitlabhq's avatar
fixes  
gitlabhq committed
29
      click_link "Create new project"
gitlabhq's avatar
gitlabhq committed
30 31 32
    end

    it "should be correct path" do
Nihad Abbasov's avatar
Nihad Abbasov committed
33
      current_path.should == new_project_path
gitlabhq's avatar
gitlabhq committed
34 35 36
    end

    it "should have labels for new project" do
Nihad Abbasov's avatar
Nihad Abbasov committed
37 38 39
      page.should have_content("Name")
      page.should have_content("Path")
      page.should have_content("Description")
gitlabhq's avatar
gitlabhq committed
40 41 42 43
    end
  end

  describe "POST /projects" do
Nihad Abbasov's avatar
Nihad Abbasov committed
44
    before do
gitlabhq's avatar
gitlabhq committed
45 46 47
      visit new_project_path
      fill_in 'Name', :with => 'NewProject'
      fill_in 'Code', :with => 'NPR'
48
      fill_in 'Path', :with => 'newproject'
gitlabhq's avatar
gitlabhq committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
      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
Nihad Abbasov's avatar
Nihad Abbasov committed
70
    before do
gitlabhq's avatar
gitlabhq committed
71 72 73 74 75 76 77 78 79 80
      @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

81
    it "should beahave like activities page" do
82
      within ".project-update"  do
83 84 85 86
        page.should have_content("master")
        page.should have_content(@project.commit.author.name)
        page.should have_content(@project.commit.safe_message)
      end
gitlabhq's avatar
gitlabhq committed
87
    end
gitlabhq's avatar
gitlabhq committed
88 89 90
  end

  describe "GET /projects/team" do
Nihad Abbasov's avatar
Nihad Abbasov committed
91
    before do
gitlabhq's avatar
gitlabhq committed
92 93 94 95 96 97 98 99 100 101 102 103
      @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

Nihad Abbasov's avatar
Nihad Abbasov committed
104
    it "should have as as team member" do
gitlabhq's avatar
gitlabhq committed
105 106 107 108 109
      page.should have_content(@user.name)
    end
  end

  describe "GET /projects/:id/edit" do
Nihad Abbasov's avatar
Nihad Abbasov committed
110
    before do
gitlabhq's avatar
gitlabhq committed
111 112 113 114 115 116 117 118 119 120 121
      @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
Nihad Abbasov's avatar
Nihad Abbasov committed
122 123 124
      page.should have_content("Name")
      page.should have_content("Path")
      page.should have_content("Description")
gitlabhq's avatar
gitlabhq committed
125 126 127 128
    end
  end

  describe "PUT /projects/:id" do
Nihad Abbasov's avatar
Nihad Abbasov committed
129
    before do
gitlabhq's avatar
gitlabhq committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
      @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
Nihad Abbasov's avatar
Nihad Abbasov committed
152
    #before do
gitlabhq's avatar
gitlabhq committed
153 154 155 156 157 158
      #@project = Factory :project
      #@project.add_access(@user, :read, :admin)
      #visit projects_path
    #end

    #it "should be correct path" do
Nihad Abbasov's avatar
Nihad Abbasov committed
159
      #expect { click_link "Destroy" }.to change {Project.count}.by(1)
gitlabhq's avatar
gitlabhq committed
160 161 162
    #end
  #end
end