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
27e4aa5f
Commit
27e4aa5f
authored
Apr 22, 2021
by
Jason Goodman
Committed by
Vitali Tatarintev
Apr 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract Routing Logic from BillableMembership Entity
parent
95638a05
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
28 deletions
+30
-28
app/helpers/gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+10
-0
ee/lib/ee/api/entities/billable_membership.rb
ee/lib/ee/api/entities/billable_membership.rb
+2
-7
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
+0
-21
spec/helpers/gitlab_routing_helper_spec.rb
spec/helpers/gitlab_routing_helper_spec.rb
+18
-0
No files found.
app/helpers/gitlab_routing_helper.rb
View file @
27e4aa5f
...
@@ -166,6 +166,16 @@ module GitlabRoutingHelper
...
@@ -166,6 +166,16 @@ module GitlabRoutingHelper
resend_invite_group_group_member_path
(
group_member
.
source
,
group_member
)
resend_invite_group_group_member_path
(
group_member
.
source
,
group_member
)
end
end
# Members
def
source_members_url
(
member
)
case
member
.
source_type
when
'Namespace'
group_group_members_url
(
member
.
source
)
when
'Project'
project_project_members_url
(
member
.
source
)
end
end
# Artifacts
# Artifacts
# Rails path generators are slow because they need to do large regex comparisons
# Rails path generators are slow because they need to do large regex comparisons
...
...
ee/lib/ee/api/entities/billable_membership.rb
View file @
27e4aa5f
...
@@ -4,7 +4,7 @@ module EE
...
@@ -4,7 +4,7 @@ module EE
module
API
module
API
module
Entities
module
Entities
class
BillableMembership
<
Grape
::
Entity
class
BillableMembership
<
Grape
::
Entity
include
::
Gitlab
::
Routing
include
RequestAwareEntity
expose
:id
expose
:id
expose
:source_id
expose
:source_id
...
@@ -12,12 +12,7 @@ module EE
...
@@ -12,12 +12,7 @@ module EE
member
.
source
.
full_name
member
.
source
.
full_name
end
end
expose
:source_members_url
do
|
member
|
expose
:source_members_url
do
|
member
|
case
member
.
source_type
source_members_url
(
member
)
when
'Namespace'
group_group_members_url
(
member
.
source
)
when
'Project'
project_project_members_url
(
member
.
source
)
end
end
end
expose
:created_at
expose
:created_at
expose
:expires_at
expose
:expires_at
...
...
ee/spec/lib/ee/api/entities/billable_membership_spec.rb
deleted
100644 → 0
View file @
95638a05
# 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
spec/helpers/gitlab_routing_helper_spec.rb
View file @
27e4aa5f
...
@@ -113,6 +113,24 @@ RSpec.describe GitlabRoutingHelper do
...
@@ -113,6 +113,24 @@ RSpec.describe GitlabRoutingHelper do
end
end
end
end
describe
'members helpers'
do
describe
'#source_members_url'
do
it
'returns a url to the memberships page for a group membership'
do
membership
=
build_stubbed
(
:group_member
)
group_members_url
=
"http://test.host/groups/
#{
membership
.
source
.
full_path
}
/-/group_members"
expect
(
source_members_url
(
membership
)).
to
eq
(
group_members_url
)
end
it
'returns a url to the memberships page for a project membership'
do
membership
=
build_stubbed
(
:project_member
)
project_members_url
=
"http://test.host/
#{
membership
.
source
.
full_path
}
/-/project_members"
expect
(
source_members_url
(
membership
)).
to
eq
(
project_members_url
)
end
end
end
context
'artifacts'
do
context
'artifacts'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:job
)
{
create
(
:ci_build
,
project:
project
,
name:
'test:job'
,
artifacts_expire_at:
1
.
hour
.
from_now
)
}
let_it_be
(
:job
)
{
create
(
:ci_build
,
project:
project
,
name:
'test:job'
,
artifacts_expire_at:
1
.
hour
.
from_now
)
}
...
...
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