BigW Consortium Gitlab

group.rb 1.48 KB
Newer Older
1 2 3
module SharedGroup
  include Spinach::DSL

4 5 6 7
  step 'current user is developer of group "Owned"' do
    is_member_of(current_user.name, "Owned", Gitlab::Access::DEVELOPER)
  end

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
  step '"John Doe" is owner of group "Owned"' do
    is_member_of("John Doe", "Owned", Gitlab::Access::OWNER)
  end

  step '"John Doe" is guest of group "Guest"' do
    is_member_of("John Doe", "Guest", Gitlab::Access::GUEST)
  end

  step '"Mary Jane" is owner of group "Owned"' do
    is_member_of("Mary Jane", "Owned", Gitlab::Access::OWNER)
  end

  step '"Mary Jane" is guest of group "Owned"' do
    is_member_of("Mary Jane", "Owned", Gitlab::Access::GUEST)
  end

  step '"Mary Jane" is guest of group "Guest"' do
    is_member_of("Mary Jane", "Guest", Gitlab::Access::GUEST)
  end

28
  step 'I should see group "TestGroup"' do
29
    expect(page).to have_content "TestGroup"
30 31 32
  end

  step 'I should not see group "TestGroup"' do
33
    expect(page).not_to have_content "TestGroup"
34 35
  end

36 37 38 39 40 41 42 43
  protected

  def is_member_of(username, groupname, role)
    @project_count ||= 0
    user = User.find_by(name: username) || create(:user, name: username)
    group = Group.find_by(name: groupname) || create(:group, name: groupname)
    group.add_user(user, role)
    project ||= create(:project, namespace: group, path: "project#{@project_count}")
44
    create(:closed_issue_event, project: project)
45 46 47
    project.team << [user, :master]
    @project_count += 1
  end
48 49 50 51

  def owned_group
    @owned_group ||= Group.find_by(name: "Owned")
  end
52
end