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
785d891b
Commit
785d891b
authored
Jun 29, 2020
by
Andy Soiron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'remove_gitlab_issue_tracker_service_class' into 'master'"
This reverts merge request !34852
parent
3a6952c2
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
120 additions
and
3 deletions
+120
-3
app/models/project.rb
app/models/project.rb
+1
-0
app/models/project_services/gitlab_issue_tracker_service.rb
app/models/project_services/gitlab_issue_tracker_service.rb
+45
-0
app/models/service.rb
app/models/service.rb
+3
-1
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+1
-1
lib/banzai/filter/issue_reference_filter.rb
lib/banzai/filter/issue_reference_filter.rb
+4
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/factories/services.rb
spec/factories/services.rb
+6
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/project_services/gitlab_issue_tracker_service_spec.rb
...els/project_services/gitlab_issue_tracker_service_spec.rb
+54
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-0
spec/models/service_spec.rb
spec/models/service_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
785d891b
...
...
@@ -167,6 +167,7 @@ class Project < ApplicationRecord
has_one
:youtrack_service
has_one
:custom_issue_tracker_service
has_one
:bugzilla_service
has_one
:gitlab_issue_tracker_service
,
inverse_of: :project
has_one
:external_wiki_service
has_one
:prometheus_service
,
inverse_of: :project
has_one
:mock_ci_service
...
...
app/models/project_services/gitlab_issue_tracker_service.rb
0 → 100644
View file @
785d891b
# frozen_string_literal: true
class
GitlabIssueTrackerService
<
IssueTrackerService
include
Gitlab
::
Routing
validates
:project_url
,
:issues_url
,
:new_issue_url
,
presence:
true
,
public_url:
true
,
if: :activated?
default_value_for
:default
,
true
def
title
'GitLab'
end
def
description
s_
(
'IssueTracker|GitLab issue tracker'
)
end
def
self
.
to_param
'gitlab'
end
def
project_url
project_issues_url
(
project
)
end
def
new_issue_url
new_project_issue_url
(
project
)
end
def
issue_url
(
iid
)
project_issue_url
(
project
,
id:
iid
)
end
def
issue_tracker_path
project_issues_path
(
project
)
end
def
new_issue_path
new_project_issue_path
(
project
)
end
def
issue_path
(
iid
)
project_issue_path
(
project
,
id:
iid
)
end
end
app/models/service.rb
View file @
785d891b
...
...
@@ -55,9 +55,11 @@ class Service < ApplicationRecord
validates
:instance
,
uniqueness:
{
scope: :type
},
if:
->
{
instance?
}
validate
:validate_is_instance_or_template
scope
:visible
,
->
{
where
.
not
(
type:
'GitlabIssueTrackerService'
)
}
scope
:issue_trackers
,
->
{
where
(
category:
'issue_tracker'
)
}
scope
:external_wikis
,
->
{
where
(
type:
'ExternalWikiService'
).
active
}
scope
:active
,
->
{
where
(
active:
true
)
}
scope
:without_defaults
,
->
{
where
(
default:
false
)
}
scope
:by_type
,
->
(
type
)
{
where
(
type:
type
)
}
scope
:by_active_flag
,
->
(
flag
)
{
where
(
active:
flag
)
}
scope
:templates
,
->
{
where
(
template:
true
,
type:
available_services_types
)
}
...
...
@@ -75,7 +77,7 @@ class Service < ApplicationRecord
scope
:wiki_page_hooks
,
->
{
where
(
wiki_page_events:
true
,
active:
true
)
}
scope
:deployment_hooks
,
->
{
where
(
deployment_events:
true
,
active:
true
)
}
scope
:alert_hooks
,
->
{
where
(
alert_events:
true
,
active:
true
)
}
scope
:external_issue_trackers
,
->
{
issue_trackers
.
active
}
scope
:external_issue_trackers
,
->
{
issue_trackers
.
active
.
without_defaults
}
scope
:deployment
,
->
{
where
(
category:
'deployment'
)
}
default_value_for
:category
,
'common'
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
785d891b
...
...
@@ -169,7 +169,7 @@ module EE
merge_requests_with_optional_codeowners:
distinct_count
(
::
ApprovalMergeRequestRule
.
code_owner_approval_optional
,
:merge_request_id
),
merge_requests_with_required_codeowners:
distinct_count
(
::
ApprovalMergeRequestRule
.
code_owner_approval_required
,
:merge_request_id
),
projects_mirrored_with_pipelines_enabled:
count
(
::
Project
.
mirrored_with_enabled_pipelines
),
projects_reporting_ci_cd_back_to_github:
count
(
::
GithubService
.
active
),
projects_reporting_ci_cd_back_to_github:
count
(
::
GithubService
.
without_defaults
.
active
),
projects_with_packages:
distinct_count
(
::
Packages
::
Package
,
:project_id
),
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
),
status_page_projects:
count
(
::
StatusPage
::
ProjectSetting
.
enabled
),
...
...
lib/banzai/filter/issue_reference_filter.rb
View file @
785d891b
...
...
@@ -23,6 +23,10 @@ module Banzai
issue_url
(
issue
,
project
)
end
def
projects_relation_for_paths
(
paths
)
super
(
paths
).
includes
(
:gitlab_issue_tracker_service
)
end
def
parent_records
(
parent
,
ids
)
parent
.
issues
.
where
(
iid:
ids
.
to_a
)
end
...
...
locale/gitlab.pot
View file @
785d891b
...
...
@@ -12599,6 +12599,9 @@ msgstr ""
msgid "IssueTracker|Custom issue tracker"
msgstr ""
msgid "IssueTracker|GitLab issue tracker"
msgstr ""
msgid "IssueTracker|Redmine issue tracker"
msgstr ""
...
...
spec/factories/services.rb
View file @
785d891b
...
...
@@ -107,6 +107,12 @@ FactoryBot.define do
issue_tracker
end
factory
:gitlab_issue_tracker_service
do
project
active
{
true
}
issue_tracker
end
trait
:issue_tracker
do
transient
do
create_data
{
true
}
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
785d891b
...
...
@@ -350,6 +350,7 @@ project:
-
youtrack_service
-
custom_issue_tracker_service
-
bugzilla_service
-
gitlab_issue_tracker_service
-
external_wiki_service
-
mock_ci_service
-
mock_deployment_service
...
...
spec/models/project_services/gitlab_issue_tracker_service_spec.rb
0 → 100644
View file @
785d891b
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
GitlabIssueTrackerService
do
describe
"Associations"
do
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
have_one
:service_hook
}
end
describe
'Validations'
do
context
'when service is active'
do
subject
{
described_class
.
new
(
project:
create
(
:project
),
active:
true
)
}
it
{
is_expected
.
to
validate_presence_of
(
:issues_url
)
}
it_behaves_like
'issue tracker service URL attribute'
,
:issues_url
end
context
'when service is inactive'
do
subject
{
described_class
.
new
(
project:
create
(
:project
),
active:
false
)
}
it
{
is_expected
.
not_to
validate_presence_of
(
:issues_url
)
}
end
end
describe
'project and issue urls'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:service
)
{
project
.
create_gitlab_issue_tracker_service
(
active:
true
)
}
context
'with absolute urls'
do
before
do
allow
(
described_class
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
end
it
'gives the correct path'
do
expect
(
service
.
project_url
).
to
eq
(
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/gitlab/root/
#{
project
.
full_path
}
/-/issues"
)
expect
(
service
.
new_issue_url
).
to
eq
(
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/gitlab/root/
#{
project
.
full_path
}
/-/issues/new"
)
expect
(
service
.
issue_url
(
432
)).
to
eq
(
"http://
#{
Gitlab
.
config
.
gitlab
.
host
}
/gitlab/root/
#{
project
.
full_path
}
/-/issues/432"
)
end
end
context
'with relative urls'
do
before
do
allow
(
described_class
).
to
receive
(
:default_url_options
).
and_return
(
script_name:
"/gitlab/root"
)
end
it
'gives the correct path'
do
expect
(
service
.
issue_tracker_path
).
to
eq
(
"/gitlab/root/
#{
project
.
full_path
}
/-/issues"
)
expect
(
service
.
new_issue_path
).
to
eq
(
"/gitlab/root/
#{
project
.
full_path
}
/-/issues/new"
)
expect
(
service
.
issue_path
(
432
)).
to
eq
(
"/gitlab/root/
#{
project
.
full_path
}
/-/issues/432"
)
end
end
end
end
spec/models/project_spec.rb
View file @
785d891b
...
...
@@ -61,6 +61,7 @@ RSpec.describe Project do
it
{
is_expected
.
to
have_one
(
:youtrack_service
)
}
it
{
is_expected
.
to
have_one
(
:custom_issue_tracker_service
)
}
it
{
is_expected
.
to
have_one
(
:bugzilla_service
)
}
it
{
is_expected
.
to
have_one
(
:gitlab_issue_tracker_service
)
}
it
{
is_expected
.
to
have_one
(
:external_wiki_service
)
}
it
{
is_expected
.
to
have_one
(
:project_feature
)
}
it
{
is_expected
.
to
have_one
(
:project_repository
)
}
...
...
spec/models/service_spec.rb
View file @
785d891b
...
...
@@ -508,7 +508,7 @@ RSpec.describe Service do
describe
'initialize service with no properties'
do
let
(
:service
)
do
Bugzilla
Service
.
create
(
GitlabIssueTracker
Service
.
create
(
project:
create
(
:project
),
project_url:
'http://gitlab.example.com'
)
...
...
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