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
94c364af
Commit
94c364af
authored
Jan 22, 2020
by
Sean Arnold
Committed by
Douglas Barbosa Alexandre
Jan 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite spec to test behaviour, not implementation
parent
f4128209
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
app/models/error_tracking/project_error_tracking_setting.rb
app/models/error_tracking/project_error_tracking_setting.rb
+5
-7
spec/models/error_tracking/project_error_tracking_setting_spec.rb
...els/error_tracking/project_error_tracking_setting_spec.rb
+7
-7
No files found.
app/models/error_tracking/project_error_tracking_setting.rb
View file @
94c364af
...
...
@@ -126,6 +126,10 @@ module ErrorTracking
end
end
def
expire_issues_cache
Rails
.
cache
.
delete_matched
(
expand_cache_key
(
'list_issues'
))
end
# http://HOST/api/0/projects/ORG/PROJECT
# ->
# http://HOST/ORG/PROJECT
...
...
@@ -140,15 +144,9 @@ module ErrorTracking
Addressable
::
URI
.
join
(
api_url
,
'/'
).
to_s
end
def
clear_cache
(
resource_prefix
)
raise
'No resource prefix provided'
unless
resource_prefix
Rails
.
cache
.
delete_matched
(
cache_key
(
resource_prefix
))
end
private
def
cache_key
(
resource_prefix
)
def
expand_
cache_key
(
resource_prefix
)
klass_key
=
self
.
class
.
reactive_cache_key
.
call
(
self
).
join
(
':'
)
"
#{
klass_key
}
:
#{
resource_prefix
}
*"
...
...
spec/models/error_tracking/project_error_tracking_setting_spec.rb
View file @
94c364af
...
...
@@ -441,17 +441,17 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
describe
'#clear_cache'
do
let
(
:key_prefix
)
{
'list_issues'
}
describe
'#expire_issues_cache'
,
:use_clean_rails_memory_store_caching
do
it
'clears the cache'
do
klass_key
=
subject
.
class
.
reactive_cache_key
.
call
(
subject
).
join
(
':'
)
key
=
"
#{
klass_key
}
:list_issues:some_suffix"
Rails
.
cache
.
write
(
key
,
1
)
expect
(
Rails
.
cache
.
exist?
(
key
)).
to
eq
(
true
)
expect
(
Rails
.
cache
)
.
to
receive
(
:delete_matched
)
.
with
(
"
#{
klass_key
}
:
#{
key_prefix
}
*"
)
subject
.
expire_issues_cache
subject
.
clear_cache
(
key_prefix
)
expect
(
Rails
.
cache
.
exist?
(
key
)).
to
eq
(
false
)
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