Merge branch 'update-rails'

This commit is contained in:
danielgrippi 2012-03-21 13:58:50 -07:00
commit f213500451
26 changed files with 151 additions and 135 deletions

12
Gemfile
View file

@ -1,7 +1,7 @@
source 'http://rubygems.org' source 'http://rubygems.org'
gem 'rails', '3.0.11' gem 'rails', '3.1.4'
gem 'rails_autolink'
gem 'bundler', '~> 1.1.0' gem 'bundler', '~> 1.1.0'
gem 'foreman', '0.34.1' gem 'foreman', '0.34.1'
gem 'whenever' gem 'whenever'
@ -14,7 +14,7 @@ gem 'rack-cors', '~> 0.2.4', :require => 'rack/cors'
# authentication # authentication
gem 'devise', '~> 1.3.1' gem 'devise', '1.5.3'
gem 'jwt' gem 'jwt'
gem 'oauth2-provider', '0.0.19' gem 'oauth2-provider', '0.0.19'
@ -49,9 +49,9 @@ end
gem 'settingslogic', :git => 'git://github.com/binarylogic/settingslogic.git' gem 'settingslogic', :git => 'git://github.com/binarylogic/settingslogic.git'
# database # database
gem 'activerecord-import' gem "activerecord-import", "~> 0.2.9"
gem 'foreigner', '~> 1.1.0' 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 'pg' if ENV['DB'] == 'all' || ENV['DB'] == 'postgres'
gem 'sqlite3' if ENV['DB'] == 'all' || ENV['DB'] == 'sqlite' gem 'sqlite3' if ENV['DB'] == 'all' || ENV['DB'] == 'sqlite'
@ -84,7 +84,7 @@ gem 'ruby-oembed', '~> 0.8.7'
# queue # 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-ensure-connected', :git => 'git://github.com/socialcast/resque-ensure-connected.git'
gem 'resque-timeout', '1.0.0' gem 'resque-timeout', '1.0.0'
gem 'SystemTimer', '1.2.3', :platforms => :ruby_18 gem 'SystemTimer', '1.2.3', :platforms => :ruby_18

View file

@ -50,37 +50,38 @@ GEM
open4 open4
Platform (0.4.0) Platform (0.4.0)
SystemTimer (1.2.3) SystemTimer (1.2.3)
abstract (1.0.0) actionmailer (3.1.4)
actionmailer (3.0.11) actionpack (= 3.1.4)
actionpack (= 3.0.11) mail (~> 2.3.0)
mail (~> 2.2.19) actionpack (3.1.4)
actionpack (3.0.11) activemodel (= 3.1.4)
activemodel (= 3.0.11) activesupport (= 3.1.4)
activesupport (= 3.0.11) builder (~> 3.0.0)
builder (~> 2.1.2) erubis (~> 2.7.0)
erubis (~> 2.6.6) i18n (~> 0.6)
i18n (~> 0.5.0) rack (~> 1.3.6)
rack (~> 1.2.1) rack-cache (~> 1.1)
rack-mount (~> 0.6.14) rack-mount (~> 0.8.2)
rack-test (~> 0.5.7) rack-test (~> 0.6.1)
tzinfo (~> 0.3.23) sprockets (~> 2.0.3)
active_reload (0.6.1) active_reload (0.6.1)
activemodel (3.0.11) activemodel (3.1.4)
activesupport (= 3.0.11) activesupport (= 3.1.4)
builder (~> 2.1.2) builder (~> 3.0.0)
i18n (~> 0.5.0) i18n (~> 0.6)
activerecord (3.0.11) activerecord (3.1.4)
activemodel (= 3.0.11) activemodel (= 3.1.4)
activesupport (= 3.0.11) activesupport (= 3.1.4)
arel (~> 2.0.10) arel (~> 2.2.3)
tzinfo (~> 0.3.23) tzinfo (~> 0.3.29)
activerecord-import (0.2.9) activerecord-import (0.2.9)
activerecord (~> 3.0) activerecord (~> 3.0)
activerecord (~> 3.0) activerecord (~> 3.0)
activeresource (3.0.11) activeresource (3.1.4)
activemodel (= 3.0.11) activemodel (= 3.1.4)
activesupport (= 3.0.11) activesupport (= 3.1.4)
activesupport (3.0.11) activesupport (3.1.4)
multi_json (~> 1.0)
acts_as_api (0.3.11) acts_as_api (0.3.11)
activemodel (>= 3.0.0) activemodel (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
@ -90,9 +91,9 @@ GEM
activesupport activesupport
builder builder
archive-tar-minitar (0.5.2) archive-tar-minitar (0.5.2)
arel (2.0.10) arel (2.2.3)
bcrypt-ruby (2.1.4) bcrypt-ruby (3.0.1)
builder (2.1.2) builder (3.0.0)
capistrano (2.9.0) capistrano (2.9.0)
highline highline
net-scp (>= 1.0.0) net-scp (>= 1.0.0)
@ -134,10 +135,10 @@ GEM
nokogiri (>= 1.5.0) nokogiri (>= 1.5.0)
daemons (1.1.8) daemons (1.1.8)
database_cleaner (0.7.1) database_cleaner (0.7.1)
devise (1.3.4) devise (1.5.3)
bcrypt-ruby (~> 2.1.2) bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3) orm_adapter (~> 0.0.3)
warden (~> 1.0.3) warden (~> 1.1)
diff-lcs (1.1.3) diff-lcs (1.1.3)
em-http-request (1.0.2) em-http-request (1.0.2)
addressable (>= 2.2.3) addressable (>= 2.2.3)
@ -149,8 +150,7 @@ GEM
eventmachine eventmachine
em-synchrony (1.0.0) em-synchrony (1.0.0)
eventmachine (>= 1.0.0.beta.1) eventmachine (>= 1.0.0.beta.1)
erubis (2.6.6) erubis (2.7.0)
abstract (>= 1.0.0)
eventmachine (1.0.0.beta.4) eventmachine (1.0.0.beta.4)
excon (0.12.0) excon (0.12.0)
factory_girl (2.6.4) factory_girl (2.6.4)
@ -172,22 +172,13 @@ GEM
activesupport (>= 2) activesupport (>= 2)
fog (1.2.0) fog (1.2.0)
builder builder
builder
excon (~> 0.12.0)
excon (~> 0.12.0) excon (~> 0.12.0)
formatador (~> 0.2.0) formatador (~> 0.2.0)
formatador (~> 0.2.0)
mime-types
mime-types mime-types
multi_json (~> 1.0) multi_json (~> 1.0)
multi_json (~> 1.0)
net-scp (~> 1.0.4)
net-scp (~> 1.0.4) net-scp (~> 1.0.4)
net-ssh (>= 2.1.3) net-ssh (>= 2.1.3)
net-ssh (>= 2.1.3)
nokogiri (~> 1.5.0) nokogiri (~> 1.5.0)
nokogiri (~> 1.5.0)
ruby-hmac
ruby-hmac ruby-hmac
foreigner (1.1.5) foreigner (1.1.5)
activerecord (>= 3.0.0) activerecord (>= 3.0.0)
@ -213,10 +204,11 @@ GEM
heroku (>= 2) heroku (>= 2)
rails (>= 2) rails (>= 2)
highline (1.6.11) highline (1.6.11)
hike (1.2.1)
hodel_3000_compliant_logger (0.1.0) hodel_3000_compliant_logger (0.1.0)
http_accept_language (1.0.2) http_accept_language (1.0.2)
http_parser.rb (0.5.3) http_parser.rb (0.5.3)
i18n (0.5.0) i18n (0.6.0)
i18n-inflector (2.6.6) i18n-inflector (2.6.6)
i18n (>= 0.4.1) i18n (>= 0.4.1)
i18n-inflector-rails (1.0.6) i18n-inflector-rails (1.0.6)
@ -246,13 +238,12 @@ GEM
rbx-require-relative (> 0.0.4) rbx-require-relative (> 0.0.4)
linecache19 (0.5.12) linecache19 (0.5.12)
ruby_core_source (>= 0.1.4) ruby_core_source (>= 0.1.4)
mail (2.2.19) mail (2.3.3)
activesupport (>= 2.3.6)
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
messagebus_ruby_api (1.0.3) messagebus_ruby_api (1.0.3)
mime-types (1.17.2) mime-types (1.18)
mimemagic (0.1.8) mimemagic (0.1.8)
mini_magick (3.4) mini_magick (3.4)
subexec (~> 0.2.1) subexec (~> 0.2.1)
@ -267,7 +258,7 @@ GEM
gem_plugin (>= 0.2.3) gem_plugin (>= 0.2.3)
multi_json (1.0.4) multi_json (1.0.4)
multipart-post (1.1.5) multipart-post (1.1.5)
mysql2 (0.2.18) mysql2 (0.3.11)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
net-sftp (2.0.5) net-sftp (2.0.5)
@ -311,37 +302,44 @@ GEM
pg (0.13.2) pg (0.13.2)
polyglot (0.3.3) polyglot (0.3.3)
proxies (0.2.1) 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-cors (0.2.4)
rack rack
rack-fiber_pool (0.9.2) rack-fiber_pool (0.9.2)
rack-google-analytics (0.10.0) rack-google-analytics (0.10.0)
rack-mobile-detect (0.3.0) rack-mobile-detect (0.3.0)
rack rack
rack-mount (0.6.14) rack-mount (0.8.3)
rack (>= 1.0.0) rack (>= 1.0.0)
rack-piwik (0.1.2) rack-piwik (0.1.2)
rack-protection (1.2.0)
rack
rack-rewrite (1.2.1) rack-rewrite (1.2.1)
rack-ssl (1.3.2) rack-ssl (1.3.2)
rack rack
rack-test (0.5.7) rack-test (0.6.1)
rack (>= 1.0) rack (>= 1.0)
rails (3.0.11) rails (3.1.4)
actionmailer (= 3.0.11) actionmailer (= 3.1.4)
actionpack (= 3.0.11) actionpack (= 3.1.4)
activerecord (= 3.0.11) activerecord (= 3.1.4)
activeresource (= 3.0.11) activeresource (= 3.1.4)
activesupport (= 3.0.11) activesupport (= 3.1.4)
bundler (~> 1.0) bundler (~> 1.0)
railties (= 3.0.11) railties (= 3.1.4)
rails-i18n (0.5.2) rails-i18n (0.5.2)
i18n (~> 0.5) i18n (~> 0.5)
railties (3.0.11) rails_autolink (1.0.6)
actionpack (= 3.0.11) rails (~> 3.1)
activesupport (= 3.0.11) railties (3.1.4)
actionpack (= 3.1.4)
activesupport (= 3.1.4)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7) rake (>= 0.8.7)
rdoc (~> 3.4) rdoc (~> 3.4)
thor (~> 0.14.4) thor (~> 0.14.6)
raindrops (0.8.0) raindrops (0.8.0)
rake (0.9.2.2) rake (0.9.2.2)
rbx-require-relative (0.0.9) rbx-require-relative (0.0.9)
@ -351,7 +349,7 @@ GEM
redis (2.2.2) redis (2.2.2)
redis-namespace (1.0.3) redis-namespace (1.0.3)
redis (< 3.0.0) redis (< 3.0.0)
resque (1.19.0) resque (1.20.0)
multi_json (~> 1.0) multi_json (~> 1.0)
redis-namespace (~> 1.0.2) redis-namespace (~> 1.0.2)
sinatra (>= 0.9.2) sinatra (>= 0.9.2)
@ -405,9 +403,14 @@ GEM
multi_json (~> 1.0.4) multi_json (~> 1.0.4)
rubyzip rubyzip
simple_oauth (0.1.5) simple_oauth (0.1.5)
sinatra (1.2.8) sinatra (1.3.2)
rack (~> 1.1) rack (~> 1.3, >= 1.3.6)
tilt (>= 1.2.2, < 2.0) 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) sqlite3 (1.3.5)
subexec (0.2.1) subexec (0.2.1)
term-ansicolor (1.0.7) term-ansicolor (1.0.7)
@ -435,7 +438,7 @@ GEM
raindrops (~> 0.7) raindrops (~> 0.7)
vegas (0.1.11) vegas (0.1.11)
rack (>= 1.0.0) rack (>= 1.0.0)
warden (1.0.6) warden (1.1.1)
rack (>= 1.0) rack (>= 1.0)
webmock (1.6.2) webmock (1.6.2)
addressable (>= 2.2.2) addressable (>= 2.2.2)
@ -456,7 +459,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
SystemTimer (= 1.2.3) SystemTimer (= 1.2.3)
active_reload active_reload
activerecord-import activerecord-import (~> 0.2.9)
acts-as-taggable-on! acts-as-taggable-on!
acts_as_api acts_as_api
addressable (= 2.2.4) addressable (= 2.2.4)
@ -471,7 +474,7 @@ DEPENDENCIES
cucumber-api-steps (= 0.6) cucumber-api-steps (= 0.6)
cucumber-rails (= 1.2.1) cucumber-rails (= 1.2.1)
database_cleaner (= 0.7.1) database_cleaner (= 0.7.1)
devise (~> 1.3.1) devise (= 1.5.3)
diaspora-client! diaspora-client!
em-synchrony (= 1.0.0) em-synchrony (= 1.0.0)
factory_girl_rails factory_girl_rails
@ -498,7 +501,7 @@ DEPENDENCIES
mobile-fu mobile-fu
mock_redis mock_redis
mongrel mongrel
mysql2 (= 0.2.18) mysql2 (= 0.3.11)
newrelic_rpm newrelic_rpm
nokogiri (= 1.5.0) nokogiri (= 1.5.0)
oauth2-provider (= 0.0.19) oauth2-provider (= 0.0.19)
@ -514,10 +517,11 @@ DEPENDENCIES
rack-piwik rack-piwik
rack-rewrite (~> 1.2.1) rack-rewrite (~> 1.2.1)
rack-ssl rack-ssl
rails (= 3.0.11) rails (= 3.1.4)
rails-i18n rails-i18n
rails_autolink
redcarpet (= 2.0.1) redcarpet (= 2.0.1)
resque (= 1.19.0) resque (= 1.20.0)
resque-ensure-connected! resque-ensure-connected!
resque-timeout (= 1.0.0) resque-timeout (= 1.0.0)
rest-client (= 1.6.7) rest-client (= 1.6.7)

View file

@ -44,8 +44,9 @@ class AspectMembershipsController < ApplicationController
def create def create
@person = Person.find(params[:person_id]) @person = Person.find(params[:person_id])
@aspect = current_user.aspects.where(:id => params[:aspect_id]).first @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') flash.now[:notice] = I18n.t('aspects.add_to_aspect.success')
respond_with AspectMembership.where(:contact_id => @contact.id, :aspect_id => @aspect.id).first respond_with AspectMembership.where(:contact_id => @contact.id, :aspect_id => @aspect.id).first
else else

View file

@ -3,7 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
module ApplicationHelper module ApplicationHelper
def how_long_ago(obj) def how_long_ago(obj)
timeago(obj.created_at) timeago(obj.created_at)
end end

View file

@ -9,9 +9,9 @@ module PeopleHelper
if search_query.blank? if search_query.blank?
content_tag(:h2, t('people.index.no_results')) content_tag(:h2, t('people.index.no_results'))
else else
content_tag(:h2, :id => 'search_title') do content_tag(:h2, :id => 'search_title') do
t('people.index.results_for').html_safe + ' ' + t('people.index.results_for').html_safe + ' ' +
content_tag(:span, search_query, :class => 'term') content_tag(:span, search_query, :class => 'term')
end end
end end
end end
@ -66,13 +66,13 @@ module PeopleHelper
def person_href(person, opts={}) def person_href(person, opts={})
"href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe "href=\"#{local_or_remote_person_path(person, opts)}\"".html_safe
end end
# Rails.application.routes.url_helpers is needed since this is indirectly called from a model # Rails.application.routes.url_helpers is needed since this is indirectly called from a model
def local_or_remote_person_path(person, opts={}) def local_or_remote_person_path(person, opts={})
opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority) opts.merge!(:protocol => AppConfig[:pod_uri].scheme, :host => AppConfig[:pod_uri].authority)
absolute = opts.delete(:absolute) absolute = opts.delete(:absolute)
if person.local? if person.local?
username = person.diaspora_handle.split('@')[0] username = person.diaspora_handle.split('@')[0]
unless username.include?('.') unless username.include?('.')
@ -84,7 +84,7 @@ module PeopleHelper
end end
end end
end end
if absolute if absolute
return Rails.application.routes.url_helpers.person_url(person, opts) return Rails.application.routes.url_helpers.person_url(person, opts)
else else

View file

@ -23,7 +23,7 @@ class InvitationCode < ActiveRecord::Base
def generate_token def generate_token
begin begin
self.token = ActiveSupport::SecureRandom.hex(6) self.token = SecureRandom.hex(6)
end while InvitationCode.exists?(:token => self[:token]) end while InvitationCode.exists?(:token => self[:token])
end end

View file

@ -71,7 +71,7 @@ class Photo < ActiveRecord::Base
photo.pending = params[:pending] if params[:pending] photo.pending = params[:pending] if params[:pending]
photo.diaspora_handle = photo.author.diaspora_handle photo.diaspora_handle = photo.author.diaspora_handle
photo.random_string = ActiveSupport::SecureRandom.hex(10) photo.random_string = SecureRandom.hex(10)
if params[:user_file] if params[:user_file]
image_file = params.delete(:user_file) image_file = params.delete(:user_file)

View file

@ -41,7 +41,7 @@ class User < ActiveRecord::Base
has_many :aspects, :order => 'order_id ASC' has_many :aspects, :order => 'order_id ASC'
belongs_to :auto_follow_back_aspect, :class_name => 'Aspect' 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 has_many :aspect_memberships, :through => :aspects
@ -438,7 +438,7 @@ class User < ActiveRecord::Base
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
if unconfirmed_email_changed? 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
end end
@ -454,10 +454,10 @@ class User < ActiveRecord::Base
def generate_keys def generate_keys
key_size = (Rails.env == 'test' ? 512 : 4096) 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? 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
end end
@ -495,7 +495,7 @@ class User < ActiveRecord::Base
end end
self[:email] = "deletedaccount_#{self[:id]}@example.org" self[:email] = "deletedaccount_#{self[:id]}@example.org"
random_password = ActiveSupport::SecureRandom.hex(20) random_password = SecureRandom.hex(20)
self.password = random_password self.password = random_password
self.password_confirmation = random_password self.password_confirmation = random_password
self.save(:validate => false) self.save(:validate => false)

View file

@ -29,7 +29,9 @@ Diaspora::Application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr 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. # 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, # This is necessary if your schema can't be completely dumped by the schema dumper,

View file

@ -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 ##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 class OpenSSL::PKey::RSA
def to_yaml def to_yaml(opts=nil)
self.to_s self.to_s
end end
end end
#
#

View file

@ -16,7 +16,7 @@ Feature: Close Account
When I try to sign in manually When I try to sign in manually
Then I should be on the new user session page Then I should be on the new user session page
When I wait for the ajax to finish 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 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" Given a user named "Bob Jones" with email "bob@bob.bob"

View file

@ -73,7 +73,7 @@ Feature: following and being followed
And I wait for the ajax to finish And I wait for the ajax to finish
And I fill in "Name" with "Super People" in the modal window 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 And I wait for the ajax to finish
When I go to the home page When I go to the home page

View file

@ -13,6 +13,6 @@ module Diaspora::Guid
# @return [String] The model's guid. # @return [String] The model's guid.
def set_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
end end

View file

@ -3,7 +3,7 @@ namespace :generate do
task :secret_token do task :secret_token do
path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb') 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| File.open(path, 'w') do |f|
f.write <<"EOF" f.write <<"EOF"
# Copyright (c) 2010-2011, Diaspora Inc. This file is # Copyright (c) 2010-2011, Diaspora Inc. This file is

View file

@ -9,7 +9,7 @@ namespace :heroku do
task :generate_secret_token do task :generate_secret_token do
puts "Generating and setting a new secret token" 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}" command = "#{HEROKU_CONFIG_ADD_COMMAND} SECRET_TOKEN=#{token}"
puts command puts command
system command system command

View file

@ -24,7 +24,7 @@ var Publisher = {
}, },
submit: function(){ 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(){ determineSubmitAvailability: function(){
@ -32,8 +32,8 @@ var Publisher = {
isSubmitDisabled = Publisher.submit().attr('disabled'), isSubmitDisabled = Publisher.submit().attr('disabled'),
isPhotoAttached = ($("#photodropzone").children().length > 0); isPhotoAttached = ($("#photodropzone").children().length > 0);
if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) { if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) {
Publisher.submit().attr('disabled', true); Publisher.submit().attr('disabled', 'disabled');
} else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) { } else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) {
Publisher.submit().removeAttr('disabled'); Publisher.submit().removeAttr('disabled');
} }
@ -43,6 +43,8 @@ var Publisher = {
$("#photodropzone").find('li').remove(); $("#photodropzone").find('li').remove();
Publisher.input().mentionsInput("reset"); Publisher.input().mentionsInput("reset");
Publisher.wrapper().removeClass("with_attachments"); Publisher.wrapper().removeClass("with_attachments");
Publisher.hiddenInput().val('');
Publisher.determineSubmitAvailability()
}, },
bindServiceIcons: function(){ bindServiceIcons: function(){

View file

@ -43,6 +43,8 @@ describe AspectMembershipsController do
end end
it 'creates a contact' do it 'creates a contact' do
#argggg why?
alice.contacts.reload
lambda { lambda {
post :create, post :create,
:format => 'js', :format => 'js',

View file

@ -49,7 +49,7 @@ describe PostsController do
get :show, :id => photo.id get :show, :id => photo.id
response.should be_success response.should be_success
end end
it 'redirects if the post is missing' do it 'redirects if the post is missing' do
get :show, :id => 1234567 get :show, :id => 1234567
response.should be_redirect response.should be_redirect
@ -94,7 +94,7 @@ describe PostsController do
end end
it 'assumes guids less than 8 chars are ids and not guids' do 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 get :show, :id => @status.id
response.should be_success response.should be_success
end end

View file

@ -7,7 +7,7 @@
# http://railscasts.com/episodes/158-factories-not-fixtures # http://railscasts.com/episodes/158-factories-not-fixtures
def r_str def r_str
ActiveSupport::SecureRandom.hex(3) SecureRandom.hex(3)
end end
FactoryGirl.define do FactoryGirl.define do
@ -100,7 +100,7 @@ FactoryGirl.define do
end end
factory(:photo) do factory(:photo) do
sequence(:random_string) {|n| ActiveSupport::SecureRandom.hex(10) } sequence(:random_string) {|n| SecureRandom.hex(10) }
association :author, :factory => :person association :author, :factory => :person
after_build do |p| after_build do |p|
p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png'))
@ -237,7 +237,7 @@ FactoryGirl.define do
end end
factory(:note, :parent => :status_message) do factory(:note, :parent => :status_message) do
text ActiveSupport::SecureRandom.hex(1000) text SecureRandom.hex(1000)
end end
factory(:rich_media, :parent => :status_message) do factory(:rich_media, :parent => :status_message) do

View file

@ -3,6 +3,7 @@ require 'spec_helper'
describe NotificationsHelper do describe NotificationsHelper do
include ApplicationHelper include ApplicationHelper
before do before do
@user = Factory(:user) @user = Factory(:user)
@person = Factory(:person) @person = Factory(:person)

View file

@ -9,6 +9,7 @@ describe PeopleHelper do
@user = alice @user = alice
@person = Factory(:person) @person = Factory(:person)
end end
describe "#person_image_link" do describe "#person_image_link" do
it "returns an empty string if person is nil" do it "returns an empty string if person is nil" do
person_image_link(nil).should == "" person_image_link(nil).should == ""
@ -62,12 +63,12 @@ describe PeopleHelper do
describe "#person_href" do describe "#person_href" do
it "calls local_or_remote_person_path and passes through the options" do it "calls local_or_remote_person_path and passes through the options" do
opts = {:absolute => true} opts = {:absolute => true}
self.should_receive(:local_or_remote_person_path).with(@person, opts).exactly(1).times self.should_receive(:local_or_remote_person_path).with(@person, opts).exactly(1).times
person_href(@person, opts) person_href(@person, opts)
end end
it "returns a href attribute" do it "returns a href attribute" do
person_href(@person).should include "href=" person_href(@person).should include "href="
end end
@ -77,7 +78,7 @@ describe PeopleHelper do
before do before do
@user = Factory(:user) @user = Factory(:user)
end end
it "links by id if there is a period in the user's username" do it "links by id if there is a period in the user's username" do
@user.username = "invalid.username" @user.username = "invalid.username"
@user.save(:validate => false).should == true @user.save(:validate => false).should == true
@ -91,7 +92,7 @@ describe PeopleHelper do
it 'links by username for a local user' do it 'links by username for a local user' do
local_or_remote_person_path(@user.person).should == user_profile_path(:username => @user.username) local_or_remote_person_path(@user.person).should == user_profile_path(:username => @user.username)
end end
it 'links by id for a remote person' do it 'links by id for a remote person' do
local_or_remote_person_path(@person).should == person_path(@person) local_or_remote_person_path(@person).should == person_path(@person)
end end

View file

@ -5,11 +5,13 @@ describe TagsHelper do
it 'returns nil if there is a @ in the query' do it 'returns nil if there is a @ in the query' do
helper.stub(:search_query).and_return('foo@bar.com') helper.stub(:search_query).and_return('foo@bar.com')
helper.looking_for_tag_link.should be_nil helper.looking_for_tag_link.should be_nil
end end
it 'returns nil if it normalizes to blank' do it 'returns nil if it normalizes to blank' do
helper.stub(:search_query).and_return('++') helper.stub(:search_query).and_return('++')
helper.looking_for_tag_link.should be_nil helper.looking_for_tag_link.should be_nil
end end
it 'returns a link to the tag otherwise' do it 'returns a link to the tag otherwise' do
helper.stub(:search_query).and_return('foo') helper.stub(:search_query).and_return('foo')
helper.looking_for_tag_link.should include(helper.tag_link) helper.looking_for_tag_link.should include(helper.tag_link)

View file

@ -27,9 +27,7 @@ describe Person do
Person.for_json.first.serialized_public_key Person.for_json.first.serialized_public_key
}.should raise_error ActiveModel::MissingAttributeError }.should raise_error ActiveModel::MissingAttributeError
end end
it 'eager loads profiles' do
Person.for_json.first.loaded_profile?.should be_true
end
it 'selects distinct people' do it 'selects distinct people' do
aspect = bob.aspects.create(:name => 'hilarious people') aspect = bob.aspects.create(:name => 'hilarious people')
aspect.contacts << bob.contact_for(eve.person) aspect.contacts << bob.contact_for(eve.person)

View file

@ -3,17 +3,19 @@ require 'spec_helper'
describe Service do describe Service do
before do before do
@user = alice @post = alice.post(:status_message, :text => "hello", :to => alice.aspects.first.id)
@post = @user.post(:status_message, :text => "hello", :to =>@user.aspects.first.id) @service = Services::Facebook.new(:access_token => "yeah", :uid => 1)
@service = Services::Facebook.new(:access_token => "yeah") alice.services << @service
@user.services << @service
end end
it 'is unique to a user by service type and uid' do it 'is unique to a user by service type and uid' do
@service.save @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 end
it 'destroys the associated service_user' do it 'destroys the associated service_user' do
@ -28,6 +30,6 @@ describe Service do
end end
it 'by default has no profile photo url' do 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
end end

View file

@ -30,17 +30,17 @@ describe Services::Twitter do
end end
describe "message size limits" do describe "message size limits" do
before :each do before :each do
@long_message_start = ActiveSupport::SecureRandom.hex(25) @long_message_start = SecureRandom.hex(25)
@long_message_end = ActiveSupport::SecureRandom.hex(25) @long_message_end = SecureRandom.hex(25)
end end
it "should not truncate a short message" do 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 ) short_post = stub(:text => short_message )
@service.public_message(short_post, '').should == short_message @service.public_message(short_post, '').should == short_message
end end
it "should truncate a long message" do it "should truncate a long message" do
long_message = ActiveSupport::SecureRandom.hex(220) long_message = SecureRandom.hex(220)
long_post = stub(:text => long_message ) long_post = stub(:text => long_message )
@service.public_message(long_post, '').should == long_message.first(137) + "..." @service.public_message(long_post, '').should == long_message.first(137) + "..."
end end

View file

@ -12,7 +12,9 @@ describe User do
it 'marshalls the key to and from the db correctly' 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 = User.build(:username => 'max', :email => 'foo@bar.com', :password => 'password', :password_confirmation => 'password')
user.save! user.save!
user.serialized_private_key.should be_present
expect{ expect{
user.reload.encryption_key user.reload.encryption_key
@ -846,7 +848,7 @@ describe User do
describe "#clear_account!" do describe "#clear_account!" do
it 'resets the password to a random string' do it 'resets the password to a random string' do
random_pass = "12345678909876543210" random_pass = "12345678909876543210"
ActiveSupport::SecureRandom.should_receive(:hex).and_return(random_pass) SecureRandom.should_receive(:hex).and_return(random_pass)
@user.clear_account! @user.clear_account!
@user.valid_password?(random_pass) @user.valid_password?(random_pass)
end end