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
02b0c37c
Commit
02b0c37c
authored
Mar 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `Todo#target`
parent
2a8858ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
app/models/todo.rb
app/models/todo.rb
+1
-5
spec/models/todo_spec.rb
spec/models/todo_spec.rb
+17
-7
No files found.
app/models/todo.rb
View file @
02b0c37c
...
...
@@ -61,14 +61,10 @@ class Todo < ActiveRecord::Base
# override to return commits, which are not active record
def
target
if
for_commit?
project
.
commit
(
commit_id
)
project
.
commit
(
commit_id
)
rescue
nil
else
super
end
# Temp fix to prevent app crash
# if note commit id doesn't exist
rescue
nil
end
def
target_reference
...
...
spec/models/todo_spec.rb
View file @
02b0c37c
...
...
@@ -99,13 +99,23 @@ describe Todo, models: true do
end
describe
'#target'
do
it
'returns an instance of Commit for commits'
do
subject
.
project
=
project
subject
.
target_type
=
'Commit'
subject
.
commit_id
=
commit
.
id
expect
(
subject
.
target
).
to
be_a
(
Commit
)
expect
(
subject
.
target
).
to
eq
commit
context
'for commits'
do
it
'returns an instance of Commit when exists'
do
subject
.
project
=
project
subject
.
target_type
=
'Commit'
subject
.
commit_id
=
commit
.
id
expect
(
subject
.
target
).
to
be_a
(
Commit
)
expect
(
subject
.
target
).
to
eq
commit
end
it
'returns nil when does not exists'
do
subject
.
project
=
project
subject
.
target_type
=
'Commit'
subject
.
commit_id
=
'xxxx'
expect
(
subject
.
target
).
to
be_nil
end
end
it
'returns the issuable for issuables'
do
...
...
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