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
471ea73a
Commit
471ea73a
authored
Jun 05, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Profiles::PreferencesController
cherry-picked
parent
41aead60
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
127 additions
and
15 deletions
+127
-15
app/controllers/profiles/preferences_controller.rb
app/controllers/profiles/preferences_controller.rb
+29
-0
app/views/layouts/nav/_profile.html.haml
app/views/layouts/nav/_profile.html.haml
+4
-3
app/views/profiles/preferences/show.html.haml
app/views/profiles/preferences/show.html.haml
+1
-0
app/views/profiles/preferences/update.js.erb
app/views/profiles/preferences/update.js.erb
+1
-0
config/routes.rb
config/routes.rb
+1
-0
features/profile/active_tab.feature
features/profile/active_tab.feature
+3
-3
features/steps/profile/active_tab.rb
features/steps/profile/active_tab.rb
+2
-2
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+2
-2
spec/controllers/profiles/preferences_controller_spec.rb
spec/controllers/profiles/preferences_controller_spec.rb
+70
-0
spec/features/security/profile_access_spec.rb
spec/features/security/profile_access_spec.rb
+2
-2
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+12
-3
No files found.
app/controllers/profiles/preferences_controller.rb
0 → 100644
View file @
471ea73a
class
Profiles::PreferencesController
<
Profiles
::
ApplicationController
before_action
:user
def
show
end
def
update
if
@user
.
update_attributes
(
preferences_params
)
flash
[
:notice
]
=
'Preferences saved.'
else
# TODO (rspeicher): There's no validation on these values, so can it fail?
end
respond_to
do
|
format
|
format
.
html
{
redirect_to
profile_preferences_path
}
format
.
js
end
end
private
def
user
@user
=
current_user
end
def
preferences_params
params
.
require
(
:user
).
permit
(
:color_scheme_id
,
:theme_id
)
end
end
app/views/layouts/nav/_profile.html.haml
View file @
471ea73a
...
...
@@ -38,11 +38,12 @@
%span
SSH Keys
%span
.count
=
current_user
.
keys
.
count
=
nav_link
(
path:
'profiles#design'
)
do
=
link_to
design_profile_path
,
title:
'Design'
,
data:
{
placement:
'right'
}
do
=
nav_link
(
controller: :preferences
)
do
=
link_to
profile_preferences_path
,
title:
'Preferences'
,
data:
{
placement:
'right'
}
do
-# TODO (rspeicher): Better icon?
=
icon
(
'image fw'
)
%span
Design
Preferences
=
nav_link
(
path:
'profiles#history'
)
do
=
link_to
history_profile_path
,
title:
'History'
,
data:
{
placement:
'right'
}
do
=
icon
(
'history fw'
)
...
...
app/views/profiles/preferences/show.html.haml
0 → 100644
View file @
471ea73a
TODO
app/views/profiles/preferences/update.js.erb
0 → 100644
View file @
471ea73a
// TODO
config/routes.rb
View file @
471ea73a
...
...
@@ -222,6 +222,7 @@ Gitlab::Application.routes.draw do
put
:reset
end
end
resource
:preferences
,
only:
[
:show
,
:update
]
resources
:keys
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
...
...
features/profile/active_tab.feature
View file @
471ea73a
...
...
@@ -18,9 +18,9 @@ Feature: Profile Active Tab
Then
the active main tab should be SSH Keys
And
no other main tabs should be active
Scenario
:
On Profile
Design
Given
I visit profile
design
page
Then
the active main tab should be
Design
Scenario
:
On Profile
Preferences
Given
I visit profile
preferences
page
Then
the active main tab should be
Preferences
And
no other main tabs should be active
Scenario
:
On Profile History
...
...
features/steps/profile/active_tab.rb
View file @
471ea73a
...
...
@@ -15,8 +15,8 @@ class Spinach::Features::ProfileActiveTab < Spinach::FeatureSteps
ensure_active_main_tab
(
'SSH Keys'
)
end
step
'the active main tab should be
Design
'
do
ensure_active_main_tab
(
'
Design
'
)
step
'the active main tab should be
Preferences
'
do
ensure_active_main_tab
(
'
Preferences
'
)
end
step
'the active main tab should be History'
do
...
...
features/steps/shared/paths.rb
View file @
471ea73a
...
...
@@ -123,8 +123,8 @@ module SharedPaths
visit
profile_keys_path
end
step
'I visit profile
design
page'
do
visit
design_profile
_path
step
'I visit profile
preferences
page'
do
visit
profile_preferences
_path
end
step
'I visit profile history page'
do
...
...
spec/controllers/profiles/preferences_controller_spec.rb
0 → 100644
View file @
471ea73a
require
'spec_helper'
describe
Profiles
::
PreferencesController
do
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
allow
(
subject
).
to
receive
(
:current_user
).
and_return
(
user
)
end
describe
'GET show'
do
it
'renders'
do
get
:show
expect
(
response
).
to
render_template
:show
end
it
'assigns user'
do
get
:show
expect
(
assigns
[
:user
]).
to
eq
user
end
end
describe
'PATCH update'
do
def
go
(
params:
{},
format: :js
)
params
.
reverse_merge!
(
color_scheme_id:
'1'
,
theme_id:
'1'
)
patch
:update
,
user:
params
,
format:
format
end
context
'on successful update'
do
it
'sets the flash'
do
go
expect
(
flash
[
:notice
]).
to
eq
'Preferences saved.'
end
it
"changes the user's preferences"
do
prefs
=
{
color_scheme_id:
'1'
,
theme_id:
'2'
}.
with_indifferent_access
expect
(
user
).
to
receive
(
:update_attributes
).
with
(
prefs
)
go
params:
prefs
end
end
context
'on unsuccessful update'
do
# TODO (rspeicher): Can this happen?
end
context
'as js'
do
it
'renders'
do
go
expect
(
response
).
to
render_template
:update
end
end
context
'as html'
do
it
'redirects'
do
go
format: :html
expect
(
response
).
to
redirect_to
(
profile_preferences_path
)
end
end
end
end
spec/features/security/profile_access_spec.rb
View file @
471ea73a
...
...
@@ -36,8 +36,8 @@ describe "Profile access", feature: true do
it
{
is_expected
.
to
be_denied_for
:visitor
}
end
describe
"GET /profile/
design
"
do
subject
{
design_profile
_path
}
describe
"GET /profile/
preferences
"
do
subject
{
profile_preferences
_path
}
it
{
is_expected
.
to
be_allowed_for
@u1
}
it
{
is_expected
.
to
be_allowed_for
:admin
}
...
...
spec/routing/routing_spec.rb
View file @
471ea73a
...
...
@@ -102,7 +102,6 @@ end
# profile_token GET /profile/token(.:format) profile#token
# profile_reset_private_token PUT /profile/reset_private_token(.:format) profile#reset_private_token
# profile GET /profile(.:format) profile#show
# profile_design GET /profile/design(.:format) profile#design
# profile_update PUT /profile/update(.:format) profile#update
describe
ProfilesController
,
"routing"
do
it
"to #account"
do
...
...
@@ -120,9 +119,19 @@ describe ProfilesController, "routing" do
it
"to #show"
do
expect
(
get
(
"/profile"
)).
to
route_to
(
'profiles#show'
)
end
end
# profile_preferences GET /profile/preferences(.:format) profiles/preferences#show
# PATCH /profile/preferences(.:format) profiles/preferences#update
# PUT /profile/preferences(.:format) profiles/preferences#update
describe
Profiles
::
PreferencesController
,
'routing'
do
it
'to #show'
do
expect
(
get
(
'/profile/preferences'
)).
to
route_to
(
'profiles/preferences#show'
)
end
it
"to #design"
do
expect
(
get
(
"/profile/design"
)).
to
route_to
(
'profiles#design'
)
it
'to #update'
do
expect
(
put
(
'/profile/preferences'
)).
to
route_to
(
'profiles/preferences#update'
)
expect
(
patch
(
'/profile/preferences'
)).
to
route_to
(
'profiles/preferences#update'
)
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