summaryrefslogtreecommitdiff
path: root/features/steps/project/project_team_management.rb
blob: 5c3a9b311295f3cb31323c38899434a4a7e972d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
class ProjectTeamManagement < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedProject
  include SharedPaths

  Then 'I should be able to see myself in team' do
    page.should have_content(@user.name)
    page.should have_content(@user.email)
  end

  And 'I should see "Sam" in team list' do
    user = User.find_by_name("Sam")
    page.should have_content(user.name)
    page.should have_content(user.email)
  end

  Given 'I click link "New Team Member"' do
    click_link "New Team Member"
  end

  And 'I select "Mike" as "Reporter"' do
    user = User.find_by_name("Mike")
    within "#new_team_member" do
      select user.name, :from => "user_ids"
      select "Reporter", :from => "project_access"
    end
    click_button "Save"
  end

  Then 'I should see "Mike" in team list as "Reporter"' do
    user = User.find_by_name("Mike")
    role_id = find(".user_#{user.id} #team_member_project_access").value
    role_id.should == UsersProject.access_roles["Reporter"].to_s
  end

  Given 'I should see "Sam" in team list as "Developer"' do
    user = User.find_by_name("Sam")
    role_id = find(".user_#{user.id} #team_member_project_access").value
    role_id.should == UsersProject.access_roles["Developer"].to_s
  end

  And 'I change "Sam" role to "Reporter"' do
    user = User.find_by_name("Sam")
    within ".user_#{user.id}" do
      select "Reporter", :from => "team_member_project_access"
    end
  end

  And 'I should see "Sam" in team list as "Reporter"' do
    user = User.find_by_name("Sam")
    role_id = find(".user_#{user.id} #team_member_project_access").value
    role_id.should == UsersProject.access_roles["Reporter"].to_s
  end

  Given 'I click link "Sam"' do
    click_link "Sam"
  end

  Then 'I should see "Sam" team profile' do
    user = User.find_by_name("Sam")
    page.should have_content(user.name)
    page.should have_content(user.email)
    page.should have_content("To team list")
  end

  And 'I click link "Remove from team"' do
    click_link "Remove from team"
  end

  And 'I should not see "Sam" in team list' do
    user = User.find_by_name("Sam")
    page.should_not have_content(user.name)
    page.should_not have_content(user.email)
  end

  And 'gitlab user "Mike"' do
    Factory :user, :name => "Mike"
  end

  And 'gitlab user "Sam"' do
    Factory :user, :name => "Sam"
  end

  And '"Sam" is "Shop" developer' do
    user = User.find_by_name("Sam")
    project = Project.find_by_name("Shop")
    project.add_access(user, :write)
  end

  Given 'I own project "Website"' do
    @project = Factory :project, :name => "Website"
    @project.add_access(@user, :admin)
  end

  And '"Mike" is "Website" reporter' do
    user = User.find_by_name("Mike")
    project = Project.find_by_name("Website")
    project.add_access(user, :read)
  end

  And 'I click link "Import team from another project"' do
    click_link "Import team from another project"
  end

  When 'I submit "Website" project for import team' do
    select 'Website', from: 'source_project_id'
    click_button 'Import'
  end
end