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
72009896
Commit
72009896
authored
Feb 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring task queue partials
parent
8673a70f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
79 deletions
+37
-79
app/helpers/tasks_helper.rb
app/helpers/tasks_helper.rb
+7
-5
app/models/task.rb
app/models/task.rb
+6
-6
app/views/dashboard/tasks/_common.html.haml
app/views/dashboard/tasks/_common.html.haml
+0
-17
app/views/dashboard/tasks/_note.html.haml
app/views/dashboard/tasks/_note.html.haml
+0
-26
app/views/dashboard/tasks/_task.html.haml
app/views/dashboard/tasks/_task.html.haml
+19
-6
spec/models/task_spec.rb
spec/models/task_spec.rb
+5
-19
No files found.
app/helpers/tasks_helper.rb
View file @
72009896
...
...
@@ -23,18 +23,20 @@ module TasksHelper
[
task
.
action_name
,
target
].
join
(
" "
)
end
def
task_
note
_link_html
(
task
)
link_to
task_
note_
target_path
(
task
)
do
def
task_
target
_link_html
(
task
)
link_to
task_target_path
(
task
)
do
"#
#{
task
.
target_iid
}
"
end
end
def
task_note_target_path
(
task
)
def
task_target_path
(
task
)
anchor
=
dom_id
(
task
.
note
)
if
task
.
note
.
present?
polymorphic_path
([
task
.
project
.
namespace
.
becomes
(
Namespace
),
task
.
project
,
task
.
target
],
anchor:
dom_id
(
task
.
note
)
)
task
.
project
,
task
.
target
],
anchor:
anchor
)
end
def
task_
note
(
text
,
options
=
{})
def
task_
body
(
text
,
options
=
{})
text
=
first_line_in_markdown
(
text
,
150
,
options
)
sanitize
(
text
,
tags:
%w(a img b pre code p span)
)
end
...
...
app/models/task.rb
View file @
72009896
...
...
@@ -50,12 +50,12 @@ class Task < ActiveRecord::Base
end
end
def
body
?
target
.
respond_to?
:title
end
def
note_text
note
.
try
(
:note
)
def
body
if
note
.
present?
note
.
note
else
target
.
title
end
end
def
target_iid
...
...
app/views/dashboard/tasks/_common.html.haml
deleted
100644 → 0
View file @
8673a70f
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
{
class:
task
.
action_name
}
=
task_action_name
(
task
)
%strong
=
link_to
"#
#{
task
.
target_iid
}
"
,
[
task
.
project
.
namespace
.
becomes
(
Namespace
),
task
.
project
,
task
.
target
]
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
-
if
task
.
body?
.task-body
.task-note
=
task
.
target
.
title
app/views/dashboard/tasks/_note.html.haml
deleted
100644 → 0
View file @
8673a70f
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
{
class:
task
.
action_name
}
=
task_action_name
(
task
)
=
task_note_link_html
(
task
)
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
.task-body
.task-note
.md
=
task_note
(
task
.
note_text
,
project:
task
.
project
)
-
note
=
task
.
note
-
if
note
.
attachment
.
url
-
if
note
.
attachment
.
image?
=
link_to
note
.
attachment
.
url
,
target:
'_blank'
do
=
image_tag
note
.
attachment
.
url
,
class:
'note-image-attach'
-
else
=
link_to
note
.
attachment
.
url
,
target:
"_blank"
,
class:
'note-file-attach'
do
%i
.fa.fa-paperclip
=
note
.
attachment_identifier
app/views/dashboard/tasks/_task.html.haml
View file @
72009896
%li
{
class:
"task task-#{task.done? ? 'done' : 'pending'}"
,
id:
dom_id
(
task
)
}
.task-item
{
class:
"#{task.body? ? 'task-block' : 'task-inline' }"
}
=
image_tag
avatar_icon
(
task
.
author_email
,
40
),
class:
"avatar s40"
,
alt
:''
.task-item
{
class:
'task-block'
}
=
image_tag
avatar_icon
(
task
.
author_email
,
40
),
class:
'avatar s40'
,
alt
:''
-
if
task
.
note
.
present?
=
render
'note'
,
task:
task
-
else
=
render
'common'
,
task:
task
.task-title
%span
.author_name
=
link_to_author
task
%span
.task_label
=
task_action_name
(
task
)
=
task_target_link_html
(
task
)
·
#{
time_ago_with_tooltip
(
task
.
created_at
)
}
-
if
task
.
pending?
.task-actions.pull-right
=
link_to
'Done'
,
[
:dashboard
,
task
],
method: :delete
,
class:
'btn'
.task-body
.task-note
.md
=
task_body
(
task
.
body
,
project:
task
.
project
)
spec/models/task_spec.rb
View file @
72009896
...
...
@@ -51,35 +51,21 @@ describe Task, models: true do
end
end
describe
'#body?'
do
let
(
:issue
)
{
build
(
:issue
)
}
describe
'#body'
do
before
do
subject
.
target
=
issue
end
it
'returns true when target respond to title'
do
expect
(
subject
.
body?
).
to
eq
true
subject
.
target
=
build
(
:issue
,
title:
'Bugfix'
)
end
it
'returns false when target does not respond to title'
do
allow
(
issue
).
to
receive
(
:respond_to?
).
with
(
:title
).
and_return
(
false
)
expect
(
subject
.
body?
).
to
eq
false
end
end
describe
'#note_text'
do
it
'returns nil when note is blank'
do
it
'returns target title when note is blank'
do
subject
.
note
=
nil
expect
(
subject
.
note_text
).
to
be_nil
expect
(
subject
.
body
).
to
eq
'Bugfix'
end
it
'returns note when note is present'
do
subject
.
note
=
build
(
:note
,
note:
'quick fix'
)
expect
(
subject
.
note_text
).
to
eq
'quick fix'
expect
(
subject
.
body
).
to
eq
'quick fix'
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