From f3605a12119df3f7401b14add5187748526e6e17 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 15 Oct 2012 19:47:42 +0400 Subject: [PATCH] #691: updated routes according to Vladimir's comments --- app/controllers/api/v1/users_controller.rb | 10 ++++------ config/routes.rb | 3 ++- spec/controllers/api/v1/users_controller_spec.rb | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 6d02fcd1c..8915a301c 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -7,12 +7,10 @@ class Api::V1::UsersController < Api::V1::BaseController before_filter :set_current_user, :except => :show def show - @user = current_user if params[:id].nil? - if @user - render :show - else - render_403 - end + end + + def show_current_user + render :show end def update diff --git a/config/routes.rb b/config/routes.rb index bdc9817a4..1e51693f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,7 +48,8 @@ Rosa::Application.routes.draw do } end resources :users, :only => [:show] - resource :user, :only => [:show, :update] do + get 'user' => 'users#show_current_user' + resource :user, :only => [:update] do member { get :notifiers put :notifiers diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index 14f4f36d4..bad6ffc8e 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -10,7 +10,7 @@ describe Api::V1::UsersController do context 'for guest' do - [:show, :notifiers].each do |action| + [:show_current_user, :notifiers].each do |action| it "should not be able to perform #{ action } action for a current user" do get action, :format => :json response.should_not be_success @@ -56,10 +56,10 @@ describe Api::V1::UsersController do http_login(@user) end - [:show, :notifiers].each do |action| + [:show_current_user, :notifiers].each do |action| it "should be able to perform #{ action } action for a current user" do get action, :format => :json - response.should render_template(action) + response.should be_success end end