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
2d2f13f1
Commit
2d2f13f1
authored
May 02, 2017
by
Douglas Barbosa Alexandre
Committed by
Robert Speicher
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update last_repository_updated_at when a push event is created
parent
a7fd4947
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
app/models/event.rb
app/models/event.rb
+6
-0
spec/models/event_spec.rb
spec/models/event_spec.rb
+24
-5
No files found.
app/models/event.rb
View file @
2d2f13f1
...
...
@@ -352,6 +352,12 @@ class Event < ActiveRecord::Base
Project
.
unscoped
.
where
(
id:
project_id
).
where
(
'last_activity_at <= ?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
).
update_all
(
last_activity_at:
created_at
)
if
push?
Project
.
unscoped
.
where
(
id:
project_id
).
where
(
'last_repository_updated_at <= ?'
,
RESET_PROJECT_ACTIVITY_INTERVAL
.
ago
).
update_all
(
last_repository_updated_at:
created_at
)
end
end
def
authored_by?
(
user
)
...
...
spec/models/event_spec.rb
View file @
2d2f13f1
...
...
@@ -243,19 +243,38 @@ describe Event, models: true do
expect
(
project
).
not_to
receive
(
:update_column
).
with
(
:last_activity_at
,
a_kind_of
(
Time
))
expect
(
project
).
not_to
receive
(
:update_column
).
with
(
:last_repository_updated_at
,
a_kind_of
(
Time
))
create_event
(
project
,
project
.
owner
)
end
end
context
'when a project was updated more than 1 hour ago'
do
it
'updates the project'
do
project
.
update
(
last_activity_at:
1
.
year
.
ago
)
context
'with a push event'
do
it
'updates the project last_activity_at and last_repository_updated_at'
do
project
.
update
(
last_activity_at:
1
.
year
.
ago
,
last_repository_updated_at:
1
.
year
.
ago
)
create_event
(
project
,
project
.
owner
)
project
.
reload
project
.
last_activity_at
<=
1
.
minute
.
ago
expect
(
project
.
last_activity_at
).
to
be_within
(
1
.
minute
).
of
(
Time
.
now
)
expect
(
project
.
last_repository_updated_at
).
to
be_within
(
1
.
minute
).
of
(
Time
.
now
)
end
end
context
'without a push event'
do
it
'does not updates the project last_repository_updated_at'
do
project
.
update
(
last_activity_at:
1
.
year
.
ago
,
last_repository_updated_at:
1
.
year
.
ago
)
create
(
:closed_issue_event
,
project:
project
,
author:
project
.
owner
)
project
.
reload
expect
(
project
.
last_activity_at
).
to
be_within
(
1
.
minute
).
of
(
Time
.
now
)
expect
(
project
.
last_repository_updated_at
).
to
be_within
(
1
.
minute
).
of
(
1
.
year
.
ago
)
end
end
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