Commit 91d6e13c

mo khan <mo@mokhan.ca>
2013-06-30 17:28:46
create passwords#index action
1 parent f0c61dc
Changed files (4)
app/controllers/passwords_controller.rb
@@ -1,16 +1,17 @@
 class PasswordsController < ApplicationController
   before_filter :authenticate_user!
 
-  def show
+  def index
+    @user = current_user
   end
 
   def update
     user = User.find(params[:id])
     if user.change_password(params[:user][:password], params[:user][:password_confirmation])
-      render :show
+      render :index
     else
       flash[:alert] = t(:passwords_do_not_match)
-      render :show
+      render :index
     end
   end
 end
app/views/passwords/show.html.erb → app/views/passwords/index.html.erb
File renamed without changes
config/routes.rb
@@ -45,7 +45,7 @@ Cake::Application.routes.draw do
 
   match 'settings/change_password' => 'settings#change_password', :as => 'settings_change_password', :method => 'POST'
 
-  resources :passwords, :only => [:update]
+  resources :passwords, :only => [:index, :update]
 
   ActiveAdmin.routes(self)
 
spec/controllers/passwords_controller_spec.rb
@@ -24,7 +24,7 @@ describe PasswordsController do
         end
 
         it "should render the show template" do
-          response.should render_template(:show)
+          response.should render_template(:index)
         end
       end
 
@@ -40,5 +40,24 @@ describe PasswordsController do
         end
       end
     end
+
+  end
+
+  describe :index do
+    context 'when logged in' do
+      let(:user) { FactoryGirl.create(:user) }
+
+      before :each do
+        http_login(user)
+        get :index
+      end
+
+      context "when displaying a form to change the current password" do
+        it "should load the user" do
+          assigns(:user).should == user
+        end
+      end
+
+    end
   end
 end