diff options
| author | mo khan <mo@mokhan.ca> | 2014-05-21 22:43:19 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-05-21 22:43:19 -0600 |
| commit | e49bef1d3606217baeba3efbaa44ce5f11f2c93e (patch) | |
| tree | 15719e332e48c188b683eedd658067c000b616c9 | |
| parent | 0e1f35bf3f1a023e3f71b916ec5927ab46800249 (diff) | |
move avatars to my/avatars.
| -rw-r--r-- | app/controllers/avatars_controller.rb | 23 | ||||
| -rw-r--r-- | app/controllers/my/avatars_controller.rb | 24 | ||||
| -rw-r--r-- | app/views/my/avatars/edit.html.erb (renamed from app/views/avatars/edit.html.erb) | 2 | ||||
| -rw-r--r-- | app/views/shared/_account_nav.html.erb | 2 | ||||
| -rw-r--r-- | config/routes.rb | 9 | ||||
| -rw-r--r-- | spec/controllers/my/avatars_controller_spec.rb (renamed from spec/controllers/avatars_controller_spec.rb) | 4 | ||||
| -rw-r--r-- | spec/features/upload_avatar_spec.rb | 2 |
7 files changed, 30 insertions, 36 deletions
diff --git a/app/controllers/avatars_controller.rb b/app/controllers/avatars_controller.rb deleted file mode 100644 index de803eb7..00000000 --- a/app/controllers/avatars_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -class AvatarsController < ApplicationController - before_filter :authenticate_user! - before_filter :find_or_build_avatar - - def edit - end - - def update - @avatar.attach(params[:avatar][:avatar]) - redirect_to edit_avatar_path(current_user), :notice => t(:avatar_uploaded) - end - - protected - - def find_or_build_avatar - if current_user.avatar == nil - @avatar = current_user.avatar = Avatar.new - current_user.save - else - @avatar = current_user.avatar - end - end -end diff --git a/app/controllers/my/avatars_controller.rb b/app/controllers/my/avatars_controller.rb new file mode 100644 index 00000000..cb534ba9 --- /dev/null +++ b/app/controllers/my/avatars_controller.rb @@ -0,0 +1,24 @@ +module My + class AvatarsController < BaseController + before_filter :find_or_build_avatar + + def edit + end + + def update + @avatar.attach(params[:avatar][:avatar]) + redirect_to edit_my_avatar_path(current_user), :notice => t(:avatar_uploaded) + end + + protected + + def find_or_build_avatar + if current_user.avatar == nil + @avatar = current_user.avatar = Avatar.new + current_user.save + else + @avatar = current_user.avatar + end + end + end +end diff --git a/app/views/avatars/edit.html.erb b/app/views/my/avatars/edit.html.erb index 394f70e1..d33dd6a1 100644 --- a/app/views/avatars/edit.html.erb +++ b/app/views/my/avatars/edit.html.erb @@ -8,7 +8,7 @@ try { mixpanel.track_forms(".edit_avatar", "uploaded avatar"); } catch {} <div class="row"> <div class="span12"> <%= avatar_for(current_user) %> - <%= form_for(@avatar, :url => avatar_path(@avatar), :method => :put, :multipart => true, remote: true, authenticity_token: true) do |f| %> + <%= form_for(@avatar, :url => my_avatar_path(@avatar), :method => :put, :multipart => true, remote: true, authenticity_token: true) do |f| %> <div class="control-group"> <div class="controls"> <%= f.file_field :avatar %> diff --git a/app/views/shared/_account_nav.html.erb b/app/views/shared/_account_nav.html.erb index e65fdf21..a33c9a6f 100644 --- a/app/views/shared/_account_nav.html.erb +++ b/app/views/shared/_account_nav.html.erb @@ -6,7 +6,7 @@ <li class="<%= selected == :favorites ? "active" : "" %>"><%= link_to "Favorites", my_favorites_path %></li> <li class="<%= selected == :basic_info ? "active" : "" %>"><%= link_to "Settings", my_settings_path %></li> <li class="<%= selected == :password ? "active" : "" %>"><%= link_to "Password", my_passwords_path %></li> - <li class="<%= selected == :picture ? "active" : "" %>"><%= link_to "Picture", edit_avatar_path(current_user) %></li> + <li class="<%= selected == :picture ? "active" : "" %>"><%= link_to "Picture", edit_my_avatar_path(current_user) %></li> <li class="pull-right"><%= link_to t('.logout'), destroy_user_session_path, class: "btn btn-inverse" %></li> <% if current_user.is_admin? %> <li class="pull-right"><%= link_to t('.admin'), admin_root_path %></li> diff --git a/config/routes.rb b/config/routes.rb index 0c415238..90ab2c22 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ Cake::Application.routes.draw do - # /home get "about_us" => "home#about_us" get "why_cakeside" => "home#why_cakeside" @@ -18,13 +17,10 @@ Cake::Application.routes.draw do get 'page/:page', :action => :index, :on => :collection end - # /profiles resources :profiles, :only => [:index, :show] do get 'page/:page', :action => :index, :on => :collection end - #get 'favorites' => 'profiles#favorites', :as => 'profiles_favorites' - # /categories get 'categories/:slug' => "categories#show", :as => :category get 'categories/:slug/page/:page' => "categories#show" @@ -43,8 +39,6 @@ Cake::Application.routes.draw do # sitemap get "/sitemap.xml", :to => "sitemap#index", :defaults => {:format => :xml} - resources :avatars, :only => [:edit, :update] - root :to => "creations#index" namespace :api, :defaults => { :format => 'json' } do @@ -69,7 +63,6 @@ Cake::Application.routes.draw do resources :favorites, only: [:index] resources :settings, only: [:index, :update] resources :passwords, only: [:index, :update] - #get 'pwd' => "passwords#index" - #patch 'pwd' => "passwords#update" + resources :avatars, :only => [:edit, :update] end end diff --git a/spec/controllers/avatars_controller_spec.rb b/spec/controllers/my/avatars_controller_spec.rb index 0a38ddb7..66ded19f 100644 --- a/spec/controllers/avatars_controller_spec.rb +++ b/spec/controllers/my/avatars_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe AvatarsController do +describe My::AvatarsController do let(:user) { create(:user) } context "when logged in " do @@ -18,7 +18,7 @@ describe AvatarsController do end it "should redirect to the avatar page" do - response.should redirect_to edit_avatar_path(user) + response.should redirect_to edit_my_avatar_path(user) end it "should display a flash notice" do diff --git a/spec/features/upload_avatar_spec.rb b/spec/features/upload_avatar_spec.rb index af6e5f84..fb2cf2d8 100644 --- a/spec/features/upload_avatar_spec.rb +++ b/spec/features/upload_avatar_spec.rb @@ -10,7 +10,7 @@ describe "uploading an avatar" do fill_in('user_password', :with => "password") end click_button("Sign In") - visit edit_avatar_path(user) + visit edit_my_avatar_path(user) file = File.expand_path(File.join(Rails.root, '/spec/fixtures/images/gorilla.jpg')) within(".edit_avatar") do attach_file('avatar_avatar', file) |
