From 453cb066917381c664f3db29acd4033df009c738 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:01:30 -0700 Subject: [PATCH 01/43] changing settings and deploy scripts, validating email --- app/models/user.rb | 2 ++ config/environments/production.rb | 9 +++------ config/thin.yml | 6 +++--- db/seeds/tom.rb | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7ab2987d9..80241fbed 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,6 +21,8 @@ class User ######## Making things work ######## key :email, String + validates_true_for :email, :logic => lambda { + email.include?('@pivotallabs.com') || email.include?('@pivotalsf.com')} def method_missing(method, *args) self.person.send(method, *args) diff --git a/config/environments/production.rb b/config/environments/production.rb index 0dc2c9b99..48d9f701a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -10,10 +10,10 @@ Diaspora::Application.configure do config.action_controller.perform_caching = true # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + #config.action_dispatch.x_sendfile_header = "X-Sendfile" # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # If you have no front-end server that supports something like X-Sendfile, # just comment this out and Rails will serve the files @@ -29,7 +29,7 @@ Diaspora::Application.configure do # Disable Rails's static asset server # In production, Apache or nginx will already do this - config.serve_static_assets = true + #config.serve_static_assets = true # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" @@ -37,9 +37,6 @@ Diaspora::Application.configure do # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false - # Enable threaded mode - # config.threadsafe! - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true diff --git a/config/thin.yml b/config/thin.yml index f60fed103..fa84529dd 100644 --- a/config/thin.yml +++ b/config/thin.yml @@ -8,8 +8,8 @@ require: [] max_persistent_conns: 512 environment: production -servers: 1 +servers: 4 daemonize: true #chdir: /usr/applications/localhash/current -#socket: /tmp/thin.sock -port: 80 +socket: /tmp/thin.sock +#port: 80 diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c8b1d41a6..10a7e910e 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -1,6 +1,7 @@ require 'config/environment' remote_url = "http://tom.joindiaspora.com/" +remote_url = "http://localhost:3000/" # Create seed user user = User.create!( :email => "tom@tom.joindiaspora.com", :password => "evankorth", From 29e3fa4d04f34eb6aef2b18fd1e9eb4404c83fc7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:04:34 -0700 Subject: [PATCH 02/43] sprinkle role --- config/sprinkle/provision.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index 63302b874..8107f3f6e 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -33,7 +33,7 @@ require "#{File.dirname(__FILE__)}/packages/ruby" # If there's only one implementation of a virtual package, it's selected automatically, otherwise # the user is requested to select which one to use. -policy :diaspora, :roles => [:tom, :backer] do +policy :diaspora, :roles => [:pivots] do # requires :clean_dreamhost requires :tools requires :rubygems From 16f53922c5d913670655cbddbb32ace95c278ba3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:22:06 -0700 Subject: [PATCH 03/43] nginx conf done, comments deleted --- config/sprinkle/conf/nginx.conf | 7 ++++-- config/sprinkle/packages/server.rb | 32 -------------------------- config/sprinkle/provision.rb | 36 ------------------------------ 3 files changed, 5 insertions(+), 70 deletions(-) diff --git a/config/sprinkle/conf/nginx.conf b/config/sprinkle/conf/nginx.conf index ad79a9b5a..514bc2957 100644 --- a/config/sprinkle/conf/nginx.conf +++ b/config/sprinkle/conf/nginx.conf @@ -28,12 +28,15 @@ http { # gzip_disable "MSIE [1-6]\.(?!.*SV1)"; upstream thin_cluster { server unix:/tmp/thin.0.sock; + server unix:/tmp/thin.1.sock; + server unix:/tmp/thin.2.sock; + server unix:/tmp/thin.3.sock; } server { - listen 80; - server_name babycakes.sofaer.net www.babycakes.sofaer.net; + listen 80 + server_name pivots.joindiaspora.com www.pivots.joindiaspora.com; root /usr/local/app/diaspora/current; location / { diff --git a/config/sprinkle/packages/server.rb b/config/sprinkle/packages/server.rb index 99f326c8b..0b9f416de 100644 --- a/config/sprinkle/packages/server.rb +++ b/config/sprinkle/packages/server.rb @@ -18,35 +18,3 @@ package :nginx_dependencies do apt %w( libc6 libpcre3 libpcre3-dev libssl0.9.8) source "http://zlib.net/zlib-1.2.5.tar.gz" end - -=begin -package :mongrel do - description 'Mongrel Application Server' - gem 'mongrel' - version '1.1.5' -end - -package :mongrel_cluster, :provides => :appserver do - description 'Cluster Management for Mongrel' - gem 'mongrel_cluster' - version '1.0.5' - requires :mongrel -end - -package :apache, :provides => :webserver do - description 'Apache 2 HTTP Server' - version '2.2.15' - - source "http://download.nextag.com/apache/httpd/httpd-#{version}.tar.bz2" do - enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so ) - prefix "/opt/local/apache2-#{version}" - post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults' - end - requires :apache_dependencies -end - -package :apache_dependencies do - description 'Apache 2 HTTP Server Build Dependencies' - apt %w( openssl libtool mawk zlib1g-dev libssl-dev ) -end -=end diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index 8107f3f6e..ec1c44c16 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -1,37 +1,11 @@ #!/usr/bin/env sprinkle -s -# Annotated Example Sprinkle Rails deployment script -# -# This is an example Sprinkle script configured to install Rails from gems, Apache, Ruby, -# Sphinx and Git from source, and mysql and Git dependencies from apt on an Ubuntu system. -# -# Installation is configured to run via capistrano (and an accompanying deploy.rb recipe script). -# Source based packages are downloaded and built into /usr/local on the remote system. -# -# A sprinkle script is separated into 3 different sections. Packages, policies and deployment: - - -# Packages (separate files for brevity) -# -# Defines the world of packages as we know it. Each package has a name and -# set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have -# relationships to each other via dependencies. require "#{File.dirname(__FILE__)}/packages/essential" require "#{File.dirname(__FILE__)}/packages/database" require "#{File.dirname(__FILE__)}/packages/server" require "#{File.dirname(__FILE__)}/packages/scm" require "#{File.dirname(__FILE__)}/packages/ruby" -#require "#{File.dirname(__FILE__)}/packages/unfortunately_essential" - -# Policies -# -# Names a group of packages (optionally with versions) that apply to a particular set of roles: -# -# Associates the rails policy to the application servers. Contains rails, and surrounding -# packages. Note, appserver, database, webserver and search are all virtual packages defined above. -# If there's only one implementation of a virtual package, it's selected automatically, otherwise -# the user is requested to select which one to use. policy :diaspora, :roles => [:pivots] do # requires :clean_dreamhost @@ -45,14 +19,6 @@ policy :diaspora, :roles => [:pivots] do requires :vim end -# Deployment -# -# Defines script wide settings such as a delivery mechanism for executing commands on the target -# system (eg. capistrano), and installer defaults (eg. build locations, etc): -# -# Configures spinkle to use capistrano for delivery of commands to the remote machines (via -# the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear -# in /usr/local deployment do @@ -73,5 +39,3 @@ deployment do end end -# End of script, given the above information, Spinkle will apply the defined policy on all roles using the -# deployment settings specified. From 2261a0d8a467d7072760ea5751a8d42445bb8076 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:28:22 -0700 Subject: [PATCH 04/43] nginx... --- config/sprinkle/conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sprinkle/conf/nginx.conf b/config/sprinkle/conf/nginx.conf index 514bc2957..3d8b9cb2a 100644 --- a/config/sprinkle/conf/nginx.conf +++ b/config/sprinkle/conf/nginx.conf @@ -35,7 +35,7 @@ http { server { - listen 80 + listen 80; server_name pivots.joindiaspora.com www.pivots.joindiaspora.com; root /usr/local/app/diaspora/current; From b55a99ec09cc48ef7ce97e466471aa275f272eee Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:42:59 -0700 Subject: [PATCH 05/43] conf changes, kill nginx with go_cold --- config/sprinkle/conf/nginx.conf | 3 --- config/sprinkle/packages/server.rb | 5 ++--- config/sprinkle/provision.rb | 1 + config/thin.yml | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/config/sprinkle/conf/nginx.conf b/config/sprinkle/conf/nginx.conf index 3d8b9cb2a..d76534f37 100644 --- a/config/sprinkle/conf/nginx.conf +++ b/config/sprinkle/conf/nginx.conf @@ -28,9 +28,6 @@ http { # gzip_disable "MSIE [1-6]\.(?!.*SV1)"; upstream thin_cluster { server unix:/tmp/thin.0.sock; - server unix:/tmp/thin.1.sock; - server unix:/tmp/thin.2.sock; - server unix:/tmp/thin.3.sock; } server { diff --git a/config/sprinkle/packages/server.rb b/config/sprinkle/packages/server.rb index 0b9f416de..c553707b3 100644 --- a/config/sprinkle/packages/server.rb +++ b/config/sprinkle/packages/server.rb @@ -1,16 +1,15 @@ -package :nginx do +package :nginx, :provides=> :webserver do description 'Nginx HTTP server' version '0.7.67' source "http://nginx.org/download/nginx-#{version}.tar.gz" requires :nginx_dependencies end -package :nginx_conf, :provides=> :webserver do +package :nginx_conf do description 'Nginx conf file' transfer "#{File.dirname(__FILE__)}/../conf/nginx.conf", '/usr/local/conf/nginx.conf', :render => true do pre :install, "mkdir -p /usr/local/sbin/conf/" end - requires :nginx end package :nginx_dependencies do diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index ec1c44c16..239f03fb2 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -17,6 +17,7 @@ policy :diaspora, :roles => [:pivots] do requires :webserver requires :scm requires :vim + requires :nginx_conf end diff --git a/config/thin.yml b/config/thin.yml index fa84529dd..564eef8d6 100644 --- a/config/thin.yml +++ b/config/thin.yml @@ -8,7 +8,7 @@ require: [] max_persistent_conns: 512 environment: production -servers: 4 +servers: 1 daemonize: true #chdir: /usr/applications/localhash/current socket: /tmp/thin.sock From 015940b60ea371258f2889eb9117a6279540fe73 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:45:47 -0700 Subject: [PATCH 06/43] Pass to the lambda --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 80241fbed..58d45c3c2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,7 +21,7 @@ class User ######## Making things work ######## key :email, String - validates_true_for :email, :logic => lambda { + validates_true_for :email, :logic => lambda { |email| email.include?('@pivotallabs.com') || email.include?('@pivotalsf.com')} def method_missing(method, *args) From ccbbf40584d5c1609a27822e46947d261370b022 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 11:48:59 -0700 Subject: [PATCH 07/43] validation lambda out to method --- app/models/user.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 58d45c3c2..9b6410966 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,8 +21,11 @@ class User ######## Making things work ######## key :email, String - validates_true_for :email, :logic => lambda { |email| - email.include?('@pivotallabs.com') || email.include?('@pivotalsf.com')} + validates_true_for :email, :logic => lambda { self.pivotal_email?} + + def pivotal_email? + email.include?('@pivotallabs.com') + end def method_missing(method, *args) self.person.send(method, *args) From 842b321dfa6b85e25ac273846ce4e63c3dd6bdab Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:02:42 -0700 Subject: [PATCH 08/43] User email checking, routes working again --- app/controllers/users_controller.rb | 14 -------------- app/models/user.rb | 28 +++++++++++++--------------- config/routes.rb | 2 +- spec/factories.rb | 2 +- spec/models/user_spec.rb | 14 -------------- spec/spec_helper.rb | 1 + 6 files changed, 16 insertions(+), 45 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 12f87c481..e5e2e263c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -26,19 +26,5 @@ class UsersController < ApplicationController end end - def create - @user = User.instantiate(params[:user]) - - if @user.created_at && @user.person.created_at - flash[:notice] = "Successfully signed up." - redirect_to root_path - else - render :action => 'new' - end - end - - def new - @user = User.new - end end diff --git a/app/models/user.rb b/app/models/user.rb index 9b6410966..197fc4ea0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,17 +16,22 @@ class User many :groups, :class_name => 'Group' - before_validation_on_create :assign_key - before_validation :do_bad_things - + before_validation_on_create :setup_person + before_create :pivotal_only + ######## Making things work ######## key :email, String - validates_true_for :email, :logic => lambda { self.pivotal_email?} + #validates_true_for :email, :logic => lambda {self.pivotal_email?} + def pivotal_email? email.include?('@pivotallabs.com') end + def pivotal_only + raise "pivotal only" unless pivotal_email? + end + def method_missing(method, *args) self.person.send(method, *args) end @@ -234,12 +239,7 @@ class User end ###Helpers############ - def self.instantiate( opts = {} ) - opts[:person][:email] = opts[:email] - opts[:person][:serialized_key] = generate_key - User.create( opts) - end - + def terse_url terse= self.url.gsub(/https?:\/\//, '') terse.gsub!(/www\./, '') @@ -247,10 +247,6 @@ class User terse end - def do_bad_things - self.password_confirmation = self.password - end - def friend_by_id( id ) friends.detect{|x| x.id == ensure_bson( id ) } end @@ -261,8 +257,10 @@ class User protected - def assign_key + def setup_person self.person.serialized_key ||= generate_key.export + self.person.email = email + self.person.save end def generate_key diff --git a/config/routes.rb b/config/routes.rb index 88c838d77..0cf622127 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ Diaspora::Application.routes.draw do |map| resources :blogs resources :bookmarks resources :people - resources :users + resources :users, :except => [:new, :create] resources :status_messages resources :comments resources :requests diff --git a/spec/factories.rb b/spec/factories.rb index 88f34e1f6..ba3aadeb9 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -24,7 +24,7 @@ Factory.define :person_with_user, :parent => :person_with_private_key do |p| end Factory.define :user do |u| - u.sequence(:email) {|n| "bob#{n}@aol.com"} + u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"} u.password "bluepin7" u.password_confirmation "bluepin7" u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)} diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e0d2415c7..fd78af0a3 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -6,20 +6,6 @@ describe User do @group = @user.group(:name => 'heroes') end - it 'should instantiate with a person and be valid' do - user = User.instantiate(:email => "bob@bob.com", - :password => "password", - :password_confirmation => "password", - :person => - {:profile => { - :first_name => "bob", - :last_name => "grimm"}}) - - user.save.should be true - user.person.should_not be nil - user.person.profile.should_not be nil - end - describe 'friend requesting' do it "should assign a request to a group" do friend = Factory.create(:person) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d0b2759cb..cadde8dcc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,6 +26,7 @@ RSpec.configure do |config| config.before(:each) do DatabaseCleaner.start stub_sockets_controller + User.stub(:pivotal_only).and_return(:true) end config.after(:each) do From d5c608c7aef1c3a2e8d91393c7161612349ffb47 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:07:11 -0700 Subject: [PATCH 09/43] Removing welcome home line --- app/views/groups/index.html.haml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index e4d1ecca2..f1785389d 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,7 +1,3 @@ -%h1 - welcome home, - = current_user.profile.first_name - = render "shared/publisher" %ul#stream From e6768cb5c8831f56aa7e064097a65e8a821cb385 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:21:29 -0700 Subject: [PATCH 10/43] helper method --- app/models/user.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 53cde243e..109a2d987 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,7 +36,6 @@ class User self.person.send(method, *args) end - def real_name "#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}" end @@ -269,6 +268,9 @@ class User groups.detect{|x| x.id == ensure_bson( id ) } end + def tommy? + email.include?("tommy@pivotallabs.com") || email.include?("tsullivan@pivotallabs.com") + end protected def setup_person From 424f576d95d8b55cf71bc31c211273a028e88659 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:48:09 -0700 Subject: [PATCH 11/43] Actionmailer config --- config/environments/production.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 48d9f701a..fb9f8f97e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -42,4 +42,14 @@ Diaspora::Application.configure do config.i18n.fallbacks = true config.threadsafe! + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + :address => 'smtp.joindiaspora.com', + :port => 587 + :domain => 'www.joindiaspora.com' + :authentication => 'plain' + :user_name => 'diaspora-pivots' + :password => "xy289|]G+R*-kA" + :enable_starttls_auto => true + } end From 771c594814ca75620a57f787fc9f124618e87459 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:49:18 -0700 Subject: [PATCH 12/43] Take out pivotal only for a second --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 109a2d987..3f6e368f2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,7 +17,7 @@ class User many :groups, :class_name => 'Group' before_validation_on_create :setup_person - before_create :pivotal_only + #before_create :pivotal_only ######## Making things work ######## key :email, String From 2ede5f499f1bfdfe89705b05376c7ec2ecb29cd2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:53:15 -0700 Subject: [PATCH 13/43] Commas --- config/environments/production.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index fb9f8f97e..354aed8f7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -45,11 +45,11 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => 'smtp.joindiaspora.com', - :port => 587 - :domain => 'www.joindiaspora.com' - :authentication => 'plain' - :user_name => 'diaspora-pivots' - :password => "xy289|]G+R*-kA" + :port => 587, + :domain => 'www.joindiaspora.com', + :authentication => 'plain', + :user_name => 'diaspora-pivots', + :password => "xy289|]G+R*-kA", :enable_starttls_auto => true } end From 0fdb337076418e1417702304f8b55399086131f3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:57:45 -0700 Subject: [PATCH 14/43] Confirmable --- app/models/user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3f6e368f2..336ed98ee 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,8 @@ class User include MongoMapper::Document devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable + :recoverable, :rememberable, :trackable, :validatable. + :confirmable key :friend_ids, Array key :pending_request_ids, Array From 063164fea236ca06f422f88c95ee81d97180cc39 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 13:59:57 -0700 Subject: [PATCH 15/43] comma --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 336ed98ee..797880766 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ class User include MongoMapper::Document devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable. + :recoverable, :rememberable, :trackable, :validatable, :confirmable key :friend_ids, Array From cbb1b550ffb30d7caa5875e60b977c335bdca97f Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 14:03:30 -0700 Subject: [PATCH 16/43] Default url --- config/environments/production.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environments/production.rb b/config/environments/production.rb index 354aed8f7..08307c678 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -43,6 +43,7 @@ Diaspora::Application.configure do config.threadsafe! config.action_mailer.delivery_method = :smtp + config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} config.action_mailer.smtp_settings = { :address => 'smtp.joindiaspora.com', :port => 587, From f84d7962fce0fc66dbdcbadebcb77fc2f0f35250 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 14:06:00 -0700 Subject: [PATCH 17/43] actionmailer config --- config/environments/production.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 08307c678..7655eff5e 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -45,9 +45,9 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} config.action_mailer.smtp_settings = { - :address => 'smtp.joindiaspora.com', + :address => 'smtp.gmail.com', :port => 587, - :domain => 'www.joindiaspora.com', + :domain => 'joindiaspora.com', :authentication => 'plain', :user_name => 'diaspora-pivots', :password => "xy289|]G+R*-kA", From 46e7dbedac4a279692532af615ee53a55bbe1e5e Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 15:19:41 -0700 Subject: [PATCH 18/43] Trying to get actionmailer working --- config/environments/production.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 7655eff5e..2481ad94a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -44,7 +44,7 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} - config.action_mailer.smtp_settings = { + smtp_settings = { :address => 'smtp.gmail.com', :port => 587, :domain => 'joindiaspora.com', @@ -53,4 +53,8 @@ Diaspora::Application.configure do :password => "xy289|]G+R*-kA", :enable_starttls_auto => true } + + Mail.defaults do + delivery_method :smtp, smtp_settings + end end From a74ea7e80f87edde829f6e0190abac2be49d40d4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 15:31:14 -0700 Subject: [PATCH 19/43] Back to config actionmailer, the settings are getting set, try mail.joindiaspora.com --- config/environments/production.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 2481ad94a..bfc68495b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -44,17 +44,13 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'} - smtp_settings = { + config.action_mailer.smtp_settings = { :address => 'smtp.gmail.com', :port => 587, - :domain => 'joindiaspora.com', + :domain => 'mail.joindiaspora.com', :authentication => 'plain', :user_name => 'diaspora-pivots', :password => "xy289|]G+R*-kA", :enable_starttls_auto => true } - - Mail.defaults do - delivery_method :smtp, smtp_settings - end end From 188f555c7278d9c929eb4dfff47c1ba7add86be7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 15:47:41 -0700 Subject: [PATCH 20/43] Actionmailer actually working --- config/environments/development.rb | 13 ++++++++++++- config/environments/production.rb | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 12446d661..6314ef6c6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -15,7 +15,18 @@ Diaspora::Application.configure do config.action_controller.perform_caching = false # Don't care if the mailer can't send - config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = true config.active_support.deprecation = :log #config.threadsafe! + config.action_mailer.delivery_method = :smtp + config.action_mailer.default_url_options = {:host => 'localhost:3000'} + config.action_mailer.smtp_settings = { + :address => 'smtp.gmail.com', + :port => 587, + :domain => 'mail.joindiaspora.com', + :authentication => 'plain', + :user_name => 'diaspora-pivots@joindiaspora.com', + :password => "xy289|]G+R*-kA", + :enable_starttls_auto => true + } end diff --git a/config/environments/production.rb b/config/environments/production.rb index bfc68495b..6899e8f1c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -49,7 +49,7 @@ Diaspora::Application.configure do :port => 587, :domain => 'mail.joindiaspora.com', :authentication => 'plain', - :user_name => 'diaspora-pivots', + :user_name => 'diaspora-pivots@joindiaspora.com', :password => "xy289|]G+R*-kA", :enable_starttls_auto => true } From 26a892ab4c5f77c69e811cd9d5c51bc59095e6ee Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 16:43:54 -0700 Subject: [PATCH 21/43] putting email verification back in --- app/models/user.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 39e62258b..416219271 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,19 +18,19 @@ class User many :groups, :class_name => 'Group' before_validation_on_create :setup_person - #before_create :pivotal_only + before_create :pivotal_or_diaspora_only ######## Making things work ######## key :email, String #validates_true_for :email, :logic => lambda {self.pivotal_email?} - def pivotal_email? - email.include?('@pivotallabs.com') + def allowed_email? + email.include?('@pivotallabs.com') || email.include("@joindiaspora.com") end - def pivotal_only - raise "pivotal only" unless pivotal_email? + def pivotal_or_diaspora_only + raise "pivotal only" unless allowed_email? end def method_missing(method, *args) From 6f24a454c8e51c024b7bd79587ba6101e4b4bc0c Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 17:23:37 -0700 Subject: [PATCH 22/43] merge --- app/models/user.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8c116d883..dbcb03526 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,7 +22,6 @@ class User ######## Making things work ######## key :email, String -<<<<<<< HEAD #validates_true_for :email, :logic => lambda {self.pivotal_email?} @@ -33,9 +32,7 @@ class User def pivotal_or_diaspora_only raise "pivotal only" unless allowed_email? end -======= ensure_index :email ->>>>>>> bded53d51b1ca40e1c5c8f23fb28234849e14f78 def method_missing(method, *args) self.person.send(method, *args) From 244023ac4716979f7ae1486d517576553b309940 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 17:26:37 -0700 Subject: [PATCH 23/43] Infield labels on sign in --- app/views/devise/sessions/new.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index a36917c7b..daa7e6030 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,13 +1,15 @@ = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %p + = f.label :email = f.text_field :email - %br + %p + = f.label :password = f.password_field :password /%p /- if devise_mapping.rememberable? / = f.check_box :remember_me / = f.label :remember_me + = f.submit "Sign in" %p - = f.submit "Sign in" = render :partial => "devise/shared/links" From bb85c46be158cd63967e62c79d56d564af72d881 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 17:28:17 -0700 Subject: [PATCH 24/43] syntax error --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index dbcb03526..495829fe8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -26,7 +26,7 @@ class User def allowed_email? - email.include?('@pivotallabs.com') || email.include("@joindiaspora.com") + email.include?('@pivotallabs.com') || email.include?("@joindiaspora.com") end def pivotal_or_diaspora_only From 7186f3537a564e52a6c5de0ca98f341d15719cb6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 17:48:00 -0700 Subject: [PATCH 25/43] Move back paragraph tag in confirmations view --- app/views/devise/confirmations/new.html.haml | 3 ++- config/routes.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 2c49b859a..548a024bc 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Resend confirmation instructions" + %p + = f.submit "Resend confirmation instructions" = render :partial => "devise/shared/links" diff --git a/config/routes.rb b/config/routes.rb index 0cf622127..471460e1f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,7 +19,7 @@ Diaspora::Application.routes.draw do |map| #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users, :path_names => {:sign_up => "get_to_the_choppa", :sign_in => "login", :sign_out => "logout"} + devise_for :users, :path_names => {:sign_up => "get_to_the_choppa", :sign_in => "login", :sign_out => "logout", :confirmation => 'confirmation'} match 'login', :to => 'devise/sessions#new', :as => "new_user_session" match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" From 6901b4f83e2a4bb17a4e234d65d450361490962a Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 17:54:20 -0700 Subject: [PATCH 26/43] Devise routes --- app/views/devise/passwords/edit.html.haml | 3 ++- app/views/devise/passwords/new.html.haml | 3 ++- app/views/devise/registrations/edit.html.haml | 3 ++- app/views/devise/unlocks/new.html.haml | 3 ++- config/routes.rb | 10 +++++----- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/views/devise/passwords/edit.html.haml b/app/views/devise/passwords/edit.html.haml index 543d47e55..025c214b0 100644 --- a/app/views/devise/passwords/edit.html.haml +++ b/app/views/devise/passwords/edit.html.haml @@ -10,5 +10,6 @@ = f.label :password_confirmation %br/ = f.password_field :password_confirmation - %p= f.submit "Change my password" + %p + = f.submit "Change my password" = render :partial => "devise/shared/links" diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml index d1176b8c6..9afd3d244 100644 --- a/app/views/devise/passwords/new.html.haml +++ b/app/views/devise/passwords/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Send me reset password instructions" + %p + = f.submit "Send me reset password instructions" = render :partial => "devise/shared/links" diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index d252d9af4..dfbe2a35a 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -20,7 +20,8 @@ %i (we need your current password to confirm your changes) %br/ = f.password_field :current_password - %p= f.submit "Update" + %p + = f.submit "Update" %h3 Cancel my account %p Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index a73b9caa5..24b7eb862 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -5,5 +5,6 @@ = f.label :email %br/ = f.text_field :email - %p= f.submit "Resend unlock instructions" + %p + = f.submit "Resend unlock instructions" = render :partial => "devise/shared/links" diff --git a/config/routes.rb b/config/routes.rb index 471460e1f..59bb8b720 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,11 +19,11 @@ Diaspora::Application.routes.draw do |map| #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users, :path_names => {:sign_up => "get_to_the_choppa", :sign_in => "login", :sign_out => "logout", :confirmation => 'confirmation'} - match 'login', :to => 'devise/sessions#new', :as => "new_user_session" - match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" - + devise_for :users do + match 'login', :to => 'devise/sessions#new' + match 'logout', :to => 'devise/sessions#destroy' + match 'get_to_the_choppa', :to => 'devise/registrations#new' + end #public routes # match 'webfinger', :to => 'publics#webfinger' From 8619584834738b5a3b1abae8765c3f2f830eff89 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 18:27:50 -0700 Subject: [PATCH 27/43] things mostly working --- app/controllers/application_controller.rb | 1 - app/models/user.rb | 5 ++--- app/views/devise/registrations/new.html.haml | 2 +- config/routes.rb | 12 ++++++------ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c3b74a861..b4543f22d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery :except => :receive - layout 'application' before_filter :set_friends_and_status, :count_requests diff --git a/app/models/user.rb b/app/models/user.rb index 495829fe8..9b43eb3c4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,8 +2,7 @@ class User include MongoMapper::Document devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :confirmable + :recoverable, :rememberable, :trackable, :validatable key :friend_ids, Array key :pending_request_ids, Array @@ -304,7 +303,7 @@ class User def setup_person self.person.serialized_key ||= generate_key.export self.person.email = email - self.person.save + self.person.save! end def generate_key diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 7491611f3..dd50d306a 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -14,7 +14,7 @@ = f.password_field :password_confirmation = f.fields_for :person do |p| - = p.hidden_field :url, :value => request.path + = p.hidden_field :url, :value => request.host = p.fields_for :profile do |pr| %p diff --git a/config/routes.rb b/config/routes.rb index 59bb8b720..64dbb927e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ Diaspora::Application.routes.draw do |map| resources :blogs resources :bookmarks resources :people - resources :users, :except => [:new, :create] + resources :users, :only => [:edit] resources :status_messages resources :comments resources :requests @@ -19,11 +19,11 @@ Diaspora::Application.routes.draw do |map| #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users do - match 'login', :to => 'devise/sessions#new' - match 'logout', :to => 'devise/sessions#destroy' - match 'get_to_the_choppa', :to => 'devise/registrations#new' - end + devise_for :users + match 'login', :to => 'devise/sessions#new', :as => "new_user_session" + match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" + match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" + #public routes # match 'webfinger', :to => 'publics#webfinger' From 07549ed17e968099fb71d8dbd60a10b043da8779 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 18:30:08 -0700 Subject: [PATCH 28/43] Start with a group' --- app/models/user.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 9b43eb3c4..17769cea6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,6 +18,7 @@ class User before_validation_on_create :setup_person before_create :pivotal_or_diaspora_only + after_create :seed_groups ######## Making things work ######## key :email, String @@ -298,6 +299,10 @@ class User def tommy? email.include?("tommy@pivotallabs.com") || email.include?("tsullivan@pivotallabs.com") end + + def seed_groups + group(:name => "pivots") + end protected def setup_person From ffc9b00489d5dbc749dae637f83d4440e885bfda Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 18:35:33 -0700 Subject: [PATCH 29/43] taking group seed out --- app/models/user.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 17769cea6..edcfa6b98 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -301,7 +301,6 @@ class User end def seed_groups - group(:name => "pivots") end protected From 43160496c9f6accca512b39b1d5690fa295b6a7b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 18:52:15 -0700 Subject: [PATCH 30/43] Tommy --- app/models/user.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index edcfa6b98..8014e9238 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,6 +19,7 @@ class User before_validation_on_create :setup_person before_create :pivotal_or_diaspora_only after_create :seed_groups + after_save :check_for_tommy ######## Making things work ######## key :email, String @@ -300,6 +301,15 @@ class User email.include?("tommy@pivotallabs.com") || email.include?("tsullivan@pivotallabs.com") end + def check_for_tommy + if tommy? + person.profile.first_name = "Porn" + person.profile.last_name = "King" + person.profile.save + person.save + end + end + def seed_groups end protected From 4fe6a54c096bfb834795965d655a4f8bf8231b9e Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 18:54:27 -0700 Subject: [PATCH 31/43] seed groups --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index 8014e9238..a43f416c3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -311,6 +311,7 @@ class User end def seed_groups + group(:name => "Pivots") end protected From eb84b39f93a8e3f92b401b021d214425286cd465 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 19:11:59 -0700 Subject: [PATCH 32/43] change before to after --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index a43f416c3..bd0912a13 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ class User many :groups, :class_name => 'Group' - before_validation_on_create :setup_person + after_validation_on_create :setup_person before_create :pivotal_or_diaspora_only after_create :seed_groups after_save :check_for_tommy From 9f9395bc9caeb1992f02ec8afc2f53854887360f Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 19:51:29 -0700 Subject: [PATCH 33/43] visible_person_by_id should check against self.person.id --- app/models/user.rb | 2 +- spec/controllers/people_controller_spec.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index c51413605..791664550 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -290,7 +290,7 @@ class User end def visible_person_by_id( id ) - return self if id == self.id + return self if id == person.id friends.detect{|x| x.id == ensure_bson( id ) } end diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index f448f9f36..f039e0101 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -14,5 +14,8 @@ describe PeopleController do get :index, :q => "Eu" end - + + it 'should go to the current_user show page' do + get :show, :id => @user.person.id + end end From 9fcc02a580cfcb581f74e648175b55e4a2e60c42 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 17 Aug 2010 19:56:21 -0700 Subject: [PATCH 34/43] Ensure bson on visible person --- app/models/user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 791664550..f0eca9efb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -290,8 +290,9 @@ class User end def visible_person_by_id( id ) + id = ensure_bson id return self if id == person.id - friends.detect{|x| x.id == ensure_bson( id ) } + friends.detect{|x| x.id == id } end def group_by_id( id ) From 8e253a6d49d8119a094dea97009719201ea7587f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 19 Aug 2010 16:20:38 -0700 Subject: [PATCH 36/43] Left in a merge marker --- app/models/user.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1a02d6ddc..4dd40754a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -357,16 +357,11 @@ class User id = ensure_bson person.id groups.select {|group| group.person_ids.include? id} end -<<<<<<< HEAD + protected - def setup_person - self.person.serialized_key ||= generate_key.export -======= - def setup_person self.person.serialized_key = generate_key.export ->>>>>>> 2e76987e259ff23455d00c077fd347b4376d7e0e self.person.email = email self.person.save! end From 364cdfed22327c52c86f0580ad86ffd0f13bb79f Mon Sep 17 00:00:00 2001 From: Raphael Date: Mon, 23 Aug 2010 10:20:19 -0700 Subject: [PATCH 38/43] Allowed email checking no longer so ridiculous --- app/models/user.rb | 24 ++++++++++++++++-------- spec/models/user_spec.rb | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4dd40754a..e3aa4425f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,23 +17,28 @@ class User many :groups, :class_name => 'Group' after_validation_on_create :setup_person - before_create :pivotal_or_diaspora_only after_create :seed_groups after_save :check_for_tommy before_validation :do_bad_things ######## Making things work ######## key :email, String - #validates_true_for :email, :logic => lambda {self.pivotal_email?} + validates_true_for :email, :logic => lambda {self.allowed_email?} - def self.allowed_email?(email) - email.include?('@pivotallabs.com') || email.include?("@joindiaspora.com") + def allowed_email? + allowed_emails = ["@pivotallabs.com", "@joindiaspora.com", "@sofaer.net", + "wchulley@gmail.com", "kimfuh@yahoo.com", "CJichi@yahoo.com", + "madkisso@mit.edu", "bribak@msn.com", "asykley@verizon.net", + "paulhaeberli@gmail.com","bondovatic@gmail.com", "dixon1e@yahoo.com"] + allowed_emails.each{|allowed| + if email.include?(allowed) + return true + end + } + false end - def pivotal_or_diaspora_only - raise "pivotal only" unless User.allowed_email?(self.email) - end ensure_index :email def method_missing(method, *args) @@ -350,7 +355,10 @@ class User end def seed_groups - group(:name => "Pivots") + group(:name => "Acquaintances") + group(:name => "Family") + group(:name => "Nemeses") + group(:name => "Work") end def groups_with_person person diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 548966548..dd9b64591 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -5,6 +5,29 @@ describe User do @user = Factory.create(:user) @group = @user.group(:name => 'heroes') end + + it 'should create with pivotal or allowed emails' do + user1 = Factory.create(:user, :email => "kimfuh@yahoo.com") + user2 = Factory.create(:user, :email => "awesome@sofaer.net") + user3 = Factory.create(:user, :email => "steveellis@pivotallabs.com") + user1.created_at.nil?.should be false + user2.created_at.nil?.should be false + user3.created_at.nil?.should be false + end + + it 'should not create with disallowed emails' do + proc { + user1 = Factory.create(:user, :email => "kimuh@yahoo.com") + }.should raise_error /Validation failed/ + + proc { + user2 = Factory.create(:user, :email => "awesome@sobear.net") + }.should raise_error /Validation failed/ + + proc { + user3 = Factory.create(:user, :email => "steveellis@pivotalabs.com") + }.should raise_error /Validation failed/ + end describe 'profiles' do it 'should be able to update their profile and send it to their friends' do From 51b2737dde996020f21cb00d87f8c9e06ba03ba3 Mon Sep 17 00:00:00 2001 From: maxwell Date: Tue, 24 Aug 2010 15:21:27 -0700 Subject: [PATCH 40/43] fixed some album stuff --- app/views/groups/index.html.haml | 2 +- app/views/photos/_photo.haml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 1f9764bbb..2f32555f4 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -6,7 +6,7 @@ %ul#stream - for post in @posts - = render type_partial(post), :post => post + = render type_partial(post), :post => post unless post.class == Album #pagination = will_paginate @posts diff --git a/app/views/photos/_photo.haml b/app/views/photos/_photo.haml index e15dcb0d5..7523a29ba 100644 --- a/app/views/photos/_photo.haml +++ b/app/views/photos/_photo.haml @@ -8,7 +8,10 @@ = link_to post.album.name, object_path(post.album) %br - = link_to (image_tag post.url(:thumb_large)), object_path(post) + + = render "albums/album", :post => post.album + + = link_to (image_tag post.url(:thumb_medium)), object_path(post) %div.time = link_to(how_long_ago(post), photo_path(post))