BigW Consortium Gitlab

team_management.rb 3.71 KB
Newer Older
1
class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
Nihad Abbasov committed
2 3 4
  include SharedAuthentication
  include SharedProject
  include SharedPaths
5
  include Select2Helper
Nihad Abbasov committed
6

7
  step 'I should be able to see myself in team' do
8 9
    expect(page).to have_content(@user.name)
    expect(page).to have_content(@user.username)
10 11
  end

12 13
  step 'I should see "Dmitriy" in team list' do
    user = User.find_by(name: "Dmitriy")
14 15
    expect(page).to have_content(user.name)
    expect(page).to have_content(user.username)
16 17
  end

18
  step 'I select "Mike" as "Reporter"' do
skv committed
19
    user = User.find_by(name: "Mike")
20

21
    page.within ".users-project-form" do
22
      select2(user.id, from: "#user_ids", multiple: true)
23
      select "Reporter", from: "access_level"
24
    end
25
    click_button "Add users to project"
26 27
  end

28
  step 'I should see "Mike" in team list as "Reporter"' do
29
    page.within ".access-reporter" do
30
      expect(page).to have_content('Mike')
31
    end
32 33
  end

34
  step 'I select "sjobs@apple.com" as "Reporter"' do
35
    page.within ".users-project-form" do
36 37 38 39 40 41 42
      select2("sjobs@apple.com", from: "#user_ids", multiple: true)
      select "Reporter", from: "access_level"
    end
    click_button "Add users to project"
  end

  step 'I should see "sjobs@apple.com" in team list as invited "Reporter"' do
43
    page.within ".access-reporter" do
44 45 46
      expect(page).to have_content('sjobs@apple.com')
      expect(page).to have_content('invited')
      expect(page).to have_content('Reporter')
47 48 49
    end
  end

50
  step 'I should see "Dmitriy" in team list as "Developer"' do
51
    page.within ".access-developer" do
52
      expect(page).to have_content('Dmitriy')
53
    end
54 55
  end

56
  step 'I change "Dmitriy" role to "Reporter"' do
57
    project = Project.find_by(name: "Shop")
58
    user = User.find_by(name: 'Dmitriy')
59
    project_member = project.project_members.find_by(user_id: user.id)
60
    page.within "#project_member_#{project_member.id}" do
Douwe Maan committed
61
      click_button "Edit access level"
62
      select "Reporter", from: "project_member_access_level"
Douwe Maan committed
63
      click_button "Save"
64 65 66
    end
  end

67
  step 'I should see "Dmitriy" in team list as "Reporter"' do
68
    page.within ".access-reporter" do
69
      expect(page).to have_content('Dmitriy')
70
    end
71 72
  end

73
  step 'I click link "Remove from team"' do
74 75 76
    click_link "Remove from team"
  end

77 78
  step 'I should not see "Dmitriy" in team list' do
    user = User.find_by(name: "Dmitriy")
79 80
    expect(page).not_to have_content(user.name)
    expect(page).not_to have_content(user.username)
81 82
  end

83
  step 'gitlab user "Mike"' do
84
    create(:user, name: "Mike")
85 86
  end

87 88
  step 'gitlab user "Dmitriy"' do
    create(:user, name: "Dmitriy")
89 90
  end

91 92
  step '"Dmitriy" is "Shop" developer' do
    user = User.find_by(name: "Dmitriy")
skv committed
93
    project = Project.find_by(name: "Shop")
94
    project.team << [user, :developer]
95
  end
Dmitriy Zaporozhets committed
96

97
  step 'I own project "Website"' do
98
    @project = create(:empty_project, name: "Website", namespace: @user.namespace)
99
    @project.team << [@user, :master]
Dmitriy Zaporozhets committed
100 101
  end

102
  step '"Mike" is "Website" reporter' do
skv committed
103 104
    user = User.find_by(name: "Mike")
    project = Project.find_by(name: "Website")
105
    project.team << [user, :reporter]
Dmitriy Zaporozhets committed
106 107
  end

108
  step 'I click link "Import team from another project"' do
Dmitriy Zaporozhets committed
109
    click_link "Import members from another project"
Dmitriy Zaporozhets committed
110 111 112
  end

  When 'I submit "Website" project for import team' do
skv committed
113
    project = Project.find_by(name: "Website")
Dmitriy Zaporozhets committed
114
    select project.name_with_namespace, from: 'source_project_id'
Dmitriy Zaporozhets committed
115 116
    click_button 'Import'
  end
117

118
  step 'I click cancel link for "Dmitriy"' do
119
    project = Project.find_by(name: "Shop")
120
    user = User.find_by(name: 'Dmitriy')
121
    project_member = project.project_members.find_by(user_id: user.id)
122
    page.within "#project_member_#{project_member.id}" do
123 124 125
      click_link('Remove user from team')
    end
  end
126
end