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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
33913f9b
Commit
33913f9b
authored
Jan 26, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make issue tracker service fields required.
parent
00a0d5ae
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
4 deletions
+91
-4
app/models/project.rb
app/models/project.rb
+1
-1
app/models/project_services/issue_tracker_service.rb
app/models/project_services/issue_tracker_service.rb
+4
-0
spec/factories/projects.rb
spec/factories/projects.rb
+3
-3
spec/models/jira_service_spec.rb
spec/models/jira_service_spec.rb
+83
-0
No files found.
app/models/project.rb
View file @
33913f9b
...
...
@@ -319,7 +319,7 @@ class Project < ActiveRecord::Base
end
def
external_issues_trackers
services
.
select
{
|
service
|
service
.
category
==
:issue_tracker
}
services
.
select
{
|
service
|
service
.
issue_tracker?
}
end
def
external_issue_tracker
...
...
app/models/project_services/issue_tracker_service.rb
View file @
33913f9b
class
IssueTrackerService
<
Service
validates
:project_url
,
:issues_url
,
:new_issue_url
,
presence:
true
,
if: :activated?
def
category
:issue_tracker
end
...
...
@@ -34,6 +36,8 @@ class IssueTrackerService < Service
issues_url:
issues_tracker
[
'issues_url'
],
new_issue_url:
issues_tracker
[
'new_issue_url'
]
}
else
self
.
properties
=
{}
end
end
end
...
...
spec/factories/projects.rb
View file @
33913f9b
...
...
@@ -80,9 +80,9 @@ FactoryGirl.define do
project
.
create_redmine_service
(
active:
true
,
properties:
{
project_url:
'http://redmine/projects/project_name_in_redmine'
,
issues_url:
"http://redmine/
#{
project
.
id
}
/project_name_in_redmine/:id"
,
new_issue_url:
'http://redmine/projects/project_name_in_redmine/issues/new'
'project_url'
=>
'http://redmine/projects/project_name_in_redmine'
,
'issues_url'
=>
"http://redmine/
#{
project
.
id
}
/project_name_in_redmine/:id"
,
'new_issue_url'
=>
'http://redmine/projects/project_name_in_redmine/issues/new'
}
)
end
...
...
spec/models/jira_service_spec.rb
0 → 100644
View file @
33913f9b
require
'spec_helper'
describe
JiraService
do
describe
"Associations"
do
it
{
should
belong_to
:project
}
it
{
should
have_one
:service_hook
}
end
describe
"Validations"
do
context
"active"
do
before
do
subject
.
active
=
true
end
it
{
should
validate_presence_of
:project_url
}
it
{
should
validate_presence_of
:issues_url
}
it
{
should
validate_presence_of
:new_issue_url
}
end
end
describe
'description and title'
do
let
(
:project
)
{
create
(
:project
)
}
context
'when it is not set'
do
before
do
@service
=
project
.
create_jira_service
(
active:
true
)
end
after
do
@service
.
destroy!
end
it
'should be initialized'
do
expect
(
@service
.
title
).
to
eq
(
'JIRA'
)
expect
(
@service
.
description
).
to
eq
(
"Jira issue tracker"
)
end
end
context
'when it is set'
do
before
do
properties
=
{
'title'
=>
'Jira One'
,
'description'
=>
'Jira One issue tracker'
}
@service
=
project
.
create_jira_service
(
active:
true
,
properties:
properties
)
end
after
do
@service
.
destroy!
end
it
"should be correct"
do
expect
(
@service
.
title
).
to
eq
(
'Jira One'
)
expect
(
@service
.
description
).
to
eq
(
'Jira One issue tracker'
)
end
end
end
describe
'project and issue urls'
do
let
(
:project
)
{
create
(
:project
)
}
context
'when gitlab.yml was initialized'
do
before
do
settings
=
{
"jira"
=>
{
"title"
=>
"Jira"
,
"project_url"
=>
"http://jira.sample/projects/project_a"
,
"issues_url"
=>
"http://jira.sample/issues/:id"
,
"new_issue_url"
=>
"http://jira.sample/projects/project_a/issues/new"
}
}
Gitlab
.
config
.
stub
(
:issues_tracker
).
and_return
(
settings
)
@service
=
project
.
create_jira_service
(
active:
true
)
end
after
do
@service
.
destroy!
end
it
'should be prepopulated with the settings'
do
expect
(
@service
.
properties
[
:project_url
]).
to
eq
(
'http://jira.sample/projects/project_a'
)
expect
(
@service
.
properties
[
:issues_url
]).
to
eq
(
"http://jira.sample/issues/:id"
)
expect
(
@service
.
properties
[
:new_issue_url
]).
to
eq
(
"http://jira.sample/projects/project_a/issues/new"
)
end
end
end
end
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