Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
f6dc2754d265
Commit
f6dc2754
authored
May 01, 2015
by
Robert Speicher
Browse files
Improve/add specs for `Project#get_issue` and `#issue_exists?`
parent
7acf2756714a
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/project.rb
View file @
f6dc2754
...
...
@@ -338,7 +338,7 @@
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 @
f6dc2754
...
...
@@ -129,6 +129,48 @@
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 @@
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
Supports
Markdown
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