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
eece1e65
Commit
eece1e65
authored
May 10, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-05-10
# Conflicts: # lib/gitlab/git/repository.rb [ci skip]
parents
05f9e7ac
3016cf26
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
93 additions
and
74 deletions
+93
-74
app/models/concerns/time_trackable.rb
app/models/concerns/time_trackable.rb
+6
-0
changelogs/unreleased/45442-updates-updated-at-to-issue-on-time-spent.yml
...eased/45442-updates-updated-at-to-issue-on-time-spent.yml
+5
-0
ee/app/controllers/ee/ldap/omniauth_callbacks_controller.rb
ee/app/controllers/ee/ldap/omniauth_callbacks_controller.rb
+0
-22
ee/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
...ec/controllers/ldap/omniauth_callbacks_controller_spec.rb
+0
-29
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+25
-0
qa/qa/page/project/job/show.rb
qa/qa/page/project/job/show.rb
+16
-6
qa/qa/specs/features/project/deploy_key_clone_spec.rb
qa/qa/specs/features/project/deploy_key_clone_spec.rb
+4
-8
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+15
-3
spec/support/api/time_tracking_shared_examples.rb
spec/support/api/time_tracking_shared_examples.rb
+22
-6
No files found.
app/models/concerns/time_trackable.rb
View file @
eece1e65
...
...
@@ -30,6 +30,8 @@ module TimeTrackable
return
if
@time_spent
==
0
touch
if
touchable?
if
@time_spent
==
:reset
reset_spent_time
else
...
...
@@ -53,6 +55,10 @@ module TimeTrackable
private
def
touchable?
valid?
&&
persisted?
end
def
reset_spent_time
timelogs
.
new
(
time_spent:
total_time_spent
*
-
1
,
user:
@time_spent_user
)
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
...
...
changelogs/unreleased/45442-updates-updated-at-to-issue-on-time-spent.yml
0 → 100644
View file @
eece1e65
---
title
:
Updates updated_at on issuable when setting time spent
merge_request
:
18757
author
:
Jacopo Beschi @jacopo-beschi
type
:
added
ee/app/controllers/ee/ldap/omniauth_callbacks_controller.rb
deleted
100644 → 0
View file @
05f9e7ac
module
EE
module
Ldap
module
OmniauthCallbacksController
extend
::
Gitlab
::
Utils
::
Override
override
:sign_in_and_redirect
def
sign_in_and_redirect
(
user
)
# The counter gets incremented in `sign_in_and_redirect`
show_ldap_sync_flash
if
user
.
sign_in_count
==
0
super
end
private
def
show_ldap_sync_flash
flash
[
:notice
]
=
'LDAP sync in progress. This could take a few minutes. '
\
'Refresh the page to see the changes.'
end
end
end
end
ee/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
deleted
100644 → 0
View file @
05f9e7ac
require
'spec_helper'
describe
Ldap
::
OmniauthCallbacksController
do
include_context
'Ldap::OmniauthCallbacksController'
it
"displays LDAP sync flash on first sign in"
do
post
provider
expect
(
flash
[
:notice
]).
to
match
(
/LDAP sync in progress*/
)
end
it
"skips LDAP sync flash on subsequent sign ins"
do
user
.
update!
(
sign_in_count:
1
)
post
provider
expect
(
flash
[
:notice
]).
to
eq
nil
end
context
'access denied'
do
let
(
:valid_login?
)
{
false
}
it
'logs a failure event'
do
stub_licensed_features
(
extended_audit_events:
true
)
expect
{
post
provider
}.
to
change
(
SecurityEvent
,
:count
).
by
(
1
)
end
end
end
lib/gitlab/git/repository.rb
View file @
eece1e65
...
...
@@ -579,10 +579,34 @@ module Gitlab
count_commits
(
from:
from
,
to:
to
,
**
options
)
end
# Counts the amount of commits between `from` and `to`.
def
count_commits_between
(
from
,
to
,
options
=
{})
count_commits
(
from:
from
,
to:
to
,
**
options
)
end
# old_rev and new_rev are commit ID's
# the result of this method is an array of Gitlab::Git::RawDiffChange
def
raw_changes_between
(
old_rev
,
new_rev
)
@raw_changes_between
||=
{}
<<<<<<<
HEAD
@raw_changes_between
[[
old_rev
,
new_rev
]]
||=
begin
return
[]
if
new_rev
.
blank?
||
new_rev
==
Gitlab
::
Git
::
BLANK_SHA
gitaly_migrate
(
:raw_changes_between
)
do
|
is_enabled
|
if
is_enabled
gitaly_repository_client
.
raw_changes_between
(
old_rev
,
new_rev
)
.
each_with_object
([])
do
|
msg
,
arr
|
msg
.
raw_changes
.
each
{
|
change
|
arr
<<
::
Gitlab
::
Git
::
RawDiffChange
.
new
(
change
)
}
end
else
result
=
[]
circuit_breaker
.
perform
do
Open3
.
pipeline_r
(
git_diff_cmd
(
old_rev
,
new_rev
),
format_git_cat_file_script
,
git_cat_file_cmd
)
do
|
last_stdout
,
wait_threads
|
last_stdout
.
each_line
{
|
line
|
result
<<
::
Gitlab
::
Git
::
RawDiffChange
.
new
(
line
.
chomp!
)
}
=======
@raw_changes_between
[[
old_rev
,
new_rev
]]
||=
begin
return
[]
if
new_rev
.
blank?
||
new_rev
==
Gitlab
::
Git
::
BLANK_SHA
...
...
@@ -600,6 +624,7 @@ module Gitlab
Open3
.
pipeline_r
(
git_diff_cmd
(
old_rev
,
new_rev
),
format_git_cat_file_script
,
git_cat_file_cmd
)
do
|
last_stdout
,
wait_threads
|
last_stdout
.
each_line
{
|
line
|
result
<<
::
Gitlab
::
Git
::
RawDiffChange
.
new
(
line
.
chomp!
)
}
>>>>>>>
upstream
/
master
if
wait_threads
.
any?
{
|
waiter
|
!
waiter
.
value
&
.
success?
}
raise
::
Gitlab
::
Git
::
Repository
::
GitError
,
"Unabled to obtain changes between
#{
old_rev
}
and
#{
new_rev
}
"
end
...
...
qa/qa/page/project/job/show.rb
View file @
eece1e65
module
QA::Page
module
Project::Job
class
Show
<
QA
::
Page
::
Base
COMPLETED_STATUSES
=
%w[passed failed canceled blocked skipped manual]
.
freeze
# excludes created, pending, running
PASSED_STATUS
=
'passed'
.
freeze
view
'app/views/projects/jobs/show.html.haml'
do
element
:build_output
,
'.js-build-output'
end
def
output
css
=
'.js-build-output'
view
'app/assets/javascripts/vue_shared/components/ci_badge_link.vue'
do
element
:status_badge
,
'ci-status'
end
wait
(
reload:
false
)
do
has_css?
(
css
)
end
def
completed?
COMPLETED_STATUSES
.
include?
find
(
'.ci-status'
).
text
end
find
(
css
).
text
def
passed?
find
(
'.ci-status'
).
text
==
PASSED_STATUS
end
# Reminder: You may wish to wait for a particular job status before checking output
def
output
find
(
'.js-build-output'
).
text
end
end
end
...
...
qa/qa/specs/features/project/deploy_key_clone_spec.rb
View file @
eece1e65
...
...
@@ -87,16 +87,12 @@ module QA
Page
::
Project
::
Show
.
act
{
wait_for_push
}
Page
::
Menu
::
Side
.
act
{
click_ci_cd_pipelines
}
Page
::
Project
::
Pipeline
::
Index
.
act
{
go_to_latest_pipeline
}
Page
::
Project
::
Pipeline
::
Show
.
act
do
go_to_first_job
wait
do
!
has_content?
(
'running'
)
end
end
Page
::
Project
::
Pipeline
::
Show
.
act
{
go_to_first_job
}
Page
::
Project
::
Job
::
Show
.
perform
do
|
job
|
job
.
wait
(
reload:
false
)
{
job
.
completed?
}
expect
(
job
.
passed?
).
to
be_truthy
,
"Job status did not become
\"
passed
\"
."
expect
(
job
.
output
).
to
include
(
sha1sum
)
end
end
...
...
spec/models/concerns/issuable_spec.rb
View file @
eece1e65
...
...
@@ -512,6 +512,14 @@ describe Issuable do
expect
(
issue
.
total_time_spent
).
to
eq
(
1800
)
end
it
'updates issues updated_at'
do
issue
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
{
spend_time
(
1800
)
}.
to
change
{
issue
.
updated_at
}
end
end
end
context
'substracting time'
do
...
...
@@ -527,9 +535,13 @@ describe Issuable do
context
'when time to substract exceeds the total time spent'
do
it
'raise a validation error'
do
expect
do
spend_time
(
-
3600
)
end
.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
do
expect
do
spend_time
(
-
3600
)
end
.
to
raise_error
(
ActiveRecord
::
RecordInvalid
)
end
.
not_to
change
{
issue
.
updated_at
}
end
end
end
end
...
...
spec/support/api/time_tracking_shared_examples.rb
View file @
eece1e65
...
...
@@ -70,8 +70,12 @@ shared_examples 'time tracking endpoints' do |issuable_name|
end
it
"add spent time for
#{
issuable_name
}
"
do
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/add_spent_time"
,
user
),
duration:
'2h'
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/add_spent_time"
,
user
),
duration:
'2h'
end
.
to
change
{
issuable
.
reload
.
updated_at
}
end
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
json_response
[
'human_total_time_spent'
]).
to
eq
(
'2h'
)
...
...
@@ -79,7 +83,11 @@ shared_examples 'time tracking endpoints' do |issuable_name|
context
'when subtracting time'
do
it
'subtracts time of the total spent time'
do
issuable
.
update_attributes!
(
spend_time:
{
duration:
7200
,
user_id:
user
.
id
})
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
do
issuable
.
update_attributes!
(
spend_time:
{
duration:
7200
,
user_id:
user
.
id
})
end
.
to
change
{
issuable
.
reload
.
updated_at
}
end
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/add_spent_time"
,
user
),
duration:
'-1h'
...
...
@@ -93,8 +101,12 @@ shared_examples 'time tracking endpoints' do |issuable_name|
it
'does not modify the total time spent'
do
issuable
.
update_attributes!
(
spend_time:
{
duration:
7200
,
user_id:
user
.
id
})
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/add_spent_time"
,
user
),
duration:
'-1w'
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/add_spent_time"
,
user
),
duration:
'-1w'
end
.
not_to
change
{
issuable
.
reload
.
updated_at
}
end
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'time_spent'
].
first
).
to
match
(
/exceeds the total time spent/
)
...
...
@@ -110,7 +122,11 @@ shared_examples 'time tracking endpoints' do |issuable_name|
end
it
"resets spent time for
#{
issuable_name
}
"
do
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/reset_spent_time"
,
user
)
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
expect
do
post
api
(
"/projects/
#{
project
.
id
}
/
#{
issuable_collection_name
}
/
#{
issuable
.
iid
}
/reset_spent_time"
,
user
)
end
.
to
change
{
issuable
.
reload
.
updated_at
}
end
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'total_time_spent'
]).
to
eq
(
0
)
...
...
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