team_members_spec.rb 1.9 KB
Newer Older
gitlabhq's avatar
gitlabhq committed
1 2 3
require 'spec_helper'

describe "TeamMembers" do
Nihad Abbasov's avatar
Nihad Abbasov committed
4
  before do
gitlabhq's avatar
gitlabhq committed
5 6 7 8 9
    login_as :user
    @project = Factory :project
    @project.add_access(@user, :read, :admin)
  end

10 11 12
  describe "View profile" do
    it "should be available" do
      visit(team_project_path(@project))
Nihad Abbasov's avatar
Nihad Abbasov committed
13
      within "#team-table" do
gitlabhq's avatar
gitlabhq committed
14 15
        click_link(@user.name)
      end
16 17 18 19 20
      page.should have_content @user.skype
      page.should_not have_content 'Twitter'
    end
  end

Nihad Abbasov's avatar
Nihad Abbasov committed
21 22
  describe "New Team member", :js => true do
    before do
gitlabhq's avatar
gitlabhq committed
23 24 25 26 27
      @user_1 = Factory :user
      visit team_project_path(@project)
      click_link "Add new"
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
28
    it "should open new team member popup" do
gitlabhq's avatar
gitlabhq committed
29 30 31
      page.should have_content("Add new member to project")
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
32
    describe "fill in" do
gitlabhq's avatar
gitlabhq committed
33 34 35
      before do
        click_link "Select user"
        click_link @user_1.name
gitlabhq's avatar
gitlabhq committed
36

Nihad Abbasov's avatar
Nihad Abbasov committed
37
        within "#team_member_new" do
gitlabhq's avatar
gitlabhq committed
38 39 40
          check "team_member_read"
          check "team_member_write"
        end
gitlabhq's avatar
gitlabhq committed
41 42
      end

gitlabhq's avatar
gitlabhq committed
43
      it { expect { click_button "Save";sleep(1) }.to change {UsersProject.count}.by(1) }
gitlabhq's avatar
gitlabhq committed
44

Nihad Abbasov's avatar
Nihad Abbasov committed
45
      it "should add new member to table" do
gitlabhq's avatar
gitlabhq committed
46
        click_button "Save"
gitlabhq's avatar
gitlabhq committed
47
        @member = UsersProject.last
gitlabhq's avatar
gitlabhq committed
48 49

        page.should have_content @user_1.name
gitlabhq's avatar
gitlabhq committed
50 51 52 53 54 55

        @member.read.should be_true
        @member.write.should be_true
        @member.admin.should be_false
      end

Nihad Abbasov's avatar
Nihad Abbasov committed
56 57
      it "should not allow creation without access selected" do
        within "#team_member_new" do
gitlabhq's avatar
gitlabhq committed
58 59 60 61 62 63 64
          uncheck "team_member_read"
          uncheck "team_member_write"
          uncheck "team_member_admin"
        end

        expect { click_button "Save" }.to_not change {UsersProject.count}
        page.should have_content("Please choose at least one Role in the Access list")
gitlabhq's avatar
gitlabhq committed
65 66 67 68
      end
    end
  end

Nihad Abbasov's avatar
Nihad Abbasov committed
69 70
  describe "Cancel membership" do
    it "should cancel membership" do
gitlabhq's avatar
gitlabhq committed
71 72 73 74 75
      visit team_project_path(@project)
      expect { click_link "Cancel" }.to change { UsersProject.count }.by(-1)
    end
  end
end