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
7308eda4
Commit
7308eda4
authored
May 27, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move non-sticky call in Users::ActivityService to Core
parent
7ff1e6f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
69 deletions
+48
-69
app/services/users/activity_service.rb
app/services/users/activity_service.rb
+1
-3
ee/app/services/ee/users/activity_service.rb
ee/app/services/ee/users/activity_service.rb
+0
-16
ee/spec/services/users/activity_service_spec.rb
ee/spec/services/users/activity_service_spec.rb
+0
-50
spec/services/users/activity_service_spec.rb
spec/services/users/activity_service_spec.rb
+47
-0
No files found.
app/services/users/activity_service.rb
View file @
7308eda4
...
...
@@ -17,7 +17,7 @@ module Users
def
execute
return
unless
@user
record_activity
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
without_sticky_writes
{
record_activity
}
end
private
...
...
@@ -37,5 +37,3 @@ module Users
end
end
end
Users
::
ActivityService
.
prepend_mod
ee/app/services/ee/users/activity_service.rb
deleted
100644 → 0
View file @
7ff1e6f8
# frozen_string_literal: true
module
EE
module
Users
module
ActivityService
extend
::
Gitlab
::
Utils
::
Override
private
override
:record_activity
def
record_activity
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
without_sticky_writes
{
super
}
end
end
end
end
ee/spec/services/users/activity_service_spec.rb
deleted
100644 → 0
View file @
7ff1e6f8
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Users
::
ActivityService
,
'#execute'
,
:request_store
,
:redis
,
:clean_gitlab_redis_shared_state
do
include_context
'clear DB Load Balancing configuration'
let
(
:user
)
{
create
(
:user
,
last_activity_on:
last_activity_on
)
}
context
'when last activity is in the past'
do
let
(
:user
)
{
create
(
:user
,
last_activity_on:
Date
.
today
-
1
.
week
)
}
context
'database load balancing is configured'
do
before
do
# Do not pollute AR for other tests, but rather simulate effect of configure_proxy.
allow
(
ActiveRecord
::
Base
.
singleton_class
).
to
receive
(
:prepend
)
::
Gitlab
::
Database
::
LoadBalancing
.
configure_proxy
allow
(
ActiveRecord
::
Base
).
to
receive
(
:connection
).
and_return
(
::
Gitlab
::
Database
::
LoadBalancing
.
proxy
)
end
let
(
:service
)
do
service
=
described_class
.
new
(
user
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
clear_session
service
end
it
'does not stick to primary'
do
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_performed_write
service
.
execute
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
be_performed_write
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_using_primary
end
end
context
'database load balancing is not configured'
do
let
(
:service
)
{
described_class
.
new
(
user
)
}
it
'updates user without error'
do
service
.
execute
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
end
end
end
spec/services/users/activity_service_spec.rb
View file @
7308eda4
...
...
@@ -84,4 +84,51 @@ RSpec.describe Users::ActivityService do
end
end
end
context
'with DB Load Balancing'
,
:request_store
,
:redis
,
:clean_gitlab_redis_shared_state
do
include_context
'clear DB Load Balancing configuration'
let
(
:user
)
{
create
(
:user
,
last_activity_on:
last_activity_on
)
}
context
'when last activity is in the past'
do
let
(
:user
)
{
create
(
:user
,
last_activity_on:
Date
.
today
-
1
.
week
)
}
context
'database load balancing is configured'
do
before
do
# Do not pollute AR for other tests, but rather simulate effect of configure_proxy.
allow
(
ActiveRecord
::
Base
.
singleton_class
).
to
receive
(
:prepend
)
::
Gitlab
::
Database
::
LoadBalancing
.
configure_proxy
allow
(
ActiveRecord
::
Base
).
to
receive
(
:connection
).
and_return
(
::
Gitlab
::
Database
::
LoadBalancing
.
proxy
)
end
let
(
:service
)
do
service
=
described_class
.
new
(
user
)
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
clear_session
service
end
it
'does not stick to primary'
do
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_performed_write
service
.
execute
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
be_performed_write
expect
(
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
not_to
be_using_primary
end
end
context
'database load balancing is not configured'
do
let
(
:service
)
{
described_class
.
new
(
user
)
}
it
'updates user without error'
do
service
.
execute
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
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