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
Jérome Perrin
gitlab-ce
Commits
2088cee9
Commit
2088cee9
authored
9 years ago
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix URL builder to use GitlabRoutingHelper
parent
abc69c89
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
lib/gitlab/url_builder.rb
lib/gitlab/url_builder.rb
+7
-11
spec/lib/gitlab/url_builder_spec.rb
spec/lib/gitlab/url_builder_spec.rb
+1
-1
No files found.
lib/gitlab/url_builder.rb
View file @
2088cee9
module
Gitlab
class
UrlBuilder
include
Rails
.
application
.
routes
.
url_helpers
include
GitlabRoutingHelper
def
initialize
(
type
)
@type
=
type
...
...
@@ -9,27 +10,22 @@ module Gitlab
def
build
(
id
)
case
@type
when
:issue
issue_url
(
id
)
build_
issue_url
(
id
)
when
:merge_request
merge_request_url
(
id
)
build_
merge_request_url
(
id
)
end
end
private
def
issue_url
(
id
)
def
build_
issue_url
(
id
)
issue
=
Issue
.
find
(
id
)
namespace_project_issue_url
(
namespace_id:
issue
.
project
.
namespace
,
id:
issue
.
iid
,
project_id:
issue
.
project
,
host:
Gitlab
.
config
.
gitlab
[
'url'
])
issue_url
(
issue
,
host:
Gitlab
.
config
.
gitlab
[
'url'
])
end
def
merge_request_url
(
id
)
def
build_
merge_request_url
(
id
)
merge_request
=
MergeRequest
.
find
(
id
)
project_merge_request_url
(
id:
merge_request
.
id
,
project_id:
merge_request
.
project
,
host:
Gitlab
.
config
.
gitlab
[
'url'
])
merge_request_url
(
merge_request
,
host:
Gitlab
.
config
.
gitlab
[
'url'
])
end
end
end
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/url_builder_spec.rb
View file @
2088cee9
...
...
@@ -13,7 +13,7 @@ describe Gitlab::UrlBuilder do
it
'returns the merge request url'
do
merge_request
=
create
(
:merge_request
)
url
=
Gitlab
::
UrlBuilder
.
new
(
:merge_request
).
build
(
merge_request
.
id
)
expect
(
url
).
to
eq
"
#{
Settings
.
gitlab
[
'url'
]
}
/
#{
merge_request
.
project
.
to_param
}
/merge_requests/
#{
merge_request
.
id
}
"
expect
(
url
).
to
eq
"
#{
Settings
.
gitlab
[
'url'
]
}
/
#{
merge_request
.
project
.
path_with_namespace
}
/merge_requests/
#{
merge_request
.
i
id
}
"
end
end
end
This diff is collapsed.
Click to expand it.
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