projects_spec.rb 1.62 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/show" do
Nihad Abbasov's avatar
Nihad Abbasov committed
7
    before do
8
      @project = create(:project, owner: @user)
gitlabhq's avatar
gitlabhq committed
9 10 11 12 13 14 15 16
      @project.add_access(@user, :read)

      visit project_path(@project)
    end

    it "should be correct path" do
      current_path.should == project_path(@project)
    end
randx's avatar
randx committed
17 18
  end

gitlabhq's avatar
gitlabhq committed
19
  describe "GET /projects/:id/edit" do
Nihad Abbasov's avatar
Nihad Abbasov committed
20
    before do
21
      @project = create(:project)
gitlabhq's avatar
gitlabhq committed
22 23 24 25 26 27 28 29 30 31
      @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
32 33 34
      page.should have_content("Project name is")
      page.should have_content("Advanced settings:")
      page.should have_content("Features:")
gitlabhq's avatar
gitlabhq committed
35 36 37 38
    end
  end

  describe "PUT /projects/:id" do
Nihad Abbasov's avatar
Nihad Abbasov committed
39
    before do
40
      @project = create(:project, owner: @user)
gitlabhq's avatar
gitlabhq committed
41 42 43 44
      @project.add_access(@user, :admin, :read)

      visit edit_project_path(@project)

45
      fill_in 'project_name', with: 'Awesome'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
46
      click_button "Save"
gitlabhq's avatar
gitlabhq committed
47 48 49 50
      @project = @project.reload
    end

    it "should be correct path" do
51
      current_path.should == edit_project_path(@project)
gitlabhq's avatar
gitlabhq committed
52 53 54 55 56 57 58
    end

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

randx's avatar
randx committed
59 60
  describe "DELETE /projects/:id" do
    before do
Sergey Linnik's avatar
Sergey Linnik committed
61
      @project = create(:project, owner: @user)
randx's avatar
randx committed
62 63 64 65 66 67 68 69
      @project.add_access(@user, :read, :admin)
      visit edit_project_path(@project)
    end

    it "should be correct path" do
      expect { click_link "Remove" }.to change {Project.count}.by(-1)
    end
  end
gitlabhq's avatar
gitlabhq committed
70
end