debian-mirror-gitlab/features/steps/shared/group.rb

51 lines
1.4 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module SharedGroup
include Spinach::DSL
2015-12-23 02:04:40 +05:30
step 'current user is developer of group "Owned"' do
is_member_of(current_user.name, "Owned", Gitlab::Access::DEVELOPER)
end
2014-09-02 18:07:02 +05:30
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
step 'I should see group "TestGroup"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "TestGroup"
2014-09-02 18:07:02 +05:30
end
step 'I should not see group "TestGroup"' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content "TestGroup"
2014-09-02 18:07:02 +05:30
end
protected
def is_member_of(username, groupname, role)
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)
2017-09-10 17:25:29 +05:30
project ||= create(:project, :repository, namespace: group)
2015-10-24 18:46:33 +05:30
create(:closed_issue_event, project: project)
2018-03-17 18:26:18 +05:30
project.add_master(user)
2014-09-02 18:07:02 +05:30
end
2015-12-23 02:04:40 +05:30
def owned_group
@owned_group ||= Group.find_by(name: "Owned")
end
2014-09-02 18:07:02 +05:30
end