team_members_spec.rb 1.83 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 13 14 15 16 17 18 19
  describe "Update profile", :js => true do
    it "should update user role" do
      @project.master_access_for?(@user).should be_true
      visit team_project_path(@project)
      select "Developer", :from => "team_member_project_access"
      @project.master_access_for?(@user).should be_false
      @project.dev_access_for?(@user).should be_true
    end
  end

20 21 22
  describe "View profile" do
    it "should be available" do
      visit(team_project_path(@project))
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
23
      click_link(@user.name)
24 25 26 27 28
      page.should have_content @user.skype
      page.should_not have_content 'Twitter'
    end
  end

29
  describe "New Team member" do
Nihad Abbasov's avatar
Nihad Abbasov committed
30
    before do
gitlabhq's avatar
gitlabhq committed
31 32
      @user_1 = Factory :user
      visit team_project_path(@project)
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
33
      click_link "New Team Member"
gitlabhq's avatar
gitlabhq committed
34 35
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
36
    it "should open new team member popup" do
37
      page.should have_content("New Team member")
gitlabhq's avatar
gitlabhq committed
38 39
    end

Nihad Abbasov's avatar
Nihad Abbasov committed
40
    describe "fill in" do
gitlabhq's avatar
gitlabhq committed
41
      before do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
42
        within "#new_team_member" do 
43
          select @user_1.name, :from => "team_member_user_id"
44
          select "Reporter", :from => "team_member_project_access"
gitlabhq's avatar
gitlabhq committed
45
        end
gitlabhq's avatar
gitlabhq committed
46 47
      end

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

Nihad Abbasov's avatar
Nihad Abbasov committed
50
      it "should add new member to table" do
gitlabhq's avatar
gitlabhq committed
51
        click_button "Save"
gitlabhq's avatar
gitlabhq committed
52
        @member = UsersProject.last
gitlabhq's avatar
gitlabhq committed
53 54

        page.should have_content @user_1.name
gitlabhq's avatar
gitlabhq committed
55

56
        @member.reload
57
        @member.project_access.should == UsersProject::REPORTER
gitlabhq's avatar
gitlabhq committed
58 59 60 61
      end
    end
  end

Nihad Abbasov's avatar
Nihad Abbasov committed
62 63
  describe "Cancel membership" do
    it "should cancel membership" do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
64 65
      visit project_team_member_path(@project, @project.users_projects.last)
      expect { click_link "Remove from team" }.to change { UsersProject.count }.by(-1)
gitlabhq's avatar
gitlabhq committed
66 67 68
    end
  end
end