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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2abb48ad
Commit
2abb48ad
authored
Apr 13, 2021
by
Jason Goodman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add source members url to billable memberships api
Link to group or project memberships page
parent
dc1f0ae2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
ee/lib/ee/api/entities/billable_membership.rb
ee/lib/ee/api/entities/billable_membership.rb
+10
-0
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
+21
-0
ee/spec/requests/api/members_spec.rb
ee/spec/requests/api/members_spec.rb
+1
-0
No files found.
ee/lib/ee/api/entities/billable_membership.rb
View file @
2abb48ad
...
@@ -4,11 +4,21 @@ module EE
...
@@ -4,11 +4,21 @@ module EE
module
API
module
API
module
Entities
module
Entities
class
BillableMembership
<
Grape
::
Entity
class
BillableMembership
<
Grape
::
Entity
include
::
Gitlab
::
Routing
expose
:id
expose
:id
expose
:source_id
expose
:source_id
expose
:source_full_name
do
|
member
|
expose
:source_full_name
do
|
member
|
member
.
source
.
full_name
member
.
source
.
full_name
end
end
expose
:source_members_url
do
|
member
|
case
member
.
source_type
when
'Namespace'
group_group_members_url
(
member
.
source
)
when
'Project'
project_project_members_url
(
member
.
source
)
end
end
expose
:created_at
expose
:created_at
expose
:expires_at
expose
:expires_at
expose
:access_level
do
expose
:access_level
do
...
...
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
0 → 100644
View file @
2abb48ad
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
::
EE
::
API
::
Entities
::
BillableMembership
do
describe
'#as_json'
do
it
'returns source_members_url for a group'
do
membership
=
create
(
:group_member
)
group_members_url
=
Gitlab
::
Routing
.
url_helpers
.
group_group_members_url
(
membership
.
source
)
expect
(
described_class
.
new
(
membership
).
as_json
[
:source_members_url
]).
to
eq
(
group_members_url
)
end
it
'returns source_members_url for a project'
do
membership
=
create
(
:project_member
)
project_members_url
=
Gitlab
::
Routing
.
url_helpers
.
project_project_members_url
(
membership
.
source
)
expect
(
described_class
.
new
(
membership
).
as_json
[
:source_members_url
]).
to
eq
(
project_members_url
)
end
end
end
ee/spec/requests/api/members_spec.rb
View file @
2abb48ad
...
@@ -522,6 +522,7 @@ RSpec.describe API::Members do
...
@@ -522,6 +522,7 @@ RSpec.describe API::Members do
'id'
=>
membership
.
id
,
'id'
=>
membership
.
id
,
'source_id'
=>
group
.
id
,
'source_id'
=>
group
.
id
,
'source_full_name'
=>
group
.
full_name
,
'source_full_name'
=>
group
.
full_name
,
'source_members_url'
=>
group_group_members_url
(
group
),
'created_at'
=>
membership
.
created_at
.
as_json
,
'created_at'
=>
membership
.
created_at
.
as_json
,
'expires_at'
=>
nil
,
'expires_at'
=>
nil
,
'access_level'
=>
{
'access_level'
=>
{
...
...
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