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
5b55bfdc
Commit
5b55bfdc
authored
Dec 04, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate roadmap_epics_state
parent
535e403c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
3 deletions
+44
-3
app/models/user_preference.rb
app/models/user_preference.rb
+2
-0
ee/app/controllers/groups/roadmap_controller.rb
ee/app/controllers/groups/roadmap_controller.rb
+4
-3
ee/app/models/ee/user_preference.rb
ee/app/models/ee/user_preference.rb
+11
-0
ee/spec/models/user_preference_spec.rb
ee/spec/models/user_preference_spec.rb
+27
-0
No files found.
app/models/user_preference.rb
View file @
5b55bfdc
...
...
@@ -51,3 +51,5 @@ class UserPreference < ActiveRecord::Base
"
#{
field_key
}
_notes_filter"
end
end
UserPreference
.
prepend
(
EE
::
UserPreference
)
ee/app/controllers/groups/roadmap_controller.rb
View file @
5b55bfdc
...
...
@@ -38,10 +38,11 @@ module Groups
return
unless
current_user
preference
=
current_user
.
user_preference
state_id
=
Epic
.
states
[
params
[
:state
]]
if
params
[
:state
].
present?
&&
state_id
!=
preference
.
roadmap_epics_state
preference
.
update
(
roadmap_epics_state:
state_id
)
if
params
[
:state
].
present?
preference
.
roadmap_epics_state
=
Epic
.
states
[
params
[
:state
]]
preference
.
save
if
preference
.
changed?
&&
Gitlab
::
Database
.
read_write?
end
Epic
.
states
.
key
(
preference
.
roadmap_epics_state
)
...
...
ee/app/models/ee/user_preference.rb
0 → 100644
View file @
5b55bfdc
module
EE
module
UserPreference
extend
ActiveSupport
::
Concern
prepended
do
validates
:roadmap_epics_state
,
allow_nil:
true
,
inclusion:
{
in:
::
Epic
.
states
.
values
,
message:
"%{value} is not a valid epic state"
}
end
end
end
ee/spec/models/user_preference_spec.rb
0 → 100644
View file @
5b55bfdc
require
'spec_helper'
describe
UserPreference
do
let
(
:user_preference
)
{
create
(
:user_preference
)
}
shared_examples
'updates roadmap_epics_state'
do
|
state
|
it
'saves roadmap_epics_state in user_preference'
do
user_preference
.
update
(
roadmap_epics_state:
state
)
expect
(
user_preference
.
reload
.
roadmap_epics_state
).
to
eq
(
state
)
end
end
describe
'roadmap_epics_state'
do
context
'when set to open epics'
do
it_behaves_like
'updates roadmap_epics_state'
,
Epic
.
states
[
:opened
]
end
context
'when set to closed epics'
do
it_behaves_like
'updates roadmap_epics_state'
,
Epic
.
states
[
:closed
]
end
context
'when reset to all epics'
do
it_behaves_like
'updates roadmap_epics_state'
,
nil
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