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
b80dca82
Commit
b80dca82
authored
Dec 12, 2018
by
Felipe Artur
Committed by
Nick Thomas
Dec 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not save user preferences on read-only mode
parent
2ccd4b36
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
0 deletions
+38
-0
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+2
-0
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+2
-0
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+2
-0
spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb
...rs/set_sort_order_from_user_preference_shared_examples.rb
+32
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
b80dca82
...
...
@@ -126,6 +126,8 @@ module IssuableCollections
sort_param
=
params
[
:sort
]
sort_param
||=
user_preference
[
issuable_sorting_field
]
return
sort_param
if
Gitlab
::
Database
.
read_only?
if
user_preference
[
issuable_sorting_field
]
!=
sort_param
user_preference
.
update_attribute
(
issuable_sorting_field
,
sort_param
)
end
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
b80dca82
...
...
@@ -42,6 +42,8 @@ describe Projects::IssuesController do
it_behaves_like
"issuables list meta-data"
,
:issue
it_behaves_like
'set sort order from user preference'
it
"returns index"
do
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
b80dca82
...
...
@@ -160,6 +160,8 @@ describe Projects::MergeRequestsController do
it_behaves_like
"issuables list meta-data"
,
:merge_request
it_behaves_like
'set sort order from user preference'
context
'when page param'
do
let
(
:last_page
)
{
project
.
merge_requests
.
page
().
total_pages
}
let!
(
:merge_request
)
{
create
(
:merge_request_with_diffs
,
target_project:
project
,
source_project:
project
)
}
...
...
spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb
0 → 100644
View file @
b80dca82
shared_examples
'set sort order from user preference'
do
describe
'#set_sort_order_from_user_preference'
do
# There is no issuable_sorting_field defined in any CE controllers yet,
# however any other field present in user_preferences table can be used for testing.
let
(
:sorting_field
)
{
:issue_notes_filter
}
let
(
:sorting_param
)
{
'any'
}
before
do
allow
(
controller
).
to
receive
(
:issuable_sorting_field
).
and_return
(
sorting_field
)
end
context
'when database is in read-only mode'
do
it
'it does not update user preference'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
expect_any_instance_of
(
UserPreference
).
not_to
receive
(
:update_attribute
).
with
(
sorting_field
,
sorting_param
)
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
,
sort:
sorting_param
end
end
context
'when database is not in read-only mode'
do
it
'updates user preference'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
false
)
expect_any_instance_of
(
UserPreference
).
to
receive
(
:update_attribute
).
with
(
sorting_field
,
sorting_param
)
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
,
sort:
sorting_param
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