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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
8581df3b
Commit
8581df3b
authored
Oct 07, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sh-fix-events-update-spec' into 'master'
Fix Event#reset_project_activity updates See merge request !6729
parents
0876b460
16626409
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
app/models/event.rb
app/models/event.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+4
-1
No files found.
app/models/event.rb
View file @
8581df3b
...
@@ -335,7 +335,7 @@ class Event < ActiveRecord::Base
...
@@ -335,7 +335,7 @@ class Event < ActiveRecord::Base
# update the project. Only one query should actually perform the update,
# update the project. Only one query should actually perform the update,
# hence we add the extra WHERE clause for last_activity_at.
# hence we add the extra WHERE clause for last_activity_at.
Project
.
unscoped
.
where
(
id:
project_id
).
Project
.
unscoped
.
where
(
id:
project_id
).
where
(
'last_activity_at
>
?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
).
where
(
'last_activity_at
<=
?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
).
update_all
(
last_activity_at:
created_at
)
update_all
(
last_activity_at:
created_at
)
end
end
...
...
spec/models/project_spec.rb
View file @
8581df3b
...
@@ -308,7 +308,9 @@ describe Project, models: true do
...
@@ -308,7 +308,9 @@ describe Project, models: true do
end
end
describe
'last_activity methods'
do
describe
'last_activity methods'
do
let
(
:project
)
{
create
(
:project
,
last_activity_at:
2
.
hours
.
ago
)
}
let
(
:timestamp
)
{
2
.
hours
.
ago
}
# last_activity_at gets set to created_at upon creation
let
(
:project
)
{
create
(
:project
,
created_at:
timestamp
,
updated_at:
timestamp
)
}
describe
'last_activity'
do
describe
'last_activity'
do
it
'alias last_activity to last_event'
do
it
'alias last_activity to last_event'
do
...
@@ -322,6 +324,7 @@ describe Project, models: true do
...
@@ -322,6 +324,7 @@ describe Project, models: true do
it
'returns the creation date of the project\'s last event if present'
do
it
'returns the creation date of the project\'s last event if present'
do
new_event
=
create
(
:event
,
project:
project
,
created_at:
Time
.
now
)
new_event
=
create
(
:event
,
project:
project
,
created_at:
Time
.
now
)
project
.
reload
expect
(
project
.
last_activity_at
.
to_i
).
to
eq
(
new_event
.
created_at
.
to_i
)
expect
(
project
.
last_activity_at
.
to_i
).
to
eq
(
new_event
.
created_at
.
to_i
)
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