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
iv
gitlab-ce
Commits
99fcf2e6
Commit
99fcf2e6
authored
May 01, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve/add specs for `Project#get_issue` and `#issue_exists?`
parent
66a3c428
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
20 deletions
+43
-20
app/models/project.rb
app/models/project.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+42
-19
No files found.
app/models/project.rb
View file @
99fcf2e6
...
...
@@ -338,7 +338,7 @@ class Project < ActiveRecord::Base
end
def
issue_exists?
(
issue_id
)
get_issue
(
issue_id
)
.
present?
get_issue
(
issue_id
)
end
def
default_issue_tracker
...
...
spec/models/project_spec.rb
View file @
99fcf2e6
...
...
@@ -129,6 +129,48 @@ describe Project do
end
end
describe
'#get_issue'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
context
'with default issues tracker'
do
it
'returns an issue'
do
expect
(
project
.
get_issue
(
issue
.
iid
)).
to
eq
issue
end
it
'returns nil when no issue found'
do
expect
(
project
.
get_issue
(
999
)).
to
be_nil
end
end
context
'with external issues tracker'
do
before
do
allow
(
project
).
to
receive
(
:default_issues_tracker?
).
and_return
(
false
)
end
it
'returns an ExternalIssue'
do
issue
=
project
.
get_issue
(
'FOO-1234'
)
expect
(
issue
).
to
be_kind_of
(
ExternalIssue
)
expect
(
issue
.
iid
).
to
eq
'FOO-1234'
expect
(
issue
.
project
).
to
eq
project
end
end
end
describe
'#issue_exists?'
do
let
(
:project
)
{
create
(
:empty_project
)
}
it
'is truthy when issue exists'
do
expect
(
project
).
to
receive
(
:get_issue
).
and_return
(
double
)
expect
(
project
.
issue_exists?
(
1
)).
to
be_truthy
end
it
'is falsey when issue does not exist'
do
expect
(
project
).
to
receive
(
:get_issue
).
and_return
(
nil
)
expect
(
project
.
issue_exists?
(
1
)).
to
be_falsey
end
end
describe
:update_merge_requests
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
...
...
@@ -180,25 +222,6 @@ describe Project do
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
expect
(
project
.
issue_exists?
(
existed_issue
.
iid
)).
to
be_truthy
end
it
'should be false or if used internal tracker and issue not exists'
do
expect
(
project
.
issue_exists?
(
not_existed_issue
.
iid
)).
to
be_falsey
end
it
'should always be true if used other tracker'
do
expect
(
ext_project
.
issue_exists?
(
rand
(
100
))).
to
be_truthy
end
end
describe
:default_issues_tracker?
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:ext_project
)
{
create
(
:redmine_project
)
}
...
...
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