Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
29cb161e
Commit
29cb161e
authored
Sep 19, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-add the AccessRequestable concern
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
178e2758
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
15 deletions
+55
-15
app/models/concerns/access_requestable.rb
app/models/concerns/access_requestable.rb
+13
-0
app/models/group.rb
app/models/group.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-0
spec/models/concerns/access_requestable_spec.rb
spec/models/concerns/access_requestable_spec.rb
+40
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+0
-7
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-8
No files found.
app/models/concerns/access_requestable.rb
0 → 100644
View file @
29cb161e
# == AccessRequestable concern
#
# Contains functionality related to objects that can receive request for access.
#
# Used by Project, and Group.
#
module
AccessRequestable
extend
ActiveSupport
::
Concern
def
request_access
(
user
)
Members
::
RequestAccessService
.
new
(
self
,
user
).
execute
end
end
app/models/group.rb
View file @
29cb161e
...
@@ -3,6 +3,7 @@ require 'carrierwave/orm/activerecord'
...
@@ -3,6 +3,7 @@ require 'carrierwave/orm/activerecord'
class
Group
<
Namespace
class
Group
<
Namespace
include
Gitlab
::
ConfigHelper
include
Gitlab
::
ConfigHelper
include
Gitlab
::
VisibilityLevel
include
Gitlab
::
VisibilityLevel
include
AccessRequestable
include
Referable
include
Referable
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
has_many
:group_members
,
->
{
where
(
requested_at:
nil
)
},
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
...
...
app/models/project.rb
View file @
29cb161e
...
@@ -5,6 +5,7 @@ class Project < ActiveRecord::Base
...
@@ -5,6 +5,7 @@ class Project < ActiveRecord::Base
include
Gitlab
::
ShellAdapter
include
Gitlab
::
ShellAdapter
include
Gitlab
::
VisibilityLevel
include
Gitlab
::
VisibilityLevel
include
Gitlab
::
CurrentSettings
include
Gitlab
::
CurrentSettings
include
AccessRequestable
include
Referable
include
Referable
include
Sortable
include
Sortable
include
AfterCommitQueue
include
AfterCommitQueue
...
...
spec/models/concerns/access_requestable_spec.rb
0 → 100644
View file @
29cb161e
require
'spec_helper'
describe
AccessRequestable
do
describe
'Group'
do
describe
'#request_access'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
it
{
expect
(
group
.
request_access
(
user
)).
to
be_a
(
GroupMember
)
}
it
{
expect
(
group
.
request_access
(
user
).
user
).
to
eq
(
user
)
}
end
describe
'#access_requested?'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
before
{
group
.
request_access
(
user
)
}
it
{
expect
(
group
.
requesters
.
exists?
(
user_id:
user
)).
to
be_truthy
}
end
end
describe
'Project'
do
describe
'#request_access'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
it
{
expect
(
project
.
request_access
(
user
)).
to
be_a
(
ProjectMember
)
}
end
describe
'#access_requested?'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
before
{
project
.
request_access
(
user
)
}
it
{
expect
(
project
.
requesters
.
exists?
(
user_id:
user
)).
to
be_truthy
}
end
end
end
spec/models/group_spec.rb
View file @
29cb161e
...
@@ -105,13 +105,6 @@ describe Group, models: true do
...
@@ -105,13 +105,6 @@ describe Group, models: true do
it
{
expect
(
group
.
human_name
).
to
eq
(
group
.
name
)
}
it
{
expect
(
group
.
human_name
).
to
eq
(
group
.
name
)
}
end
end
describe
'#request_access'
do
let
(
:user
)
{
create
(
:user
)
}
it
{
expect
(
group
.
request_access
(
user
)).
to
be_a
(
GroupMember
)
}
it
{
expect
(
group
.
request_access
(
user
).
user
).
to
eq
(
user
)
}
end
describe
'#add_user'
do
describe
'#add_user'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
{
group
.
add_user
(
user
,
GroupMember
::
MASTER
)
}
before
{
group
.
add_user
(
user
,
GroupMember
::
MASTER
)
}
...
...
spec/models/project_spec.rb
View file @
29cb161e
...
@@ -942,14 +942,6 @@ describe Project, models: true do
...
@@ -942,14 +942,6 @@ describe Project, models: true do
end
end
end
end
describe
'#request_access'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
it
{
expect
(
project
.
request_access
(
user
)).
to
be_a
(
ProjectMember
)
}
it
{
expect
(
project
.
request_access
(
user
).
user
).
to
eq
(
user
)
}
end
describe
'.search'
do
describe
'.search'
do
let
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
let
(
:project
)
{
create
(
:project
,
description:
'kitten mittens'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment