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
77e87314
Commit
77e87314
authored
Oct 08, 2020
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for user activity on Jira::IssuesController
parent
fb7aca94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
93 deletions
+109
-93
ee/spec/requests/user_activity_spec.rb
ee/spec/requests/user_activity_spec.rb
+11
-0
spec/requests/user_activity_spec.rb
spec/requests/user_activity_spec.rb
+1
-93
spec/support/shared_examples/requests/user_activity_shared_examples.rb
...shared_examples/requests/user_activity_shared_examples.rb
+97
-0
No files found.
ee/spec/requests/user_activity_spec.rb
0 → 100644
View file @
77e87314
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'Update of user activity'
do
paths_to_visit
=
[
'/group/project/-/integrations/jira/issues'
]
it_behaves_like
'updating of user activity'
,
paths_to_visit
end
spec/requests/user_activity_spec.rb
View file @
77e87314
...
...
@@ -3,18 +3,6 @@
require
'spec_helper'
RSpec
.
describe
'Update of user activity'
do
let
(
:user
)
{
create
(
:user
,
last_activity_on:
nil
)
}
before
do
group
=
create
(
:group
,
name:
'group'
)
project
=
create
(
:project
,
:public
,
namespace:
group
,
name:
'project'
)
create
(
:issue
,
project:
project
,
iid:
10
)
create
(
:merge_request
,
source_project:
project
,
iid:
15
)
project
.
add_maintainer
(
user
)
end
paths_to_visit
=
[
'/group'
,
'/group/project'
,
...
...
@@ -30,85 +18,5 @@ RSpec.describe 'Update of user activity' do
'/group/project/-/merge_requests/15'
]
context
'without an authenticated user'
do
it
'does not set the last activity cookie'
do
get
"/group/project"
expect
(
response
.
cookies
[
'user_last_activity_on'
]).
to
be_nil
end
end
context
'with an authenticated user'
do
before
do
login_as
(
user
)
end
context
'with a POST request'
do
it
'does not set the last activity cookie'
do
post
"/group/project/archive"
expect
(
response
.
cookies
[
'user_last_activity_on'
]).
to
be_nil
end
end
paths_to_visit
.
each
do
|
path
|
context
"on GET to
#{
path
}
"
do
it
'updates the last activity date'
do
expect
(
Users
::
ActivityService
).
to
receive
(
:new
).
and_call_original
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
context
'when calling it twice'
do
it
'updates last_activity_on just once'
do
expect
(
Users
::
ActivityService
).
to
receive
(
:new
).
once
.
and_call_original
2
.
times
do
get
path
end
end
end
context
'when last_activity_on is nil'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
nil
)
end
it
'updates the last activity date'
do
expect
(
user
.
last_activity_on
).
to
be_nil
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
end
context
'when last_activity_on is stale'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
2
.
days
.
ago
.
to_date
)
end
it
'updates the last activity date'
do
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
end
context
'when last_activity_on is up to date'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
Date
.
today
)
end
it
'does not try to update it'
do
expect
(
Users
::
ActivityService
).
not_to
receive
(
:new
)
get
path
end
end
end
end
end
it_behaves_like
'updating of user activity'
,
paths_to_visit
end
spec/support/shared_examples/requests/user_activity_shared_examples.rb
0 → 100644
View file @
77e87314
# frozen_string_literal: true
RSpec
.
shared_examples
'updating of user activity'
do
|
paths_to_visit
|
let
(
:user
)
{
create
(
:user
,
last_activity_on:
nil
)
}
before
do
group
=
create
(
:group
,
name:
'group'
)
project
=
create
(
:project
,
:public
,
namespace:
group
,
name:
'project'
)
create
(
:issue
,
project:
project
,
iid:
10
)
create
(
:merge_request
,
source_project:
project
,
iid:
15
)
project
.
add_maintainer
(
user
)
end
context
'without an authenticated user'
do
it
'does not set the last activity cookie'
do
get
"/group/project"
expect
(
response
.
cookies
[
'user_last_activity_on'
]).
to
be_nil
end
end
context
'with an authenticated user'
do
before
do
login_as
(
user
)
end
context
'with a POST request'
do
it
'does not set the last activity cookie'
do
post
"/group/project/archive"
expect
(
response
.
cookies
[
'user_last_activity_on'
]).
to
be_nil
end
end
paths_to_visit
.
each
do
|
path
|
context
"on GET to
#{
path
}
"
do
it
'updates the last activity date'
do
expect
(
Users
::
ActivityService
).
to
receive
(
:new
).
and_call_original
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
context
'when calling it twice'
do
it
'updates last_activity_on just once'
do
expect
(
Users
::
ActivityService
).
to
receive
(
:new
).
once
.
and_call_original
2
.
times
do
get
path
end
end
end
context
'when last_activity_on is nil'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
nil
)
end
it
'updates the last activity date'
do
expect
(
user
.
last_activity_on
).
to
be_nil
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
end
context
'when last_activity_on is stale'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
2
.
days
.
ago
.
to_date
)
end
it
'updates the last activity date'
do
get
path
expect
(
user
.
last_activity_on
).
to
eq
(
Date
.
today
)
end
end
context
'when last_activity_on is up to date'
do
before
do
user
.
update_attribute
(
:last_activity_on
,
Date
.
today
)
end
it
'does not try to update it'
do
expect
(
Users
::
ActivityService
).
not_to
receive
(
:new
)
get
path
end
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