From d638bdb018047a168e6292f6813ba8b977f7444d Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 5 Oct 2010 17:49:06 -0700 Subject: [PATCH 01/11] MS IZ password change field is now in edit profile --- Gemfile.lock | 12 +------- app/controllers/users_controller.rb | 17 +++++++++-- app/views/users/_profile.haml | 7 +++++ spec/controllers/users_controller_spec.rb | 35 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8534f580a..5ae63f097 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,7 +116,6 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.3) - columnize (0.3.1) crack (0.1.8) cucumber (0.9.0) builder (~> 2.1.2) @@ -152,7 +151,6 @@ GEM i18n (0.4.1) json (1.4.6) json_pure (1.4.6) - linecache (0.43) mail (2.2.6.1) activesupport (>= 2.3.6) mime-types @@ -201,7 +199,6 @@ GEM rake (>= 0.8.4) thor (~> 0.14.0) rake (0.8.7) - redgreen (1.2.2) rest-client (1.6.1) mime-types (>= 1.16) rspec (2.0.0.beta.22) @@ -217,11 +214,6 @@ GEM rspec-rails (2.0.0.beta.17) rspec (>= 2.0.0.beta.14) webrat (>= 0.7.0) - ruby-debug (0.10.3) - columnize (>= 0.1) - ruby-debug-base (~> 0.10.3.0) - ruby-debug-base (0.10.3) - linecache (>= 0.3) rubyzip (0.9.4) selenium-webdriver (0.0.28) ffi (>= 0.6.1) @@ -258,7 +250,7 @@ DEPENDENCIES autotest bson (= 1.0.7) bson_ext (= 1.0.7) - bundler (= 1.0.0) + bundler (>= 1.0.0) capybara (~> 0.3.9) carrierwave! cucumber-rails (= 0.3.2) @@ -278,11 +270,9 @@ DEPENDENCIES pubsubhubbub rails (= 3.0.0) redfinger! - redgreen roxml! rspec (>= 2.0.0.beta.17) rspec-rails (= 2.0.0.beta.17) - ruby-debug sprinkle! thin webmock diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1cc280577..4a68d8bd2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -21,12 +21,25 @@ class UsersController < ApplicationController def update @user = current_user - data = clean_hash params[:user] prep_image_url(data) + + params[:user].delete(:password) if params[:user][:password].blank? + params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank? + + if params[:user][:password] && params[:user][:password_confirmation] + if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation]) + flash[:notice] = "Password Changed" + else + flash[:error] = "Password Change Failed" + end + + end + @user.update_profile data - respond_with(@user, :location => root_url) + redirect_to edit_user_path(@user) + end def public diff --git a/app/views/users/_profile.haml b/app/views/users/_profile.haml index 2b26eead0..78304d183 100644 --- a/app/views/users/_profile.haml +++ b/app/views/users/_profile.haml @@ -47,6 +47,13 @@ %p = p.label :last_name = p.text_field :last_name, :value => @profile.last_name + %p + = f.label :password + = f.text_field :password + %p + = f.label :password_confirmation + = f.text_field :password_confirmation + #submit_block = link_to t('.cancel'), root_path diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index a050738e1..272775771 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -27,7 +27,42 @@ describe UsersController do @user.person.profile.image_url.should == image_url end + end + context 'should allow the user to update their password' do + it 'should change a users password ' do + old_password = @user.encrypted_password + + put("update", :id => @user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz","profile"=> + {"image_url" => "", + "last_name" => @user.person.profile.last_name, + "first_name" => @user.person.profile.first_name}}) + + @user.reload + @user.encrypted_password.should_not == old_password + end + + it 'should not change a password if they do not match' do + old_password = @user.encrypted_password + put("update", :id => @user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same","profile"=> + {"image_url" => "", + "last_name" => @user.person.profile.last_name, + "first_name" => @user.person.profile.first_name}}) + @user.reload + @user.encrypted_password.should == old_password + end + + + it 'should not update if the password fields are left blank' do + + old_password = @user.encrypted_password + put("update", :id => @user.id, "user"=> {"password" => "", 'password_confirmation' => "","profile"=> + {"image_url" => "", + "last_name" => @user.person.profile.last_name, + "first_name" => @user.person.profile.first_name}}) + @user.reload + @user.encrypted_password.should == old_password + end end end end From a063207a0a7b64335d75102062c7b78533602445 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 17:52:21 -0700 Subject: [PATCH 02/11] logger instead of debug --- lib/message_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 351ca99d6..a9dc79d17 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -35,7 +35,7 @@ class MessageHandler http.callback {process} when :hub_publish http = EventMachine::PubSubHubbub.new(query.destination).publish :timeout => TIMEOUT - http.callback {process; Rails.logger.debug(http.response)} + http.callback {Rails.logger.info(http.response); process} else raise "message is not a type I know!" end From cc01345eddf89c639e90869bc9d432e729a37e6a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 17:56:13 -0700 Subject: [PATCH 03/11] debug statements --- lib/message_handler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index a9dc79d17..782402137 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -21,6 +21,7 @@ class MessageHandler end def add_hub_notification(hub_url, feed_url) + Rails.logger.info("in message handler") @queue.push(Message.new(:hub_publish, hub_url, :body => feed_url)) end @@ -35,7 +36,7 @@ class MessageHandler http.callback {process} when :hub_publish http = EventMachine::PubSubHubbub.new(query.destination).publish :timeout => TIMEOUT - http.callback {Rails.logger.info(http.response); process} + http.callback {Rails.logger.info("got into hub_publish"); process} else raise "message is not a type I know!" end From 57e47e5a68731d5a564d219411efbe85fe5ffcf2 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 17:58:56 -0700 Subject: [PATCH 04/11] removed excess dumb. pubsub should work now --- lib/message_handler.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 782402137..e3890d94f 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -21,7 +21,6 @@ class MessageHandler end def add_hub_notification(hub_url, feed_url) - Rails.logger.info("in message handler") @queue.push(Message.new(:hub_publish, hub_url, :body => feed_url)) end @@ -35,8 +34,8 @@ class MessageHandler http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT http.callback {process} when :hub_publish - http = EventMachine::PubSubHubbub.new(query.destination).publish :timeout => TIMEOUT - http.callback {Rails.logger.info("got into hub_publish"); process} + http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT + http.callback {process} else raise "message is not a type I know!" end From 7f652eb81ca56357b6f67dd038e14b641f7b856d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 18:03:17 -0700 Subject: [PATCH 05/11] more logging --- lib/message_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index e3890d94f..f4ad8d2a2 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -35,7 +35,7 @@ class MessageHandler http.callback {process} when :hub_publish http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT - http.callback {process} + http.callback {Rails.logger.info("in publish"); Rails.logger.info(http.response) ;process} else raise "message is not a type I know!" end From fc31eb405dc0ff5b3f2cc056ab3c0c5a3203442b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 18:34:56 -0700 Subject: [PATCH 06/11] removing logging messages --- lib/message_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/message_handler.rb b/lib/message_handler.rb index f4ad8d2a2..e3890d94f 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -35,7 +35,7 @@ class MessageHandler http.callback {process} when :hub_publish http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT - http.callback {Rails.logger.info("in publish"); Rails.logger.info(http.response) ;process} + http.callback {process} else raise "message is not a type I know!" end From d519e46f4d39b80557750eb0e8be66b97b7f883e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 19:01:04 -0700 Subject: [PATCH 07/11] webfinger edit --- app/views/publics/webfinger.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index b689f2a54..8c6d08657 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -6,7 +6,7 @@ - + From dc88110716ed89621b5e3374359f54eda6080e52 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 20:22:13 -0700 Subject: [PATCH 08/11] img tag in hcard --- Gemfile.lock | 10 ++++++++++ app/views/publics/hcard.erb | 2 +- lib/diaspora/ostatus_builder.rb | 2 +- lib/hcard.rb | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 5ae63f097..44d386e33 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,6 +116,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.3) + columnize (0.3.1) crack (0.1.8) cucumber (0.9.0) builder (~> 2.1.2) @@ -151,6 +152,7 @@ GEM i18n (0.4.1) json (1.4.6) json_pure (1.4.6) + linecache (0.43) mail (2.2.6.1) activesupport (>= 2.3.6) mime-types @@ -199,6 +201,7 @@ GEM rake (>= 0.8.4) thor (~> 0.14.0) rake (0.8.7) + redgreen (1.2.2) rest-client (1.6.1) mime-types (>= 1.16) rspec (2.0.0.beta.22) @@ -214,6 +217,11 @@ GEM rspec-rails (2.0.0.beta.17) rspec (>= 2.0.0.beta.14) webrat (>= 0.7.0) + ruby-debug (0.10.3) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.3.0) + ruby-debug-base (0.10.3) + linecache (>= 0.3) rubyzip (0.9.4) selenium-webdriver (0.0.28) ffi (>= 0.6.1) @@ -270,9 +278,11 @@ DEPENDENCIES pubsubhubbub rails (= 3.0.0) redfinger! + redgreen roxml! rspec (>= 2.0.0.beta.17) rspec-rails (= 2.0.0.beta.17) + ruby-debug sprinkle! thin webmock diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index 17b0ebdb7..6b8ab3209 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -36,7 +36,7 @@
Photo
- <%= @person.profile.image_url%> +
diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index f75495ad2..e95604402 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -30,7 +30,7 @@ module Diaspora Diaspora #{@user.public_url}.atom #{@user.real_name}'s Public Feed -its a stream +Posts from Diaspora #{Time.now.xmlschema} #{@user.real_name} diff --git a/lib/hcard.rb b/lib/hcard.rb index e6baa49fd..d43326b56 100644 --- a/lib/hcard.rb +++ b/lib/hcard.rb @@ -8,6 +8,6 @@ module HCard {:given_name => doc.css(".given_name").text, :family_name => doc.css(".family_name").text, :url => doc.css("#pod_location").text, - :photo => doc.css(".photo")} + :photo => doc.css(".photo").src} end end From 91bbd607e6fcdae9cb7b03375bf429f745c53577 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 20:27:33 -0700 Subject: [PATCH 09/11] user avatar in public feed activity:subject --- lib/diaspora/ostatus_builder.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index e95604402..c4a0466fc 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -53,6 +53,7 @@ module Diaspora #{@user.public_url} #{@user.real_name} + XML end From 982f51b9c79b229e8fc5450acfd1217d707409ca Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 20:31:40 -0700 Subject: [PATCH 10/11] prepend pod_url to image paths --- app/views/publics/hcard.erb | 2 +- lib/diaspora/ostatus_builder.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index 6b8ab3209..0cd7f4d02 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -36,7 +36,7 @@
Photo
- +
diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index c4a0466fc..ec5751659 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -53,7 +53,7 @@ module Diaspora #{@user.public_url} #{@user.real_name} - + XML end From 6b74053e068d0163ca253c1b11e6e1bbfbaf4677 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 5 Oct 2010 20:37:28 -0700 Subject: [PATCH 11/11] scratch that last commit --- app/views/publics/hcard.erb | 2 +- lib/diaspora/ostatus_builder.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index 0cd7f4d02..6b8ab3209 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -36,7 +36,7 @@
Photo
- +
diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index ec5751659..92e12122a 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -53,7 +53,7 @@ module Diaspora #{@user.public_url} #{@user.real_name} - + XML end