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
68a7ecda
Commit
68a7ecda
authored
Feb 11, 2013
by
Andrew8xx8
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Project issue tracker functions refactored
parent
999fc239
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
29 deletions
+52
-29
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+2
-12
app/models/project.rb
app/models/project.rb
+12
-0
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+1
-1
spec/factories.rb
spec/factories.rb
+4
-0
spec/lib/issues_tracker_spec.rb
spec/lib/issues_tracker_spec.rb
+0
-16
spec/models/project_spec.rb
spec/models/project_spec.rb
+33
-0
No files found.
app/helpers/issues_helper.rb
View file @
68a7ecda
...
...
@@ -42,7 +42,7 @@ module IssuesHelper
end
def
url_for_issue
(
issue_id
)
if
@project
.
issues_tracker
==
Project
.
issues_tracker
.
default_value
if
@project
.
used_default_issues_tracker?
url
=
project_issue_url
project_id:
@project
,
id:
issue_id
else
url
=
Settings
[
:issues_tracker
][
@project
.
issues_tracker
][
"issues_url"
]
...
...
@@ -51,20 +51,10 @@ module IssuesHelper
end
def
title_for_issue
(
issue_id
)
if
issue
=
@project
.
issues
.
where
(
id:
issue_id
).
first
if
@project
.
used_default_issues_tracker?
&&
issue
=
@project
.
issues
.
where
(
id:
issue_id
).
first
issue
.
title
else
""
end
end
def
issue_exists?
(
issue_id
)
return
false
if
@project
.
nil?
if
@project
.
issues_tracker
==
Project
.
issues_tracker
.
default_value
@project
.
issues
.
where
(
id:
issue_id
).
first
.
present?
else
true
end
end
end
app/models/project.rb
View file @
68a7ecda
...
...
@@ -205,6 +205,18 @@ class Project < ActiveRecord::Base
issues
.
tag_counts_on
(
:labels
)
end
def
issue_exists?
(
issue_id
)
if
used_default_issues_tracker?
self
.
issues
.
where
(
id:
issue_id
).
first
.
present?
else
true
end
end
def
used_default_issues_tracker?
self
.
issues_tracker
==
Project
.
issues_tracker
.
default_value
end
def
services
[
gitlab_ci_service
].
compact
end
...
...
lib/gitlab/markdown.rb
View file @
68a7ecda
...
...
@@ -163,7 +163,7 @@ module Gitlab
end
def
reference_issue
(
identifier
)
if
issue_exists?
identifier
if
@project
.
issue_exists?
identifier
url
=
url_for_issue
(
identifier
)
title
=
title_for_issue
(
identifier
)
...
...
spec/factories.rb
View file @
68a7ecda
...
...
@@ -29,6 +29,10 @@ FactoryGirl.define do
creator
end
factory
:redmine_project
,
parent: :project
do
issues_tracker
{
"redmine"
}
end
factory
:group
do
sequence
(
:name
)
{
|
n
|
"group
#{
n
}
"
}
path
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
...
...
spec/lib/issues_tracker_spec.rb
deleted
100644 → 0
View file @
999fc239
require
'spec_helper'
describe
IssuesTracker
do
let
(
:project
)
{
double
(
'project'
)
}
before
do
@project
=
project
project
.
stub
(
repository:
stub
(
ref_names:
[
'master'
,
'foo/bar/baz'
,
'v1.0.0'
,
'v2.0.0'
]))
project
.
stub
(
path_with_namespace:
'gitlab/gitlab-ci'
)
end
it
'returns url for issue'
do
ololo
end
end
spec/models/project_spec.rb
View file @
68a7ecda
...
...
@@ -190,4 +190,37 @@ describe Project do
Project
.
new
(
path:
"empty"
).
repository
.
should
be_nil
end
end
describe
:issue_exists?
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:existed_issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:not_existed_issue
)
{
create
(
:issue
)
}
let
(
:ext_project
)
{
create
(
:redmine_project
)
}
it
"should be true or if used internal tracker and issue exists"
do
project
.
issue_exists?
(
existed_issue
.
id
).
should
be_true
end
it
"should be false or if used internal tracker and issue not exists"
do
project
.
issue_exists?
(
not_existed_issue
.
id
).
should
be_false
end
it
"should always be true if used other tracker"
do
ext_project
.
issue_exists?
(
rand
(
100
)).
should
be_true
end
end
describe
:used_default_issues_tracker?
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:ext_project
)
{
create
(
:redmine_project
)
}
it
"should be true if used internal tracker"
do
project
.
used_default_issues_tracker?
.
should
be_true
end
it
"should be false if used other tracker"
do
ext_project
.
used_default_issues_tracker?
.
should
be_false
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