Commit 46bf3a094988327b08c88006c694f0a0a15f7da2
1 parent
2be5e6d4
Exists in
master
and in
4 other branches
Refactored profile to resource. Added missing flash notice on successfull update…
…d. Update username via ajax
Showing
20 changed files
with
345 additions
and
306 deletions
Show diff stats
app/assets/javascripts/profile.js.coffee
... | ... | @@ -8,3 +8,13 @@ $ -> |
8 | 8 | |
9 | 9 | # Go up the hierarchy and show the corresponding submission feedback element |
10 | 10 | $(@).closest('fieldset').find('.update-feedback').show('highlight', {color: '#DFF0D8'}, 500) |
11 | + | |
12 | + $('.update-username form').on 'ajax:before', -> | |
13 | + $('.loading-gif').show() | |
14 | + $(this).find('.update-success').hide() | |
15 | + $(this).find('.update-failed').hide() | |
16 | + | |
17 | + $('.update-username form').on 'ajax:complete', -> | |
18 | + $(this).find('.save-btn').removeAttr('disabled') | |
19 | + $(this).find('.save-btn').removeClass('disabled') | |
20 | + $(this).find('.loading-gif').hide() | ... | ... |
app/controllers/profile_controller.rb
... | ... | @@ -1,47 +0,0 @@ |
1 | -class ProfileController < ApplicationController | |
2 | - before_filter :user | |
3 | - | |
4 | - def show | |
5 | - end | |
6 | - | |
7 | - def design | |
8 | - end | |
9 | - | |
10 | - def update | |
11 | - @user.update_attributes(params[:user]) | |
12 | - | |
13 | - respond_to do |format| | |
14 | - format.html { redirect_to :back } | |
15 | - format.js | |
16 | - end | |
17 | - end | |
18 | - | |
19 | - def token | |
20 | - end | |
21 | - | |
22 | - def password_update | |
23 | - params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"} | |
24 | - | |
25 | - if @user.update_attributes(params[:user]) | |
26 | - flash[:notice] = "Password was successfully updated. Please login with it" | |
27 | - redirect_to new_user_session_path | |
28 | - else | |
29 | - render 'account' | |
30 | - end | |
31 | - end | |
32 | - | |
33 | - def reset_private_token | |
34 | - current_user.reset_authentication_token! | |
35 | - redirect_to profile_account_path | |
36 | - end | |
37 | - | |
38 | - def history | |
39 | - @events = current_user.recent_events.page(params[:page]).per(20) | |
40 | - end | |
41 | - | |
42 | - private | |
43 | - | |
44 | - def user | |
45 | - @user = current_user | |
46 | - end | |
47 | -end |
... | ... | @@ -0,0 +1,66 @@ |
1 | +class ProfilesController < ApplicationController | |
2 | + before_filter :user | |
3 | + layout 'profile' | |
4 | + | |
5 | + def show | |
6 | + end | |
7 | + | |
8 | + def design | |
9 | + end | |
10 | + | |
11 | + def account | |
12 | + end | |
13 | + | |
14 | + def update | |
15 | + if @user.update_attributes(params[:user]) | |
16 | + flash[:notice] = "Profile was successfully updated" | |
17 | + else | |
18 | + flash[:alert] = "Failed to update profile" | |
19 | + end | |
20 | + | |
21 | + respond_to do |format| | |
22 | + format.html { redirect_to :back } | |
23 | + format.js | |
24 | + end | |
25 | + end | |
26 | + | |
27 | + def token | |
28 | + end | |
29 | + | |
30 | + def update_password | |
31 | + params[:user].reject!{ |k, v| k != "password" && k != "password_confirmation"} | |
32 | + | |
33 | + if @user.update_attributes(params[:user]) | |
34 | + flash[:notice] = "Password was successfully updated. Please login with it" | |
35 | + redirect_to new_user_session_path | |
36 | + else | |
37 | + render 'account' | |
38 | + end | |
39 | + end | |
40 | + | |
41 | + def reset_private_token | |
42 | + if current_user.reset_authentication_token! | |
43 | + flash[:notice] = "Token was successfully updated" | |
44 | + end | |
45 | + | |
46 | + redirect_to account_profile_path | |
47 | + end | |
48 | + | |
49 | + def history | |
50 | + @events = current_user.recent_events.page(params[:page]).per(20) | |
51 | + end | |
52 | + | |
53 | + def update_username | |
54 | + @user.update_attributes(username: params[:user][:username]) | |
55 | + | |
56 | + respond_to do |format| | |
57 | + format.js | |
58 | + end | |
59 | + end | |
60 | + | |
61 | + private | |
62 | + | |
63 | + def user | |
64 | + @user = current_user | |
65 | + end | |
66 | +end | ... | ... |
app/views/layouts/profile.html.haml
... | ... | @@ -6,17 +6,17 @@ |
6 | 6 | = render "layouts/head_panel", title: "Profile" |
7 | 7 | .container |
8 | 8 | %ul.main_menu |
9 | - = nav_link(path: 'profile#show', html_options: {class: 'home'}) do | |
9 | + = nav_link(path: 'profiles#show', html_options: {class: 'home'}) do | |
10 | 10 | = link_to "Profile", profile_path |
11 | - = nav_link(path: 'profile#account') do | |
12 | - = link_to "Account", profile_account_path | |
11 | + = nav_link(path: 'profiles#account') do | |
12 | + = link_to "Account", account_profile_path | |
13 | 13 | = nav_link(controller: :keys) do |
14 | 14 | = link_to keys_path do |
15 | 15 | SSH Keys |
16 | 16 | %span.count= current_user.keys.count |
17 | - = nav_link(path: 'profile#design') do | |
18 | - = link_to "Design", profile_design_path | |
19 | - = nav_link(path: 'profile#history') do | |
20 | - = link_to "History", profile_history_path | |
17 | + = nav_link(path: 'profiles#design') do | |
18 | + = link_to "Design", design_profile_path | |
19 | + = nav_link(path: 'profiles#history') do | |
20 | + = link_to "History", history_profile_path | |
21 | 21 | |
22 | 22 | .content= yield | ... | ... |
app/views/profile/account.html.haml
... | ... | @@ -1,69 +0,0 @@ |
1 | -- if Gitlab.config.omniauth_enabled? | |
2 | - %fieldset | |
3 | - %legend Social Accounts | |
4 | - .oauth_select_holder | |
5 | - %p.hint Tip: Click on icon to activate sigin with one of the following services | |
6 | - - User.omniauth_providers.each do |provider| | |
7 | - %span{class: oauth_active_class(provider) } | |
8 | - = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider) | |
9 | - | |
10 | - | |
11 | - | |
12 | -%fieldset | |
13 | - %legend | |
14 | - Private token | |
15 | - %span.cred.right | |
16 | - keep it secret! | |
17 | - .padded | |
18 | - = form_for @user, url: profile_reset_private_token_path, method: :put do |f| | |
19 | - .data | |
20 | - %p.slead | |
21 | - Private token used to access application resources without authentication. | |
22 | - %br | |
23 | - It can be used for atom feed or API | |
24 | - %p.cgray | |
25 | - - if current_user.private_token | |
26 | - = text_field_tag "token", current_user.private_token, class: "xxlarge large_text" | |
27 | - = f.submit 'Reset', confirm: "Are you sure?", class: "btn primary btn-build-token" | |
28 | - - else | |
29 | - %span You don`t have one yet. Click generate to fix it. | |
30 | - = f.submit 'Generate', class: "btn success btn-build-token" | |
31 | - | |
32 | -%fieldset | |
33 | - %legend Password | |
34 | - = form_for @user, url: profile_password_path, method: :put do |f| | |
35 | - .padded | |
36 | - %p.slead After successful password update you will be redirected to login page where you should login with new password | |
37 | - -if @user.errors.any? | |
38 | - .alert-message.block-message.error | |
39 | - %ul | |
40 | - - @user.errors.full_messages.each do |msg| | |
41 | - %li= msg | |
42 | - | |
43 | - .clearfix | |
44 | - = f.label :password | |
45 | - .input= f.password_field :password, required: true | |
46 | - .clearfix | |
47 | - = f.label :password_confirmation | |
48 | - .input | |
49 | - = f.password_field :password_confirmation, required: true | |
50 | - .clearfix | |
51 | - .input | |
52 | - = f.submit 'Save password', class: "btn save-btn" | |
53 | - | |
54 | - | |
55 | - | |
56 | -%fieldset | |
57 | - %legend | |
58 | - Username | |
59 | - %small.right | |
60 | - Changing your username can have unintended side effects! | |
61 | - = form_for @user, url: profile_update_path, method: :put do |f| | |
62 | - .padded | |
63 | - = f.label :username | |
64 | - .input | |
65 | - = f.text_field :username, required: true | |
66 | - .input | |
67 | - = f.submit 'Save username', class: "btn save-btn" | |
68 | - | |
69 | - |
app/views/profile/design.html.haml
... | ... | @@ -1,52 +0,0 @@ |
1 | -= form_for @user, url: profile_update_path, remote: true, method: :put do |f| | |
2 | - %fieldset.application-theme | |
3 | - %legend | |
4 | - Application theme | |
5 | - .update-feedback.hide | |
6 | - %i.icon-ok | |
7 | - Saved | |
8 | - .themes_opts | |
9 | - = label_tag do | |
10 | - .prev.default | |
11 | - = f.radio_button :theme_id, 1 | |
12 | - Default | |
13 | - | |
14 | - = label_tag do | |
15 | - .prev.classic | |
16 | - = f.radio_button :theme_id, 2 | |
17 | - Classic | |
18 | - | |
19 | - = label_tag do | |
20 | - .prev.modern | |
21 | - = f.radio_button :theme_id, 3 | |
22 | - Modern | |
23 | - | |
24 | - = label_tag do | |
25 | - .prev.gray | |
26 | - = f.radio_button :theme_id, 4 | |
27 | - SlateGray | |
28 | - | |
29 | - = label_tag do | |
30 | - .prev.violet | |
31 | - = f.radio_button :theme_id, 5 | |
32 | - Violet | |
33 | - %br | |
34 | - .clearfix | |
35 | - | |
36 | - %fieldset.code-preview-theme | |
37 | - %legend | |
38 | - Code preview theme | |
39 | - .update-feedback.hide | |
40 | - %i.icon-ok | |
41 | - Saved | |
42 | - .code_highlight_opts | |
43 | - = label_tag do | |
44 | - .prev | |
45 | - = image_tag "white.png" | |
46 | - = f.radio_button :dark_scheme, false | |
47 | - White code preview | |
48 | - = label_tag do | |
49 | - .prev | |
50 | - = image_tag "dark.png" | |
51 | - = f.radio_button :dark_scheme, true | |
52 | - Dark code preview |
app/views/profile/history.html.haml
app/views/profile/index.html.haml
... | ... | @@ -1 +0,0 @@ |
1 | -%h1 Profile |
app/views/profile/show.html.haml
... | ... | @@ -1,82 +0,0 @@ |
1 | -.profile_avatar_holder | |
2 | - = image_tag gravatar_icon(@user.email, 90) | |
3 | -%h3.page_title | |
4 | - = @user.name | |
5 | - %br | |
6 | - %small | |
7 | - = @user.email | |
8 | - | |
9 | -%hr | |
10 | - | |
11 | -= form_for @user, url: profile_update_path, method: :put, html: { class: "edit_user form-horizontal" } do |f| | |
12 | - -if @user.errors.any? | |
13 | - %div.alert-message.block-message.error | |
14 | - %ul | |
15 | - - @user.errors.full_messages.each do |msg| | |
16 | - %li= msg | |
17 | - .row | |
18 | - .span7 | |
19 | - .control-group | |
20 | - = f.label :name, class: "control-label" | |
21 | - .controls | |
22 | - = f.text_field :name, class: "input-xlarge", required: true | |
23 | - %span.help-block Enter your name, so people you know can recognize you. | |
24 | - .control-group | |
25 | - = f.label :email, class: "control-label" | |
26 | - .controls | |
27 | - = f.text_field :email, class: "input-xlarge", required: true | |
28 | - %span.help-block We also use email for avatar detection. | |
29 | - | |
30 | - .span5.right | |
31 | - %fieldset.tips | |
32 | - %legend Tips: | |
33 | - %ul | |
34 | - %li | |
35 | - %p You can change your password on Account page | |
36 | - -unless Gitlab.config.disable_gravatar? | |
37 | - %li | |
38 | - %p You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"} | |
39 | - | |
40 | - - if Gitlab.config.omniauth_enabled? && @user.provider? | |
41 | - %li | |
42 | - %p.hint | |
43 | - You can login through #{@user.provider.titleize}! | |
44 | - = link_to "click here to change", profile_account_path | |
45 | - | |
46 | - .row | |
47 | - .span7 | |
48 | - .control-group | |
49 | - = f.label :skype, class: "control-label" | |
50 | - .controls= f.text_field :skype, class: "input-xlarge" | |
51 | - .control-group | |
52 | - = f.label :linkedin, class: "control-label" | |
53 | - .controls= f.text_field :linkedin, class: "input-xlarge" | |
54 | - .control-group | |
55 | - = f.label :twitter, class: "control-label" | |
56 | - .controls= f.text_field :twitter, class: "input-xlarge" | |
57 | - .control-group | |
58 | - = f.label :bio, class: "control-label" | |
59 | - .controls | |
60 | - = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250 | |
61 | - %span.help-block Tell us about yourself in fewer than 250 characters. | |
62 | - .span5.right | |
63 | - %fieldset | |
64 | - %legend | |
65 | - Personal projects: | |
66 | - %small.right | |
67 | - %span= current_user.my_own_projects.count | |
68 | - of | |
69 | - %span= current_user.projects_limit | |
70 | - .padded | |
71 | - .progress | |
72 | - .bar{style: "width: #{current_user.projects_limit_percent}%;"} | |
73 | - | |
74 | - %fieldset | |
75 | - %legend | |
76 | - SSH public keys: | |
77 | - %strong.right= link_to current_user.keys.count, keys_path | |
78 | - .padded | |
79 | - = link_to "Add Public Key", new_key_path, class: "btn small" | |
80 | - | |
81 | - .form-actions | |
82 | - = f.submit 'Save', class: "btn save-btn" |
app/views/profile/update.js.erb
... | ... | @@ -1,9 +0,0 @@ |
1 | -// Remove body class for any previous theme, re-add current one | |
2 | -$('body').removeClass('ui_basic ui_mars ui_modern ui_gray ui_color') | |
3 | -$('body').addClass('<%= app_theme %>') | |
4 | - | |
5 | -// Re-render the header to reflect the new theme | |
6 | -$('header').html('<%= escape_javascript(render("layouts/head_panel", title: "Profile")) %>') | |
7 | - | |
8 | -// Re-initialize header tooltips | |
9 | -$('.has_bottom_tooltip').tooltip({placement: 'bottom'}) |
... | ... | @@ -0,0 +1,77 @@ |
1 | +- if Gitlab.config.omniauth_enabled? | |
2 | + %fieldset | |
3 | + %legend Social Accounts | |
4 | + .oauth_select_holder | |
5 | + %p.hint Tip: Click on icon to activate sigin with one of the following services | |
6 | + - User.omniauth_providers.each do |provider| | |
7 | + %span{class: oauth_active_class(provider) } | |
8 | + = link_to authbutton(provider, 32), omniauth_authorize_path(User, provider) | |
9 | + | |
10 | + | |
11 | + | |
12 | +%fieldset | |
13 | + %legend | |
14 | + Private token | |
15 | + %span.cred.right | |
16 | + keep it secret! | |
17 | + .padded | |
18 | + = form_for @user, url: reset_private_token_profile_path, method: :put do |f| | |
19 | + .data | |
20 | + %p.slead | |
21 | + Private token used to access application resources without authentication. | |
22 | + %br | |
23 | + It can be used for atom feed or API | |
24 | + %p.cgray | |
25 | + - if current_user.private_token | |
26 | + = text_field_tag "token", current_user.private_token, class: "xxlarge large_text" | |
27 | + = f.submit 'Reset', confirm: "Are you sure?", class: "btn primary btn-build-token" | |
28 | + - else | |
29 | + %span You don`t have one yet. Click generate to fix it. | |
30 | + = f.submit 'Generate', class: "btn success btn-build-token" | |
31 | + | |
32 | +%fieldset | |
33 | + %legend Password | |
34 | + = form_for @user, url: update_password_profile_path, method: :put do |f| | |
35 | + .padded | |
36 | + %p.slead After successful password update you will be redirected to login page where you should login with new password | |
37 | + -if @user.errors.any? | |
38 | + .alert-message.block-message.error | |
39 | + %ul | |
40 | + - @user.errors.full_messages.each do |msg| | |
41 | + %li= msg | |
42 | + | |
43 | + .clearfix | |
44 | + = f.label :password | |
45 | + .input= f.password_field :password, required: true | |
46 | + .clearfix | |
47 | + = f.label :password_confirmation | |
48 | + .input | |
49 | + = f.password_field :password_confirmation, required: true | |
50 | + .clearfix | |
51 | + .input | |
52 | + = f.submit 'Save password', class: "btn save-btn" | |
53 | + | |
54 | + | |
55 | + | |
56 | +%fieldset.update-username | |
57 | + %legend | |
58 | + Username | |
59 | + %small.cred.right | |
60 | + Changing your username can have unintended side effects! | |
61 | + = form_for @user, url: update_username_profile_path, method: :put, remote: true do |f| | |
62 | + .padded | |
63 | + = f.label :username | |
64 | + .input | |
65 | + = f.text_field :username, required: true | |
66 | + | |
67 | + %span.loading-gif.hide= image_tag "ajax_loader.gif" | |
68 | + %span.update-success.cgreen.hide | |
69 | + %i.icon-ok | |
70 | + Saved | |
71 | + %span.update-failed.cred.hide | |
72 | + %i.icon-ok | |
73 | + Failed | |
74 | + .input | |
75 | + = f.submit 'Save username', class: "btn save-btn" | |
76 | + | |
77 | + | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | += form_for @user, url: profile_path, remote: true, method: :put do |f| | |
2 | + %fieldset.application-theme | |
3 | + %legend | |
4 | + Application theme | |
5 | + .update-feedback.hide | |
6 | + %i.icon-ok | |
7 | + Saved | |
8 | + .themes_opts | |
9 | + = label_tag do | |
10 | + .prev.default | |
11 | + = f.radio_button :theme_id, 1 | |
12 | + Default | |
13 | + | |
14 | + = label_tag do | |
15 | + .prev.classic | |
16 | + = f.radio_button :theme_id, 2 | |
17 | + Classic | |
18 | + | |
19 | + = label_tag do | |
20 | + .prev.modern | |
21 | + = f.radio_button :theme_id, 3 | |
22 | + Modern | |
23 | + | |
24 | + = label_tag do | |
25 | + .prev.gray | |
26 | + = f.radio_button :theme_id, 4 | |
27 | + SlateGray | |
28 | + | |
29 | + = label_tag do | |
30 | + .prev.violet | |
31 | + = f.radio_button :theme_id, 5 | |
32 | + Violet | |
33 | + %br | |
34 | + .clearfix | |
35 | + | |
36 | + %fieldset.code-preview-theme | |
37 | + %legend | |
38 | + Code preview theme | |
39 | + .update-feedback.hide | |
40 | + %i.icon-ok | |
41 | + Saved | |
42 | + .code_highlight_opts | |
43 | + = label_tag do | |
44 | + .prev | |
45 | + = image_tag "white.png" | |
46 | + = f.radio_button :dark_scheme, false | |
47 | + White code preview | |
48 | + = label_tag do | |
49 | + .prev | |
50 | + = image_tag "dark.png" | |
51 | + = f.radio_button :dark_scheme, true | |
52 | + Dark code preview | ... | ... |
... | ... | @@ -0,0 +1,82 @@ |
1 | +.profile_avatar_holder | |
2 | + = image_tag gravatar_icon(@user.email, 90) | |
3 | +%h3.page_title | |
4 | + = @user.name | |
5 | + %br | |
6 | + %small | |
7 | + = @user.email | |
8 | + | |
9 | +%hr | |
10 | + | |
11 | += form_for @user, url: profile_path, method: :put, html: { class: "edit_user form-horizontal" } do |f| | |
12 | + -if @user.errors.any? | |
13 | + %div.alert-message.block-message.error | |
14 | + %ul | |
15 | + - @user.errors.full_messages.each do |msg| | |
16 | + %li= msg | |
17 | + .row | |
18 | + .span7 | |
19 | + .control-group | |
20 | + = f.label :name, class: "control-label" | |
21 | + .controls | |
22 | + = f.text_field :name, class: "input-xlarge", required: true | |
23 | + %span.help-block Enter your name, so people you know can recognize you. | |
24 | + .control-group | |
25 | + = f.label :email, class: "control-label" | |
26 | + .controls | |
27 | + = f.text_field :email, class: "input-xlarge", required: true | |
28 | + %span.help-block We also use email for avatar detection. | |
29 | + | |
30 | + .span5.right | |
31 | + %fieldset.tips | |
32 | + %legend Tips: | |
33 | + %ul | |
34 | + %li | |
35 | + %p You can change your password on Account page | |
36 | + -unless Gitlab.config.disable_gravatar? | |
37 | + %li | |
38 | + %p You can change your avatar at #{link_to "gravatar.com", "http://gravatar.com"} | |
39 | + | |
40 | + - if Gitlab.config.omniauth_enabled? && @user.provider? | |
41 | + %li | |
42 | + %p | |
43 | + You can login through #{@user.provider.titleize}! | |
44 | + = link_to "click here to change", account_profile_path | |
45 | + | |
46 | + .row | |
47 | + .span7 | |
48 | + .control-group | |
49 | + = f.label :skype, class: "control-label" | |
50 | + .controls= f.text_field :skype, class: "input-xlarge" | |
51 | + .control-group | |
52 | + = f.label :linkedin, class: "control-label" | |
53 | + .controls= f.text_field :linkedin, class: "input-xlarge" | |
54 | + .control-group | |
55 | + = f.label :twitter, class: "control-label" | |
56 | + .controls= f.text_field :twitter, class: "input-xlarge" | |
57 | + .control-group | |
58 | + = f.label :bio, class: "control-label" | |
59 | + .controls | |
60 | + = f.text_area :bio, rows: 6, class: "input-xlarge", maxlength: 250 | |
61 | + %span.help-block Tell us about yourself in fewer than 250 characters. | |
62 | + .span5.right | |
63 | + %fieldset | |
64 | + %legend | |
65 | + Personal projects: | |
66 | + %small.right | |
67 | + %span= current_user.my_own_projects.count | |
68 | + of | |
69 | + %span= current_user.projects_limit | |
70 | + .padded | |
71 | + .progress | |
72 | + .bar{style: "width: #{current_user.projects_limit_percent}%;"} | |
73 | + | |
74 | + %fieldset | |
75 | + %legend | |
76 | + SSH public keys: | |
77 | + %strong.right= link_to current_user.keys.count, keys_path | |
78 | + .padded | |
79 | + = link_to "Add Public Key", new_key_path, class: "btn small" | |
80 | + | |
81 | + .form-actions | |
82 | + = f.submit 'Save', class: "btn save-btn" | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +// Remove body class for any previous theme, re-add current one | |
2 | +$('body').removeClass('ui_basic ui_mars ui_modern ui_gray ui_color') | |
3 | +$('body').addClass('<%= app_theme %>') | |
4 | + | |
5 | +// Re-render the header to reflect the new theme | |
6 | +$('header').html('<%= escape_javascript(render("layouts/head_panel", title: "Profile")) %>') | |
7 | + | |
8 | +// Re-initialize header tooltips | |
9 | +$('.has_bottom_tooltip').tooltip({placement: 'bottom'}) | ... | ... |
config/routes.rb
... | ... | @@ -69,14 +69,18 @@ Gitlab::Application.routes.draw do |
69 | 69 | # |
70 | 70 | # Profile Area |
71 | 71 | # |
72 | - get "profile/account" => "profile#account" | |
73 | - get "profile/history" => "profile#history" | |
74 | - put "profile/password" => "profile#password_update" | |
75 | - get "profile/token" => "profile#token" | |
76 | - put "profile/reset_private_token" => "profile#reset_private_token" | |
77 | - get "profile" => "profile#show" | |
78 | - get "profile/design" => "profile#design" | |
79 | - put "profile/update" => "profile#update" | |
72 | + resource :profile, only: [:show, :update] do | |
73 | + member do | |
74 | + get :account | |
75 | + get :history | |
76 | + get :token | |
77 | + get :design | |
78 | + | |
79 | + put :update_password | |
80 | + put :reset_private_token | |
81 | + put :update_username | |
82 | + end | |
83 | + end | |
80 | 84 | |
81 | 85 | resources :keys |
82 | 86 | ... | ... |
features/steps/shared/paths.rb
... | ... | @@ -54,7 +54,7 @@ module SharedPaths |
54 | 54 | end |
55 | 55 | |
56 | 56 | Given 'I visit profile account page' do |
57 | - visit profile_account_path | |
57 | + visit account_profile_path | |
58 | 58 | end |
59 | 59 | |
60 | 60 | Given 'I visit profile SSH keys page' do |
... | ... | @@ -62,15 +62,11 @@ module SharedPaths |
62 | 62 | end |
63 | 63 | |
64 | 64 | Given 'I visit profile design page' do |
65 | - visit profile_design_path | |
65 | + visit design_profile_path | |
66 | 66 | end |
67 | 67 | |
68 | 68 | Given 'I visit profile history page' do |
69 | - visit profile_history_path | |
70 | - end | |
71 | - | |
72 | - Given 'I visit profile token page' do | |
73 | - visit profile_token_path | |
69 | + visit history_profile_path | |
74 | 70 | end |
75 | 71 | |
76 | 72 | # ---------------------------------------- | ... | ... |
spec/requests/security/profile_access_spec.rb
... | ... | @@ -29,7 +29,16 @@ describe "Users Security" do |
29 | 29 | end |
30 | 30 | |
31 | 31 | describe "GET /profile/account" do |
32 | - subject { profile_account_path } | |
32 | + subject { account_profile_path } | |
33 | + | |
34 | + it { should be_allowed_for @u1 } | |
35 | + it { should be_allowed_for :admin } | |
36 | + it { should be_allowed_for :user } | |
37 | + it { should be_denied_for :visitor } | |
38 | + end | |
39 | + | |
40 | + describe "GET /profile/design" do | |
41 | + subject { design_profile_path } | |
33 | 42 | |
34 | 43 | it { should be_allowed_for @u1 } |
35 | 44 | it { should be_allowed_for :admin } | ... | ... |
spec/routing/routing_spec.rb
... | ... | @@ -82,37 +82,25 @@ end |
82 | 82 | # profile GET /profile(.:format) profile#show |
83 | 83 | # profile_design GET /profile/design(.:format) profile#design |
84 | 84 | # profile_update PUT /profile/update(.:format) profile#update |
85 | -describe ProfileController, "routing" do | |
85 | +describe ProfilesController, "routing" do | |
86 | 86 | it "to #account" do |
87 | - get("/profile/account").should route_to('profile#account') | |
87 | + get("/profile/account").should route_to('profiles#account') | |
88 | 88 | end |
89 | 89 | |
90 | 90 | it "to #history" do |
91 | - get("/profile/history").should route_to('profile#history') | |
92 | - end | |
93 | - | |
94 | - it "to #password_update" do | |
95 | - put("/profile/password").should route_to('profile#password_update') | |
96 | - end | |
97 | - | |
98 | - it "to #token" do | |
99 | - get("/profile/token").should route_to('profile#token') | |
91 | + get("/profile/history").should route_to('profiles#history') | |
100 | 92 | end |
101 | 93 | |
102 | 94 | it "to #reset_private_token" do |
103 | - put("/profile/reset_private_token").should route_to('profile#reset_private_token') | |
95 | + put("/profile/reset_private_token").should route_to('profiles#reset_private_token') | |
104 | 96 | end |
105 | 97 | |
106 | 98 | it "to #show" do |
107 | - get("/profile").should route_to('profile#show') | |
99 | + get("/profile").should route_to('profiles#show') | |
108 | 100 | end |
109 | 101 | |
110 | 102 | it "to #design" do |
111 | - get("/profile/design").should route_to('profile#design') | |
112 | - end | |
113 | - | |
114 | - it "to #update" do | |
115 | - put("/profile/update").should route_to('profile#update') | |
103 | + get("/profile/design").should route_to('profiles#design') | |
116 | 104 | end |
117 | 105 | end |
118 | 106 | ... | ... |