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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
821fc4b0
Commit
821fc4b0
authored
Jun 05, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Profiles::PreferencesController
parent
0b3c9742
Changes
11
Show 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 @
821fc4b0
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 @
821fc4b0
...
@@ -38,11 +38,12 @@
...
@@ -38,11 +38,12 @@
%span
%span
SSH Keys
SSH Keys
%span
.count
=
current_user
.
keys
.
count
%span
.count
=
current_user
.
keys
.
count
=
nav_link
(
path:
'profiles#design'
)
do
=
nav_link
(
controller: :preferences
)
do
=
link_to
design_profile_path
,
title:
'Design'
,
data:
{
placement:
'right'
}
do
=
link_to
profile_preferences_path
,
title:
'Preferences'
,
data:
{
placement:
'right'
}
do
-# TODO (rspeicher): Better icon?
=
icon
(
'image fw'
)
=
icon
(
'image fw'
)
%span
%span
Design
Preferences
=
nav_link
(
path:
'profiles#history'
)
do
=
nav_link
(
path:
'profiles#history'
)
do
=
link_to
history_profile_path
,
title:
'History'
,
data:
{
placement:
'right'
}
do
=
link_to
history_profile_path
,
title:
'History'
,
data:
{
placement:
'right'
}
do
=
icon
(
'history fw'
)
=
icon
(
'history fw'
)
...
...
app/views/profiles/preferences/show.html.haml
0 → 100644
View file @
821fc4b0
TODO
app/views/profiles/preferences/update.js.erb
0 → 100644
View file @
821fc4b0
// TODO
config/routes.rb
View file @
821fc4b0
...
@@ -222,6 +222,7 @@ Gitlab::Application.routes.draw do
...
@@ -222,6 +222,7 @@ Gitlab::Application.routes.draw do
put
:reset
put
:reset
end
end
end
end
resource
:preferences
,
only:
[
:show
,
:update
]
resources
:keys
resources
:keys
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
resources
:emails
,
only:
[
:index
,
:create
,
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
...
...
features/profile/active_tab.feature
View file @
821fc4b0
...
@@ -18,9 +18,9 @@ Feature: Profile Active Tab
...
@@ -18,9 +18,9 @@ Feature: Profile Active Tab
Then
the active main tab should be SSH Keys
Then
the active main tab should be SSH Keys
And
no other main tabs should be active
And
no other main tabs should be active
Scenario
:
On Profile
Design
Scenario
:
On Profile
Preferences
Given
I visit profile
design
page
Given
I visit profile
preferences
page
Then
the active main tab should be
Design
Then
the active main tab should be
Preferences
And
no other main tabs should be active
And
no other main tabs should be active
Scenario
:
On Profile History
Scenario
:
On Profile History
...
...
features/steps/profile/active_tab.rb
View file @
821fc4b0
...
@@ -15,8 +15,8 @@ class Spinach::Features::ProfileActiveTab < Spinach::FeatureSteps
...
@@ -15,8 +15,8 @@ class Spinach::Features::ProfileActiveTab < Spinach::FeatureSteps
ensure_active_main_tab
(
'SSH Keys'
)
ensure_active_main_tab
(
'SSH Keys'
)
end
end
step
'the active main tab should be
Design
'
do
step
'the active main tab should be
Preferences
'
do
ensure_active_main_tab
(
'
Design
'
)
ensure_active_main_tab
(
'
Preferences
'
)
end
end
step
'the active main tab should be History'
do
step
'the active main tab should be History'
do
...
...
features/steps/shared/paths.rb
View file @
821fc4b0
...
@@ -123,8 +123,8 @@ module SharedPaths
...
@@ -123,8 +123,8 @@ module SharedPaths
visit
profile_keys_path
visit
profile_keys_path
end
end
step
'I visit profile
design
page'
do
step
'I visit profile
preferences
page'
do
visit
design_profile
_path
visit
profile_preferences
_path
end
end
step
'I visit profile history page'
do
step
'I visit profile history page'
do
...
...
spec/controllers/profiles/preferences_controller_spec.rb
0 → 100644
View file @
821fc4b0
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 @
821fc4b0
...
@@ -36,8 +36,8 @@ describe "Profile access", feature: true do
...
@@ -36,8 +36,8 @@ describe "Profile access", feature: true do
it
{
is_expected
.
to
be_denied_for
:visitor
}
it
{
is_expected
.
to
be_denied_for
:visitor
}
end
end
describe
"GET /profile/
design
"
do
describe
"GET /profile/
preferences
"
do
subject
{
design_profile
_path
}
subject
{
profile_preferences
_path
}
it
{
is_expected
.
to
be_allowed_for
@u1
}
it
{
is_expected
.
to
be_allowed_for
@u1
}
it
{
is_expected
.
to
be_allowed_for
:admin
}
it
{
is_expected
.
to
be_allowed_for
:admin
}
...
...
spec/routing/routing_spec.rb
View file @
821fc4b0
...
@@ -102,7 +102,6 @@ end
...
@@ -102,7 +102,6 @@ end
# profile_token GET /profile/token(.:format) profile#token
# profile_token GET /profile/token(.:format) profile#token
# profile_reset_private_token PUT /profile/reset_private_token(.:format) profile#reset_private_token
# profile_reset_private_token PUT /profile/reset_private_token(.:format) profile#reset_private_token
# profile GET /profile(.:format) profile#show
# profile GET /profile(.:format) profile#show
# profile_design GET /profile/design(.:format) profile#design
# profile_update PUT /profile/update(.:format) profile#update
# profile_update PUT /profile/update(.:format) profile#update
describe
ProfilesController
,
"routing"
do
describe
ProfilesController
,
"routing"
do
it
"to #account"
do
it
"to #account"
do
...
@@ -120,9 +119,19 @@ describe ProfilesController, "routing" do
...
@@ -120,9 +119,19 @@ describe ProfilesController, "routing" do
it
"to #show"
do
it
"to #show"
do
expect
(
get
(
"/profile"
)).
to
route_to
(
'profiles#show'
)
expect
(
get
(
"/profile"
)).
to
route_to
(
'profiles#show'
)
end
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
it
'to #update'
do
expect
(
get
(
"/profile/design"
)).
to
route_to
(
'profiles#design'
)
expect
(
put
(
'/profile/preferences'
)).
to
route_to
(
'profiles/preferences#update'
)
expect
(
patch
(
'/profile/preferences'
)).
to
route_to
(
'profiles/preferences#update'
)
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