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
658fc330
Commit
658fc330
authored
Nov 14, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken specs plus some refactoring.
parent
50573a63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
18 deletions
+9
-18
app/models/concerns/time_trackable.rb
app/models/concerns/time_trackable.rb
+7
-17
app/services/system_note_service.rb
app/services/system_note_service.rb
+1
-1
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
No files found.
app/models/concerns/time_trackable.rb
View file @
658fc330
...
...
@@ -16,13 +16,15 @@ module TimeTrackable
has_many
:timelogs
,
as: :trackable
,
dependent: :destroy
end
def
spend_time
=
(
args
)
return
unless
valid_spend_time_args?
(
args
)
def
spend_time
=
(
seconds
:,
user
:)
# Exit if time to subtract exceeds the total time spent.
return
if
seconds
<
0
&&
(
seconds
.
abs
>
total_time_spent
)
seconds
=
args
[
:seconds
]
new_time_spent
=
seconds
.
zero?
?
-
(
total_time_spent
)
:
seconds
# When seconds = 0 we reset the total time spent by creating a new Timelog
# record with a negative value that is equal to the current total time spent.
new_time_spent
=
seconds
.
zero?
?
(
total_time_spent
*
-
1
)
:
seconds
timelogs
.
new
(
user:
args
[
:user
]
,
time_spent:
new_time_spent
)
timelogs
.
new
(
user:
user
,
time_spent:
new_time_spent
)
@time_spent
=
seconds
end
...
...
@@ -30,16 +32,4 @@ module TimeTrackable
def
total_time_spent
timelogs
.
sum
(
:time_spent
)
end
private
def
valid_spend_time_args?
(
args
)
return
false
if
[
:seconds
,
:user
].
any?
{
|
k
|
args
[
k
].
blank?
}
# time to subtract exceeds the total time spent
seconds
=
args
[
:seconds
]
return
false
if
seconds
<
0
&&
(
seconds
.
abs
>
total_time_spent
)
true
end
end
app/services/system_note_service.rb
View file @
658fc330
...
...
@@ -149,7 +149,7 @@ module SystemNoteService
# Returns the created Note object
def
change_time_spent
(
noteable
,
project
,
author
)
time_spent
=
noteable
.
time_spent
time_spent
=
noteable
.
time_spent
if
time_spent
.
zero?
body
=
"Removed time spent on this
#{
noteable
.
human_class_name
}
"
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
658fc330
...
...
@@ -353,5 +353,6 @@ Timelog:
-
time_spent
-
trackable_id
-
trackable_type
-
user_id
-
created_at
-
updated_at
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