BigW Consortium Gitlab

groups.rb 3.98 KB
Newer Older
1
class Spinach::Features::AdminGroups < Spinach::FeatureSteps
randx committed
2
  include SharedAuthentication
3
  include SharedGroup
randx committed
4
  include SharedPaths
5
  include SharedUser
randx committed
6
  include SharedActiveTab
7
  include Select2Helper
randx committed
8

9 10 11 12
  When 'I visit admin group page' do
    visit admin_group_path(current_group)
  end

randx committed
13 14 15 16
  When 'I click new group link' do
    click_link "New Group"
  end

17
  step 'I have group with projects' do
18 19 20 21
    @group   = create(:group)
    @project = create(:project, group: @group)
    @event   = create(:closed_issue_event, project: @project)

22
    @project.team << [current_user, :master]
23 24
  end

25
  step 'submit form with new group info' do
Dmitriy Zaporozhets committed
26
    fill_in 'group_path', with: 'gitlab'
27
    fill_in 'group_description', with: 'Group description'
28
    click_button "Create group"
randx committed
29 30
  end

31
  step 'I should see newly created group' do
32 33
    expect(page).to have_content "Group: gitlab"
    expect(page).to have_content "Group description"
randx committed
34 35
  end

36
  step 'I should be redirected to group page' do
37
    expect(current_path).to eq admin_group_path(Group.find_by(path: 'gitlab'))
randx committed
38
  end
39

40
  When 'I select user "John Doe" from user list as "Reporter"' do
41
    select2(user_john.id, from: "#user_ids", multiple: true)
42
    page.within "#new_project_member" do
43
      select "Reporter", from: "access_level"
44
    end
45
    click_button "Add users to group"
46 47
  end

48 49 50 51 52 53 54 55
  When 'I select user "johndoe@gitlab.com" from user list as "Reporter"' do
    select2('johndoe@gitlab.com', from: "#user_ids", multiple: true)
    page.within "#new_project_member" do
      select "Reporter", from: "access_level"
    end
    click_button "Add users to group"
  end

56
  step 'I should see "John Doe" in team list in every project as "Reporter"' do
57
    page.within ".group-users-list" do
58 59
      expect(page).to have_content "John Doe"
      expect(page).to have_content "Reporter"
60
    end
61 62
  end

63 64
  step 'I should see "johndoe@gitlab.com" in team list in every project as "Reporter"' do
    page.within ".group-users-list" do
65 66
      expect(page).to have_content "johndoe@gitlab.com"
      expect(page).to have_content "Invited by"
67 68 69 70
      expect(page).to have_content "Reporter"
    end
  end

71 72
  step 'I should be all groups' do
    Group.all.each do |group|
73
      expect(page).to have_content group.name
74 75 76
    end
  end

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
  step 'group has shared projects' do
    share_link = shared_project.project_group_links.new(group_access: Gitlab::Access::MASTER)
    share_link.group_id = current_group.id
    share_link.save!
  end

  step 'I visit group page' do
    visit admin_group_path(current_group)
  end

  step 'I should see project shared with group' do
    expect(page).to have_content(shared_project.name_with_namespace)
    expect(page).to have_content "Projects shared with"
  end

92
  step 'we have user "John Doe" in group' do
93
    current_group.add_reporter(user_john)
94 95 96
  end

  step 'I should not see "John Doe" in team list' do
97
    page.within ".group-users-list" do
98
      expect(page).not_to have_content "John Doe"
99 100 101
    end
  end

102 103 104 105 106 107
  step 'I select current user as "Developer"' do
    page.within ".users-group-form" do
      select2(current_user.id, from: "#user_ids", multiple: true)
      select "Developer", from: "access_level"
    end

Phil Hughes committed
108
    click_button "Add to group"
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
  end

  step 'I should see current user as "Developer"' do
    page.within '.content-list' do
      expect(page).to have_content(current_user.name)
      expect(page).to have_content('Developer')
    end
  end

  step 'I click on the "Remove User From Group" button for current user' do
    find(:css, 'li', text: current_user.name).find(:css, 'a.btn-remove').click
    # poltergeist always confirms popups.
  end

  step 'I should not see current user as "Developer"' do
    page.within '.content-list' do
      expect(page).not_to have_content(current_user.name)
      expect(page).not_to have_content('Developer')
    end
  end

130 131 132 133 134
  protected

  def current_group
    @group ||= Group.first
  end
135

136 137 138 139
  def shared_project
    @shared_project ||= create(:empty_project)
  end

140 141 142
  def user_john
    @user_john ||= User.find_by(name: "John Doe")
  end
randx committed
143
end