From a2aabeb599d294e7b4f47befb9d65b3b6a03ed2d Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 16 Mar 2012 18:10:18 -0700 Subject: [PATCH 1/9] remove ActiveSupport::SecureRandom --- app/models/invitation_code.rb | 2 +- app/models/photo.rb | 2 +- app/models/user.rb | 4 ++-- lib/diaspora/guid.rb | 2 +- lib/tasks/generate_session_secret.rake | 2 +- lib/tasks/heroku.rake | 2 +- spec/factories.rb | 6 +++--- spec/models/services/twitter_spec.rb | 8 ++++---- spec/models/user_spec.rb | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb index e653648ce..21bb1a74e 100644 --- a/app/models/invitation_code.rb +++ b/app/models/invitation_code.rb @@ -23,7 +23,7 @@ class InvitationCode < ActiveRecord::Base def generate_token begin - self.token = ActiveSupport::SecureRandom.hex(6) + self.token = SecureRandom.hex(6) end while InvitationCode.exists?(:token => self[:token]) end diff --git a/app/models/photo.rb b/app/models/photo.rb index 54b3a9f6b..fa76787c5 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -71,7 +71,7 @@ class Photo < ActiveRecord::Base photo.pending = params[:pending] if params[:pending] photo.diaspora_handle = photo.author.diaspora_handle - photo.random_string = ActiveSupport::SecureRandom.hex(10) + photo.random_string = SecureRandom.hex(10) if params[:user_file] image_file = params.delete(:user_file) diff --git a/app/models/user.rb b/app/models/user.rb index 6d7abfb7c..2ca3d6bb8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -438,7 +438,7 @@ class User < ActiveRecord::Base self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email if unconfirmed_email_changed? - self.confirm_email_token = unconfirmed_email ? ActiveSupport::SecureRandom.hex(15) : nil + self.confirm_email_token = unconfirmed_email ? SecureRandom.hex(15) : nil end end @@ -495,7 +495,7 @@ class User < ActiveRecord::Base end self[:email] = "deletedaccount_#{self[:id]}@example.org" - random_password = ActiveSupport::SecureRandom.hex(20) + random_password = SecureRandom.hex(20) self.password = random_password self.password_confirmation = random_password self.save(:validate => false) diff --git a/lib/diaspora/guid.rb b/lib/diaspora/guid.rb index 3a7b1d54d..c94e56eac 100644 --- a/lib/diaspora/guid.rb +++ b/lib/diaspora/guid.rb @@ -13,6 +13,6 @@ module Diaspora::Guid # @return [String] The model's guid. def set_guid - self.guid = ActiveSupport::SecureRandom.hex(8) if self.guid.blank? + self.guid = SecureRandom.hex(8) if self.guid.blank? end end diff --git a/lib/tasks/generate_session_secret.rake b/lib/tasks/generate_session_secret.rake index f6a1e85b5..efd55bbab 100644 --- a/lib/tasks/generate_session_secret.rake +++ b/lib/tasks/generate_session_secret.rake @@ -3,7 +3,7 @@ namespace :generate do task :secret_token do path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb') - secret = ActiveSupport::SecureRandom.hex(40) + secret = SecureRandom.hex(40) File.open(path, 'w') do |f| f.write <<"EOF" # Copyright (c) 2010-2011, Diaspora Inc. This file is diff --git a/lib/tasks/heroku.rake b/lib/tasks/heroku.rake index 3b702d7fc..32ca1a781 100644 --- a/lib/tasks/heroku.rake +++ b/lib/tasks/heroku.rake @@ -9,7 +9,7 @@ namespace :heroku do task :generate_secret_token do puts "Generating and setting a new secret token" - token = ActiveSupport::SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks + token = SecureRandom.hex(40)#reloads secret token every time you reload vars.... this expires cookies, and kinda sucks command = "#{HEROKU_CONFIG_ADD_COMMAND} SECRET_TOKEN=#{token}" puts command system command diff --git a/spec/factories.rb b/spec/factories.rb index 4f13b6ec6..bde89c3c0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -7,7 +7,7 @@ # http://railscasts.com/episodes/158-factories-not-fixtures def r_str - ActiveSupport::SecureRandom.hex(3) + SecureRandom.hex(3) end FactoryGirl.define do @@ -100,7 +100,7 @@ FactoryGirl.define do end factory(:photo) do - sequence(:random_string) {|n| ActiveSupport::SecureRandom.hex(10) } + sequence(:random_string) {|n| SecureRandom.hex(10) } association :author, :factory => :person after_build do |p| p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) @@ -237,7 +237,7 @@ FactoryGirl.define do end factory(:note, :parent => :status_message) do - text ActiveSupport::SecureRandom.hex(1000) + text SecureRandom.hex(1000) end factory(:rich_media, :parent => :status_message) do diff --git a/spec/models/services/twitter_spec.rb b/spec/models/services/twitter_spec.rb index e990a3175..cccd19094 100644 --- a/spec/models/services/twitter_spec.rb +++ b/spec/models/services/twitter_spec.rb @@ -30,17 +30,17 @@ describe Services::Twitter do end describe "message size limits" do before :each do - @long_message_start = ActiveSupport::SecureRandom.hex(25) - @long_message_end = ActiveSupport::SecureRandom.hex(25) + @long_message_start = SecureRandom.hex(25) + @long_message_end = SecureRandom.hex(25) end it "should not truncate a short message" do - short_message = ActiveSupport::SecureRandom.hex(20) + short_message = SecureRandom.hex(20) short_post = stub(:text => short_message ) @service.public_message(short_post, '').should == short_message end it "should truncate a long message" do - long_message = ActiveSupport::SecureRandom.hex(220) + long_message = SecureRandom.hex(220) long_post = stub(:text => long_message ) @service.public_message(long_post, '').should == long_message.first(137) + "..." end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1738beda5..30a29e910 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -846,7 +846,7 @@ describe User do describe "#clear_account!" do it 'resets the password to a random string' do random_pass = "12345678909876543210" - ActiveSupport::SecureRandom.should_receive(:hex).and_return(random_pass) + SecureRandom.should_receive(:hex).and_return(random_pass) @user.clear_account! @user.valid_password?(random_pass) end From 35a6f4f265abd03c731e0ccc3e689d95dff810fb Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Fri, 16 Mar 2012 18:23:14 -0700 Subject: [PATCH 2/9] basic 3.1 upgrade... a few things are still broken. help me out and run the tests and fix them <3 --- Gemfile | 10 +- Gemfile.lock | 146 +++++++++++----------- config/initializers/patch_openssl_pkey.rb | 16 +-- 3 files changed, 88 insertions(+), 84 deletions(-) diff --git a/Gemfile b/Gemfile index 20f656985..86c1a6d56 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'http://rubygems.org' -gem 'rails', '3.0.11' - +gem 'rails', '3.1.4' +gem 'rails_autolink' gem 'bundler', '~> 1.1.0' gem 'foreman', '0.34.1' gem 'whenever' @@ -14,7 +14,7 @@ gem 'rack-cors', '~> 0.2.4', :require => 'rack/cors' # authentication -gem 'devise', '~> 1.3.1' +gem 'devise', '1.5.3' gem 'jwt' gem 'oauth2-provider', '0.0.19' @@ -49,9 +49,9 @@ end gem 'settingslogic', :git => 'git://github.com/binarylogic/settingslogic.git' # database -gem 'activerecord-import' +gem "activerecord-import", "~> 0.2.9" gem 'foreigner', '~> 1.1.0' -gem 'mysql2', '0.2.18' if ENV['DB'].nil? || ENV['DB'] == 'all' || ENV['DB'] == 'mysql' +gem 'mysql2', '0.3.11' if ENV['DB'].nil? || ENV['DB'] == 'all' || ENV['DB'] == 'mysql' gem 'pg' if ENV['DB'] == 'all' || ENV['DB'] == 'postgres' gem 'sqlite3' if ENV['DB'] == 'all' || ENV['DB'] == 'sqlite' diff --git a/Gemfile.lock b/Gemfile.lock index be40d39c8..6b4eef93b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,37 +50,38 @@ GEM open4 Platform (0.4.0) SystemTimer (1.2.3) - abstract (1.0.0) - actionmailer (3.0.11) - actionpack (= 3.0.11) - mail (~> 2.2.19) - actionpack (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) + actionmailer (3.1.4) + actionpack (= 3.1.4) + mail (~> 2.3.0) + actionpack (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.6) + rack-cache (~> 1.1) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.3) active_reload (0.6.1) - activemodel (3.0.11) - activesupport (= 3.0.11) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) + activemodel (3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) activerecord-import (0.2.9) activerecord (~> 3.0) activerecord (~> 3.0) - activeresource (3.0.11) - activemodel (= 3.0.11) - activesupport (= 3.0.11) - activesupport (3.0.11) + activeresource (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + activesupport (3.1.4) + multi_json (~> 1.0) acts_as_api (0.3.11) activemodel (>= 3.0.0) activesupport (>= 3.0.0) @@ -90,9 +91,9 @@ GEM activesupport builder archive-tar-minitar (0.5.2) - arel (2.0.10) - bcrypt-ruby (2.1.4) - builder (2.1.2) + arel (2.2.3) + bcrypt-ruby (3.0.1) + builder (3.0.0) capistrano (2.9.0) highline net-scp (>= 1.0.0) @@ -134,10 +135,10 @@ GEM nokogiri (>= 1.5.0) daemons (1.1.8) database_cleaner (0.7.1) - devise (1.3.4) - bcrypt-ruby (~> 2.1.2) + devise (1.5.3) + bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) - warden (~> 1.0.3) + warden (~> 1.1) diff-lcs (1.1.3) em-http-request (1.0.2) addressable (>= 2.2.3) @@ -149,8 +150,7 @@ GEM eventmachine em-synchrony (1.0.0) eventmachine (>= 1.0.0.beta.1) - erubis (2.6.6) - abstract (>= 1.0.0) + erubis (2.7.0) eventmachine (1.0.0.beta.4) excon (0.12.0) factory_girl (2.6.4) @@ -172,22 +172,13 @@ GEM activesupport (>= 2) fog (1.2.0) builder - builder - excon (~> 0.12.0) excon (~> 0.12.0) formatador (~> 0.2.0) - formatador (~> 0.2.0) - mime-types mime-types multi_json (~> 1.0) - multi_json (~> 1.0) - net-scp (~> 1.0.4) net-scp (~> 1.0.4) net-ssh (>= 2.1.3) - net-ssh (>= 2.1.3) nokogiri (~> 1.5.0) - nokogiri (~> 1.5.0) - ruby-hmac ruby-hmac foreigner (1.1.5) activerecord (>= 3.0.0) @@ -213,10 +204,11 @@ GEM heroku (>= 2) rails (>= 2) highline (1.6.11) + hike (1.2.1) hodel_3000_compliant_logger (0.1.0) http_accept_language (1.0.2) http_parser.rb (0.5.3) - i18n (0.5.0) + i18n (0.6.0) i18n-inflector (2.6.6) i18n (>= 0.4.1) i18n-inflector-rails (1.0.6) @@ -246,13 +238,12 @@ GEM rbx-require-relative (> 0.0.4) linecache19 (0.5.12) ruby_core_source (>= 0.1.4) - mail (2.2.19) - activesupport (>= 2.3.6) + mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) messagebus_ruby_api (1.0.3) - mime-types (1.17.2) + mime-types (1.18) mimemagic (0.1.8) mini_magick (3.4) subexec (~> 0.2.1) @@ -267,7 +258,7 @@ GEM gem_plugin (>= 0.2.3) multi_json (1.0.4) multipart-post (1.1.5) - mysql2 (0.2.18) + mysql2 (0.3.11) net-scp (1.0.4) net-ssh (>= 1.99.1) net-sftp (2.0.5) @@ -311,37 +302,44 @@ GEM pg (0.13.2) polyglot (0.3.3) proxies (0.2.1) - rack (1.2.5) + rack (1.3.6) + rack-cache (1.2) + rack (>= 0.4) rack-cors (0.2.4) rack rack-fiber_pool (0.9.2) rack-google-analytics (0.10.0) rack-mobile-detect (0.3.0) rack - rack-mount (0.6.14) + rack-mount (0.8.3) rack (>= 1.0.0) rack-piwik (0.1.2) + rack-protection (1.2.0) + rack rack-rewrite (1.2.1) rack-ssl (1.3.2) rack - rack-test (0.5.7) + rack-test (0.6.1) rack (>= 1.0) - rails (3.0.11) - actionmailer (= 3.0.11) - actionpack (= 3.0.11) - activerecord (= 3.0.11) - activeresource (= 3.0.11) - activesupport (= 3.0.11) + rails (3.1.4) + actionmailer (= 3.1.4) + actionpack (= 3.1.4) + activerecord (= 3.1.4) + activeresource (= 3.1.4) + activesupport (= 3.1.4) bundler (~> 1.0) - railties (= 3.0.11) + railties (= 3.1.4) rails-i18n (0.5.2) i18n (~> 0.5) - railties (3.0.11) - actionpack (= 3.0.11) - activesupport (= 3.0.11) + rails_autolink (1.0.6) + rails (~> 3.1) + railties (3.1.4) + actionpack (= 3.1.4) + activesupport (= 3.1.4) + rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.4) + thor (~> 0.14.6) raindrops (0.8.0) rake (0.9.2.2) rbx-require-relative (0.0.9) @@ -405,9 +403,14 @@ GEM multi_json (~> 1.0.4) rubyzip simple_oauth (0.1.5) - sinatra (1.2.8) - rack (~> 1.1) - tilt (>= 1.2.2, < 2.0) + sinatra (1.3.2) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sprockets (2.0.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.5) subexec (0.2.1) term-ansicolor (1.0.7) @@ -435,7 +438,7 @@ GEM raindrops (~> 0.7) vegas (0.1.11) rack (>= 1.0.0) - warden (1.0.6) + warden (1.1.1) rack (>= 1.0) webmock (1.6.2) addressable (>= 2.2.2) @@ -456,7 +459,7 @@ PLATFORMS DEPENDENCIES SystemTimer (= 1.2.3) active_reload - activerecord-import + activerecord-import (~> 0.2.9) acts-as-taggable-on! acts_as_api addressable (= 2.2.4) @@ -471,7 +474,7 @@ DEPENDENCIES cucumber-api-steps (= 0.6) cucumber-rails (= 1.2.1) database_cleaner (= 0.7.1) - devise (~> 1.3.1) + devise (= 1.5.3) diaspora-client! em-synchrony (= 1.0.0) factory_girl_rails @@ -498,7 +501,7 @@ DEPENDENCIES mobile-fu mock_redis mongrel - mysql2 (= 0.2.18) + mysql2 (= 0.3.11) newrelic_rpm nokogiri (= 1.5.0) oauth2-provider (= 0.0.19) @@ -514,8 +517,9 @@ DEPENDENCIES rack-piwik rack-rewrite (~> 1.2.1) rack-ssl - rails (= 3.0.11) + rails (= 3.1.4) rails-i18n + rails_autolink redcarpet (= 2.0.1) resque (= 1.19.0) resque-ensure-connected! diff --git a/config/initializers/patch_openssl_pkey.rb b/config/initializers/patch_openssl_pkey.rb index 2a5acf165..5b3d5370e 100644 --- a/config/initializers/patch_openssl_pkey.rb +++ b/config/initializers/patch_openssl_pkey.rb @@ -4,11 +4,11 @@ # # # -#Why? as of rails 3.0.4, objects are marshalled by calling to yaml, if it is a text field in the db. since we assume things are strings coming out, and pkey does not seem to define a to_yaml, it was getting set to nil -class OpenSSL::PKey::RSA - def to_yaml - self.to_s - end -end - - +##Why? as of rails 3.0.4, objects are marshalled by calling to yaml, if it is a text field in the db. since we assume things are strings coming out, and pkey does not seem to define a to_yaml, it was getting set to nil +#class OpenSSL::PKey::RSA +# def to_yaml +# self.to_s +# end +#end +# +# From 835f808e5a869cf8c5ed5d1b43e11c4bce79131a Mon Sep 17 00:00:00 2001 From: Maxwell Salzberg Date: Sat, 17 Mar 2012 17:55:42 -0700 Subject: [PATCH 3/9] more progress --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/helpers/application_helper.rb | 1 + app/helpers/notifications_helper.rb | 2 ++ app/helpers/people_helper.rb | 1 + config/initializers/patch_openssl_pkey.rb | 10 +++++----- spec/helpers/application_helper_spec.rb | 2 ++ spec/helpers/notifications_helper_spec.rb | 2 ++ spec/helpers/people_helper_spec.rb | 2 ++ 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 86c1a6d56..7393e34c9 100644 --- a/Gemfile +++ b/Gemfile @@ -84,7 +84,7 @@ gem 'ruby-oembed', '~> 0.8.7' # queue -gem 'resque', '1.19.0' +gem 'resque', '1.20.0' gem 'resque-ensure-connected', :git => 'git://github.com/socialcast/resque-ensure-connected.git' gem 'resque-timeout', '1.0.0' gem 'SystemTimer', '1.2.3', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 6b4eef93b..7fd195cce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -349,7 +349,7 @@ GEM redis (2.2.2) redis-namespace (1.0.3) redis (< 3.0.0) - resque (1.19.0) + resque (1.20.0) multi_json (~> 1.0) redis-namespace (~> 1.0.2) sinatra (>= 0.9.2) @@ -521,7 +521,7 @@ DEPENDENCIES rails-i18n rails_autolink redcarpet (= 2.0.1) - resque (= 1.19.0) + resque (= 1.20.0) resque-ensure-connected! resque-timeout (= 1.0.0) rest-client (= 1.6.7) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 522c218c1..d2ef55662 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,6 +3,7 @@ # the COPYRIGHT file. module ApplicationHelper + include Rails.application.routes.url_helpers def how_long_ago(obj) timeago(obj.created_at) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 6f25e8cc8..5f02020a0 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,5 +1,7 @@ module NotificationsHelper include PeopleHelper + include Rails.application.routes.url_helpers + def object_link(note, actors) target_type = note.popup_translation_key diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 2e0851213..40084de0b 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -4,6 +4,7 @@ module PeopleHelper include ERB::Util + include Rails.application.routes.url_helpers def search_header if search_query.blank? diff --git a/config/initializers/patch_openssl_pkey.rb b/config/initializers/patch_openssl_pkey.rb index 5b3d5370e..22c190ba4 100644 --- a/config/initializers/patch_openssl_pkey.rb +++ b/config/initializers/patch_openssl_pkey.rb @@ -5,10 +5,10 @@ # # ##Why? as of rails 3.0.4, objects are marshalled by calling to yaml, if it is a text field in the db. since we assume things are strings coming out, and pkey does not seem to define a to_yaml, it was getting set to nil -#class OpenSSL::PKey::RSA -# def to_yaml -# self.to_s -# end -#end +class OpenSSL::PKey::RSA + def to_yaml(opts=nil) + self.to_s + end +end # # diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 271fd662b..08cada621 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,6 +5,8 @@ require 'spec_helper' describe ApplicationHelper do + include Rails.application.routes.url_helpers + before do @user = alice @person = Factory(:person) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 3cdb465e1..a4a09d0c5 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe NotificationsHelper do include ApplicationHelper + include Rails.application.routes.url_helpers + before do @user = Factory(:user) @person = Factory(:person) diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index 945b330ba..e9f86c7bc 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -5,6 +5,8 @@ require 'spec_helper' describe PeopleHelper do + include Rails.application.routes.url_helpers + before do @user = alice @person = Factory(:person) From 5c431d933f2776caecf85679093b5f89be05d3d5 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Tue, 20 Mar 2012 18:03:46 -0700 Subject: [PATCH 4/9] MS DG down to four failures --- app/helpers/application_helper.rb | 2 -- app/helpers/notifications_helper.rb | 2 -- app/helpers/people_helper.rb | 13 ++++++------- config/environments/test.rb | 4 +++- spec/controllers/posts_controller_spec.rb | 4 ++-- spec/helpers/application_helper_spec.rb | 2 -- spec/helpers/notifications_helper_spec.rb | 3 +-- spec/helpers/people_helper_spec.rb | 13 ++++++------- spec/helpers/tags_helper_spec.rb | 4 +++- 9 files changed, 21 insertions(+), 26 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d2ef55662..d19a42b57 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,8 +3,6 @@ # the COPYRIGHT file. module ApplicationHelper - include Rails.application.routes.url_helpers - def how_long_ago(obj) timeago(obj.created_at) end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 5f02020a0..6f25e8cc8 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,7 +1,5 @@ module NotificationsHelper include PeopleHelper - include Rails.application.routes.url_helpers - def object_link(note, actors) target_type = note.popup_translation_key diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 40084de0b..adf89671a 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -4,15 +4,14 @@ module PeopleHelper include ERB::Util - include Rails.application.routes.url_helpers def search_header if search_query.blank? content_tag(:h2, t('people.index.no_results')) else - content_tag(:h2, :id => 'search_title') do + content_tag(:h2, :id => 'search_title') do t('people.index.results_for').html_safe + ' ' + - content_tag(:span, search_query, :class => 'term') + content_tag(:span, search_query, :class => 'term') end end end @@ -67,13 +66,13 @@ module PeopleHelper def person_href(person, opts={}) "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe end - - + + # Rails.application.routes.url_helpers is needed since this is indirectly called from a model def local_or_remote_person_path(person, opts={}) opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority) absolute = opts.delete(:absolute) - + if person.local? username = person.diaspora_handle.split('@')[0] unless username.include?('.') @@ -85,7 +84,7 @@ module PeopleHelper end end end - + if absolute return Rails.application.routes.url_helpers.person_url(person, opts) else diff --git a/config/environments/test.rb b/config/environments/test.rb index d66421502..d1ab8b3a7 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -29,7 +29,9 @@ Diaspora::Application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test config.active_support.deprecation = :stderr - config.threadsafe! + + # fixes url helper issue in rspec + #config.threadsafe! # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 468f61df0..9c97dd1c4 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -49,7 +49,7 @@ describe PostsController do get :show, :id => photo.id response.should be_success end - + it 'redirects if the post is missing' do get :show, :id => 1234567 response.should be_redirect @@ -94,7 +94,7 @@ describe PostsController do end it 'assumes guids less than 8 chars are ids and not guids' do - Post.should_receive(:where).with(hash_including(:id => @status.id)).and_return(Post) + Post.should_receive(:where).with(hash_including(:id => @status.id.to_s)).and_return(Post) get :show, :id => @status.id response.should be_success end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 08cada621..271fd662b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -5,8 +5,6 @@ require 'spec_helper' describe ApplicationHelper do - include Rails.application.routes.url_helpers - before do @user = alice @person = Factory(:person) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index a4a09d0c5..7ce660bc1 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' describe NotificationsHelper do include ApplicationHelper - include Rails.application.routes.url_helpers - + before do @user = Factory(:user) @person = Factory(:person) diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index e9f86c7bc..e6dc2838b 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -5,12 +5,11 @@ require 'spec_helper' describe PeopleHelper do - include Rails.application.routes.url_helpers - before do @user = alice @person = Factory(:person) end + describe "#person_image_link" do it "returns an empty string if person is nil" do person_image_link(nil).should == "" @@ -64,12 +63,12 @@ describe PeopleHelper do describe "#person_href" do it "calls local_or_remote_person_path and passes through the options" do opts = {:absolute => true} - + self.should_receive(:local_or_remote_person_path).with(@person, opts).exactly(1).times - + person_href(@person, opts) end - + it "returns a href attribute" do person_href(@person).should include "href=" end @@ -79,7 +78,7 @@ describe PeopleHelper do before do @user = Factory(:user) end - + it "links by id if there is a period in the user's username" do @user.username = "invalid.username" @user.save(:validate => false).should == true @@ -93,7 +92,7 @@ describe PeopleHelper do it 'links by username for a local user' do local_or_remote_person_path(@user.person).should == user_profile_path(:username => @user.username) end - + it 'links by id for a remote person' do local_or_remote_person_path(@person).should == person_path(@person) end diff --git a/spec/helpers/tags_helper_spec.rb b/spec/helpers/tags_helper_spec.rb index b8f3f1b15..f62edef90 100644 --- a/spec/helpers/tags_helper_spec.rb +++ b/spec/helpers/tags_helper_spec.rb @@ -5,11 +5,13 @@ describe TagsHelper do it 'returns nil if there is a @ in the query' do helper.stub(:search_query).and_return('foo@bar.com') helper.looking_for_tag_link.should be_nil - end + end + it 'returns nil if it normalizes to blank' do helper.stub(:search_query).and_return('++') helper.looking_for_tag_link.should be_nil end + it 'returns a link to the tag otherwise' do helper.stub(:search_query).and_return('foo') helper.looking_for_tag_link.should include(helper.tag_link) From 9c0ed946a77d55075264dae40c94adeb762c5b40 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Tue, 20 Mar 2012 18:36:19 -0700 Subject: [PATCH 5/9] no more rspec failures; and suppress a warning with a backported monkeypatch --- app/models/user.rb | 6 +++--- .../initializers/patch_active_support_output.rb | 16 ++++++++++++++++ .../aspect_memberships_controller_spec.rb | 2 ++ spec/models/person_spec.rb | 4 +--- spec/models/service_spec.rb | 16 +++++++++------- spec/models/user_spec.rb | 2 ++ 6 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 config/initializers/patch_active_support_output.rb diff --git a/app/models/user.rb b/app/models/user.rb index 2ca3d6bb8..129c32430 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,7 +41,7 @@ class User < ActiveRecord::Base has_many :aspects, :order => 'order_id ASC' belongs_to :auto_follow_back_aspect, :class_name => 'Aspect' - belongs_to :invited_by, :class_name => 'User' + belongs_to :invited_by, :class_name => 'User' has_many :aspect_memberships, :through => :aspects @@ -454,10 +454,10 @@ class User < ActiveRecord::Base def generate_keys key_size = (Rails.env == 'test' ? 512 : 4096) - self.serialized_private_key = OpenSSL::PKey::RSA::generate(key_size) if self.serialized_private_key.blank? + self.serialized_private_key = OpenSSL::PKey::RSA::generate(key_size).to_s if self.serialized_private_key.blank? if self.person && self.person.serialized_public_key.blank? - self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key + self.person.serialized_public_key = OpenSSL::PKey::RSA.new(self.serialized_private_key).public_key.to_s end end diff --git a/config/initializers/patch_active_support_output.rb b/config/initializers/patch_active_support_output.rb new file mode 100644 index 000000000..c993853af --- /dev/null +++ b/config/initializers/patch_active_support_output.rb @@ -0,0 +1,16 @@ +# this is a temp monkey patch to suppress errors in rails 3.1 +# it was fixed in 3.2, but it does not look like they are going to backport +# see: https://github.com/rails/rails/issues/3927 +class ERB + module Util + def html_escape(s) + s = s.to_s + if s.html_safe? + s + else + s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe + end + end + end +end + diff --git a/spec/controllers/aspect_memberships_controller_spec.rb b/spec/controllers/aspect_memberships_controller_spec.rb index ea7a42076..8e7192704 100644 --- a/spec/controllers/aspect_memberships_controller_spec.rb +++ b/spec/controllers/aspect_memberships_controller_spec.rb @@ -43,6 +43,8 @@ describe AspectMembershipsController do end it 'creates a contact' do + #argggg why? + alice.contacts.reload lambda { post :create, :format => 'js', diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 3c0adb31c..ffce24664 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -27,9 +27,7 @@ describe Person do Person.for_json.first.serialized_public_key }.should raise_error ActiveModel::MissingAttributeError end - it 'eager loads profiles' do - Person.for_json.first.loaded_profile?.should be_true - end + it 'selects distinct people' do aspect = bob.aspects.create(:name => 'hilarious people') aspect.contacts << bob.contact_for(eve.person) diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 6d3ad9e83..a7d53eb3d 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -3,17 +3,19 @@ require 'spec_helper' describe Service do before do - @user = alice - @post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id) - @service = Services::Facebook.new(:access_token => "yeah") - @user.services << @service + @post = alice.post(:status_message, :text => "hello", :to => alice.aspects.first.id) + @service = Services::Facebook.new(:access_token => "yeah", :uid => 1) + alice.services << @service end it 'is unique to a user by service type and uid' do @service.save - @user.services << Services::Facebook.new(:access_token => "yeah") - @user.services[1].valid?.should be_false + second_service = Services::Facebook.new(:access_token => "yeah", :uid => 1) + + alice.services << second_service + alice.services.last.save + alice.services.last.should be_invalid end it 'destroys the associated service_user' do @@ -28,6 +30,6 @@ describe Service do end it 'by default has no profile photo url' do - Service.new.profile_photo_url.should == nil + Service.new.profile_photo_url.should be_nil end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 30a29e910..b68b927c9 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -12,7 +12,9 @@ describe User do it 'marshalls the key to and from the db correctly' do user = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password') + user.save! + user.serialized_private_key.should be_present expect{ user.reload.encryption_key From 03409495f92379aa180e0bd95247bfe69008afcd Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 21 Mar 2012 09:56:26 -0700 Subject: [PATCH 6/9] better patch for ActiveSupport --- config/initializers/patch_active_support_output.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/patch_active_support_output.rb b/config/initializers/patch_active_support_output.rb index c993853af..2b24cbd03 100644 --- a/config/initializers/patch_active_support_output.rb +++ b/config/initializers/patch_active_support_output.rb @@ -8,7 +8,7 @@ class ERB if s.html_safe? s else - s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe + silence_warnings { s.gsub(/[&"><]/n) { |special| HTML_ESCAPE[special] }.html_safe } end end end From 0883ce1dbbb2d71f7ff349e4f01952b0d3d914d6 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 21 Mar 2012 12:09:03 -0700 Subject: [PATCH 7/9] fix a bunch of cukes. the disabled functionilty in rails helpers changed and we had to update out JS accordingly --- app/controllers/aspect_memberships_controller.rb | 3 ++- public/javascripts/publisher.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/aspect_memberships_controller.rb b/app/controllers/aspect_memberships_controller.rb index 89327f420..118ec33af 100644 --- a/app/controllers/aspect_memberships_controller.rb +++ b/app/controllers/aspect_memberships_controller.rb @@ -44,8 +44,9 @@ class AspectMembershipsController < ApplicationController def create @person = Person.find(params[:person_id]) @aspect = current_user.aspects.where(:id => params[:aspect_id]).first + @contact = current_user.share_with(@person, @aspect) - if @contact = current_user.share_with(@person, @aspect) + if @contact flash.now[:notice] = I18n.t('aspects.add_to_aspect.success') respond_with AspectMembership.where(:contact_id => @contact.id, :aspect_id => @aspect.id).first else diff --git a/public/javascripts/publisher.js b/public/javascripts/publisher.js index cda29e862..44552f65b 100644 --- a/public/javascripts/publisher.js +++ b/public/javascripts/publisher.js @@ -24,7 +24,7 @@ var Publisher = { }, submit: function(){ - return Publisher.cachedSubmit = Publisher.cachedSubmit || Publisher.form().find('#status_message_submit'); + return Publisher.cachedSubmit = Publisher.cachedSubmit || Publisher.form().find("input[type='submit']"); }, determineSubmitAvailability: function(){ @@ -32,8 +32,8 @@ var Publisher = { isSubmitDisabled = Publisher.submit().attr('disabled'), isPhotoAttached = ($("#photodropzone").children().length > 0); - if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) { - Publisher.submit().attr('disabled', true); + if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) { + Publisher.submit().attr('disabled', 'disabled'); } else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) { Publisher.submit().removeAttr('disabled'); } @@ -43,6 +43,8 @@ var Publisher = { $("#photodropzone").find('li').remove(); Publisher.input().mentionsInput("reset"); Publisher.wrapper().removeClass("with_attachments"); + Publisher.hiddenInput().val(''); + Publisher.determineSubmitAvailability() }, bindServiceIcons: function(){ From def5b81fbf7b05f71f587978246ee5f3d3d98faa Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 21 Mar 2012 12:41:37 -0700 Subject: [PATCH 8/9] MS DG; fix cukes and stuff --- features/closes_account.feature | 2 +- features/connects_users.feature | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/closes_account.feature b/features/closes_account.feature index 4b5204752..647edf215 100644 --- a/features/closes_account.feature +++ b/features/closes_account.feature @@ -16,7 +16,7 @@ Feature: Close Account When I try to sign in manually Then I should be on the new user session page When I wait for the ajax to finish - Then I should see "Your account is locked." + Then I should see "Invalid email or password" Scenario: post display should not throw error when mention is removed for the user whose account is closed Given a user named "Bob Jones" with email "bob@bob.bob" diff --git a/features/connects_users.feature b/features/connects_users.feature index 4faee4641..0342a0048 100644 --- a/features/connects_users.feature +++ b/features/connects_users.feature @@ -73,7 +73,7 @@ Feature: following and being followed And I wait for the ajax to finish And I fill in "Name" with "Super People" in the modal window - And I press "aspect_submit" in the modal window + And I press "Create" in the modal window And I wait for the ajax to finish When I go to the home page From e19c84b5a32a910be41740068d996ed622ea6f90 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Wed, 21 Mar 2012 13:58:20 -0700 Subject: [PATCH 9/9] remove the monkey patch that didn't work. --- .../initializers/patch_active_support_output.rb | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 config/initializers/patch_active_support_output.rb diff --git a/config/initializers/patch_active_support_output.rb b/config/initializers/patch_active_support_output.rb deleted file mode 100644 index 2b24cbd03..000000000 --- a/config/initializers/patch_active_support_output.rb +++ /dev/null @@ -1,16 +0,0 @@ -# this is a temp monkey patch to suppress errors in rails 3.1 -# it was fixed in 3.2, but it does not look like they are going to backport -# see: https://github.com/rails/rails/issues/3927 -class ERB - module Util - def html_escape(s) - s = s.to_s - if s.html_safe? - s - else - silence_warnings { s.gsub(/[&"><]/n) { |special| HTML_ESCAPE[special] }.html_safe } - end - end - end -end -