diff options
23 files changed, 58 insertions, 57 deletions
diff --git a/app/controllers/keys_controller.rb b/app/controllers/profiles/keys_controller.rb index 1a25d834e12..24a01040f52 100644 --- a/app/controllers/keys_controller.rb +++ b/app/controllers/profiles/keys_controller.rb @@ -1,6 +1,5 @@ -class KeysController < ApplicationController +class Profiles::KeysController < ApplicationController layout "profile" - respond_to :js, :html def index @keys = current_user.keys.all @@ -12,15 +11,16 @@ class KeysController < ApplicationController def new @key = current_user.keys.new - - respond_with(@key) end def create @key = current_user.keys.new(params[:key]) - @key.save - respond_with(@key) + if @key.save + redirect_to profile_key_path(@key) + else + render 'new' + end end def destroy @@ -28,7 +28,7 @@ class KeysController < ApplicationController @key.destroy respond_to do |format| - format.html { redirect_to keys_url } + format.html { redirect_to profile_keys_url } format.js { render nothing: true } end end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/profiles/notifications_controller.rb index 370bdaa2fa1..5c492aeb49d 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/profiles/notifications_controller.rb @@ -1,4 +1,4 @@ -class NotificationsController < ApplicationController +class Profiles::NotificationsController < ApplicationController layout 'profile' def show diff --git a/app/controllers/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb index 0e5b42178a7..432899f857d 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/profiles/passwords_controller.rb @@ -1,4 +1,4 @@ -class PasswordsController < ApplicationController +class Profiles::PasswordsController < ApplicationController layout 'navless' skip_before_filter :check_password_expiration diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8ccb2380d62..4ab8cc87f75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -95,7 +95,7 @@ module ApplicationHelper default_nav = [ { label: "My Profile", url: profile_path }, - { label: "My SSH Keys", url: keys_path }, + { label: "My SSH Keys", url: profile_keys_path }, { label: "My Dashboard", url: root_path }, { label: "Admin Section", url: admin_root_path }, ] diff --git a/app/views/keys/_show.html.haml b/app/views/keys/_show.html.haml deleted file mode 100644 index 52bbea6fc7b..00000000000 --- a/app/views/keys/_show.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%tr - %td - = link_to key_path(key) do - %strong= key.title - %td - %span.cgray - Added - = time_ago_in_words(key.created_at) - ago - %td - = link_to 'Remove', key, confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" - diff --git a/app/views/keys/edit.html.haml b/app/views/keys/edit.html.haml deleted file mode 100644 index 60a3afedddc..00000000000 --- a/app/views/keys/edit.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%h1 Editing key - -= render 'form' - -= link_to 'Show', @key -\| -= link_to 'Back', keys_path diff --git a/app/views/layouts/nav/_profile.html.haml b/app/views/layouts/nav/_profile.html.haml index e5e4b27c665..c2db7067e44 100644 --- a/app/views/layouts/nav/_profile.html.haml +++ b/app/views/layouts/nav/_profile.html.haml @@ -7,7 +7,7 @@ = nav_link(controller: :notifications) do = link_to "Notifications", profile_notifications_path = nav_link(controller: :keys) do - = link_to keys_path do + = link_to profile_keys_path do SSH Keys %span.count= current_user.keys.count = nav_link(path: 'profiles#design') do diff --git a/app/views/keys/_form.html.haml b/app/views/profiles/keys/_form.html.haml index fe26216b1d5..59808d60022 100644 --- a/app/views/keys/_form.html.haml +++ b/app/views/profiles/keys/_form.html.haml @@ -1,6 +1,6 @@ %div - = form_for @key do |f| - -if @key.errors.any? + = form_for [:profile, @key] do |f| + - if @key.errors.any? .alert.alert-error %ul - @key.errors.full_messages.each do |msg| @@ -20,5 +20,5 @@ .actions = f.submit 'Save', class: "btn btn-save" - = link_to "Cancel", keys_path, class: "btn btn-cancel" + = link_to "Cancel", profile_keys_path, class: "btn btn-cancel" diff --git a/app/views/profiles/keys/_key.html.haml b/app/views/profiles/keys/_key.html.haml new file mode 100644 index 00000000000..a71ad6295cd --- /dev/null +++ b/app/views/profiles/keys/_key.html.haml @@ -0,0 +1,12 @@ +%tr + %td + = link_to profile_key_path(key) do + %strong= key.title + %td + %span.cgray + Added + = time_ago_in_words(key.created_at) + ago + %td + = link_to 'Remove', profile_key_path(key), confirm: 'Are you sure?', method: :delete, class: "btn btn-small btn-remove delete-key pull-right" + diff --git a/app/views/profiles/keys/edit.html.haml b/app/views/profiles/keys/edit.html.haml new file mode 100644 index 00000000000..08c5a3dfe1e --- /dev/null +++ b/app/views/profiles/keys/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing key + += render 'form' + += link_to 'Show', profile_keys_path(key) +\| += link_to 'Back', profile_keys_path diff --git a/app/views/keys/index.html.haml b/app/views/profiles/keys/index.html.haml index 7730b344a7d..b22805bc862 100644 --- a/app/views/keys/index.html.haml +++ b/app/views/profiles/keys/index.html.haml @@ -1,6 +1,6 @@ %h3.page_title SSH Keys - = link_to "Add new", new_key_path, class: "btn pull-right" + = link_to "Add new", new_profile_key_path, class: "btn pull-right" %hr %p.slead @@ -13,8 +13,7 @@ %th Name %th Added %th - - @keys.each do |key| - = render(partial: 'show', locals: {key: key}) + = render @keys - if @keys.blank? %tr %td{colspan: 3} diff --git a/app/views/keys/new.html.haml b/app/views/profiles/keys/new.html.haml index fff3805890e..fff3805890e 100644 --- a/app/views/keys/new.html.haml +++ b/app/views/profiles/keys/new.html.haml diff --git a/app/views/keys/show.html.haml b/app/views/profiles/keys/show.html.haml index 059fe5e5806..64c6621ea5f 100644 --- a/app/views/keys/show.html.haml +++ b/app/views/profiles/keys/show.html.haml @@ -5,10 +5,10 @@ created at = @key.created_at.stamp("Aug 21, 2011") .back_link - = link_to keys_path do + = link_to profile_keys_path do ← To keys list %hr %pre= @key.key .pull-right - = link_to 'Remove', @key, confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" + = link_to 'Remove', profile_key_path(@key), confirm: 'Are you sure?', method: :delete, class: "btn btn-remove delete-key" diff --git a/app/views/notifications/_settings.html.haml b/app/views/profiles/notifications/_settings.html.haml index 1a4a4a9f916..1a4a4a9f916 100644 --- a/app/views/notifications/_settings.html.haml +++ b/app/views/profiles/notifications/_settings.html.haml diff --git a/app/views/notifications/show.html.haml b/app/views/profiles/notifications/show.html.haml index 069747097c5..069747097c5 100644 --- a/app/views/notifications/show.html.haml +++ b/app/views/profiles/notifications/show.html.haml diff --git a/app/views/notifications/update.js.haml b/app/views/profiles/notifications/update.js.haml index 88e74d50671..88e74d50671 100644 --- a/app/views/notifications/update.js.haml +++ b/app/views/profiles/notifications/update.js.haml diff --git a/app/views/passwords/new.html.haml b/app/views/profiles/passwords/new.html.haml index c92424160b3..c92424160b3 100644 --- a/app/views/passwords/new.html.haml +++ b/app/views/profiles/passwords/new.html.haml diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 7ca2546afdf..7ca7583cd32 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -83,9 +83,9 @@ %legend SSH public keys: %span.pull-right - = link_to pluralize(current_user.keys.count, 'key'), keys_path + = link_to pluralize(current_user.keys.count, 'key'), profile_keys_path .padded - = link_to "Add Public Key", new_key_path, class: "btn btn-small" + = link_to "Add Public Key", new_profile_key_path, class: "btn btn-small" .form-actions = f.submit 'Save', class: "btn btn-save" diff --git a/config/routes.rb b/config/routes.rb index a59e6b7ce5b..c6b25e460cd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,11 +113,13 @@ Gitlab::Application.routes.draw do put :update_username end - resource :notifications, only: [:show, :update] - resource :password, only: [:new, :create] + scope module: :profiles do + resource :notifications, only: [:show, :update] + resource :password, only: [:new, :create] + resources :keys + end end - resources :keys match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ } diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index a280ce6f89c..7871eabcb5d 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -21,7 +21,7 @@ class ProfileSshKeys < Spinach::FeatureSteps key = Key.find_by_title("Laptop") page.should have_content(key.title) page.should have_content(key.key) - current_path.should == key_path(key) + current_path.should == profile_key_path(key) end Given 'I click link "Work"' do @@ -33,7 +33,7 @@ class ProfileSshKeys < Spinach::FeatureSteps end Then 'I visit profile keys page' do - visit keys_path + visit profile_keys_path end And 'I should not see "Work" ssh key' do diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 21b6159bce3..b2c23cf11c9 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -70,7 +70,7 @@ module SharedPaths end step 'I visit profile SSH keys page' do - visit keys_path + visit profile_keys_path end step 'I visit profile design page' do diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb index 6880d2819d1..112b825e023 100644 --- a/spec/routing/notifications_routing_spec.rb +++ b/spec/routing/notifications_routing_spec.rb @@ -1,13 +1,13 @@ require "spec_helper" -describe NotificationsController do +describe Profiles::NotificationsController do describe "routing" do it "routes to #show" do - get("/profile/notifications").should route_to("notifications#show") + get("/profile/notifications").should route_to("profiles/notifications#show") end it "routes to #update" do - put("/profile/notifications").should route_to("notifications#update") + put("/profile/notifications").should route_to("profiles/notifications#update") end end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index aa3952f74b6..cc2a141c454 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -155,33 +155,33 @@ end # key GET /keys/:id(.:format) keys#show # PUT /keys/:id(.:format) keys#update # DELETE /keys/:id(.:format) keys#destroy -describe KeysController, "routing" do +describe Profiles::KeysController, "routing" do it "to #index" do - get("/keys").should route_to('keys#index') + get("/profile/keys").should route_to('profiles/keys#index') end it "to #create" do - post("/keys").should route_to('keys#create') + post("/profile/keys").should route_to('profiles/keys#create') end it "to #new" do - get("/keys/new").should route_to('keys#new') + get("/profile/keys/new").should route_to('profiles/keys#new') end it "to #edit" do - get("/keys/1/edit").should route_to('keys#edit', id: '1') + get("/profile/keys/1/edit").should route_to('profiles/keys#edit', id: '1') end it "to #show" do - get("/keys/1").should route_to('keys#show', id: '1') + get("/profile/keys/1").should route_to('profiles/keys#show', id: '1') end it "to #update" do - put("/keys/1").should route_to('keys#update', id: '1') + put("/profile/keys/1").should route_to('profiles/keys#update', id: '1') end it "to #destroy" do - delete("/keys/1").should route_to('keys#destroy', id: '1') + delete("/profile/keys/1").should route_to('profiles/keys#destroy', id: '1') end end |