Commit 1fb87983

mo k <mo@mokhan.ca>
2012-05-26 13:19:38
try to write a single test for the registrations controller, but i keep getting a silly undefined 'name' method error on nilclass:nil
1 parent 64fa364
Changed files (2)
app/controllers/registrations_controller.rb
@@ -4,8 +4,6 @@ class RegistrationsController < Devise::RegistrationsController
   end
 
   def update
-    params "PARAMS: #{params[:user]}"
-    logger.info("PARAMS: #{params[:user]}")
     @user = current_user
     if params[:user][:password].blank? 
       if @user.update_without_password(params[:user])
spec/controllers/registrations_controller_spec.rb
@@ -1,42 +1,53 @@
 require 'spec_helper'
 #module Devise
-  #class RegistrationsController
+#class RegistrationsController
 
-  #end
+#end
 #end
 
 describe RegistrationsController do
   before (:each) do
-    request.env['warden'] = mock(Warden, :authenticate => user, :authenticate! => user)
+    #request.env['warden'] = mock(Warden, :authenticate => user, :authenticate! => user)
   end
-  let(:user){ FactoryGirl.build(:user) }
+  #let(:user){ FactoryGirl.build(:user) }
+  let(:user){ User.new( :id => 2) }
 
   context "when updating a users profile settings not including their password" do
     it "should update their website" do
       controller = RegistrationsController.new
+      controller.stub(:current_user).and_return(user)
 
-      blah = {
-        :current_password =>'',
-        :email => '',
-        :facebook => '',
-        #:name =>'',
+      payload = {
+        :current_password => '',
+        :email => 'mo@mokhan.ca',
+        :facebook => 'mo',
+        :name =>'mo',
         :password => '',
         :password_confirmation => '',
-        :twitter => '',
-        :website => '',
+        :twitter => 'mocheen',
+        :website => 'http://mokhan.ca/',
       }
 
-      #user.should_receive[:update_without_password].with(blah)
-      #controller.update
-      put :update, :user => {:hello => "mo"}
+      #user.should_receive[:update_without_password].with(payload)
+      #put :update, :id => user.id, :user => payload
     end
     it "should not change their password" do
-      
+
     end
   end
   context "when updating a users pasword" do
     it "should update their password" do
-      
+
     end
   end
 end
+
+#HTTP GET /creations/ => creations#index
+#HTTP GET /creations/1 => creations#show
+#HTTP GET /creations/1/edit => creations#edit
+#HTTP PUT /creations/1 => creations#update
+#HTTP POST /creations/ => creations#create
+#HTTP DELETE /creations/1 => creations#destroy
+
+
+