summaryrefslogtreecommitdiff
path: root/features/steps/shared/group.rb
diff options
context:
space:
mode:
authorCiro Santillli <ciro.santilli@gmail.com>2014-02-07 17:59:55 +0100
committerCiro Santillli <ciro.santilli@gmail.com>2014-02-12 15:52:53 +0100
commit439a61783d0b61bbcc8f3c9e5b828b2270a679aa (patch)
treee6a02b733ad2dea5bda94ea5ac25d333e1419589 /features/steps/shared/group.rb
parentc86553cd836b7be3948ace41ef47f85776a48a97 (diff)
downloadgitlab-ce-439a61783d0b61bbcc8f3c9e5b828b2270a679aa.tar.gz
User can leave group from group page.
Diffstat (limited to 'features/steps/shared/group.rb')
-rw-r--r--features/steps/shared/group.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/features/steps/shared/group.rb b/features/steps/shared/group.rb
new file mode 100644
index 00000000000..6b4c47312a7
--- /dev/null
+++ b/features/steps/shared/group.rb
@@ -0,0 +1,36 @@
+module SharedGroup
+ include Spinach::DSL
+
+ 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
+
+ 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}")
+ event ||= create(:closed_issue_event, project: project)
+ project.team << [user, :master]
+ @project_count += 1
+ end
+end