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
e07458f0
Commit
e07458f0
authored
Jun 29, 2021
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip saving the diffs whitespace setting if the user isn't logged in
Changelog: fixed
parent
a7cd42f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+1
-1
spec/frontend/diffs/store/actions_spec.js
spec/frontend/diffs/store/actions_spec.js
+17
-1
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
e07458f0
...
...
@@ -557,7 +557,7 @@ export const setShowWhitespace = async (
{
state
,
commit
},
{
url
,
showWhitespace
,
updateDatabase
=
true
},
)
=>
{
if
(
updateDatabase
)
{
if
(
updateDatabase
&&
Boolean
(
window
.
gon
?.
current_user_id
)
)
{
await
axios
.
put
(
url
||
state
.
endpointUpdateUser
,
{
show_whitespace_in_diffs
:
showWhitespace
});
}
...
...
spec/frontend/diffs/store/actions_spec.js
View file @
e07458f0
...
...
@@ -1019,10 +1019,12 @@ describe('DiffsStoreActions', () => {
const
endpointUpdateUser
=
'
user/prefs
'
;
let
putSpy
;
let
mock
;
let
gon
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
putSpy
=
jest
.
spyOn
(
axios
,
'
put
'
);
gon
=
window
.
gon
;
mock
.
onPut
(
endpointUpdateUser
).
reply
(
200
,
{});
jest
.
spyOn
(
eventHub
,
'
$emit
'
).
mockImplementation
();
...
...
@@ -1030,6 +1032,7 @@ describe('DiffsStoreActions', () => {
afterEach
(()
=>
{
mock
.
restore
();
window
.
gon
=
gon
;
});
it
(
'
commits SET_SHOW_WHITESPACE
'
,
(
done
)
=>
{
...
...
@@ -1043,7 +1046,9 @@ describe('DiffsStoreActions', () => {
);
});
it
(
'
saves to the database
'
,
async
()
=>
{
it
(
'
saves to the database when the user is logged in
'
,
async
()
=>
{
window
.
gon
=
{
current_user_id
:
12345
};
await
setShowWhitespace
(
{
state
:
{
endpointUpdateUser
},
commit
()
{}
},
{
showWhitespace
:
true
,
updateDatabase
:
true
},
...
...
@@ -1052,6 +1057,17 @@ describe('DiffsStoreActions', () => {
expect
(
putSpy
).
toHaveBeenCalledWith
(
endpointUpdateUser
,
{
show_whitespace_in_diffs
:
true
});
});
it
(
'
does not try to save to the API if the user is not logged in
'
,
async
()
=>
{
window
.
gon
=
{};
await
setShowWhitespace
(
{
state
:
{
endpointUpdateUser
},
commit
()
{}
},
{
showWhitespace
:
true
,
updateDatabase
:
true
},
);
expect
(
putSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
emits eventHub event
'
,
async
()
=>
{
await
setShowWhitespace
(
{
state
:
{},
commit
()
{}
},
...
...
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