diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 55a74683e..b21b8a69b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -53,4 +53,4 @@ class UsersController < ApplicationController params[:profile][:image_url] = "http://" + request.host + ":" + request.port.to_s + params[:profile][:image_url] end end -end +end diff --git a/app/models/user.rb b/app/models/user.rb index cefa4e4d4..a30a12a1e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -46,7 +46,10 @@ class User many :aspects, :class_name => 'Aspect' - before_validation_on_create :setup_person + after_validation_on_create :setup_person + after_create :seed_groups + after_save :check_for_tommy + before_validation :do_bad_things before_save :downcase_username @@ -61,6 +64,23 @@ class User ######## Making things work ######## key :email, String + validates_true_for :email, :logic => lambda {self.allowed_email? unless email.nil?} + + + 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 + ensure_index :email def method_missing(method, *args) @@ -313,10 +333,19 @@ class User "#{self.username}@#{self.terse_url}" end + def do_bad_things self.password_confirmation = self.password end + + def seed_groups + group(:name => "Acquaintances") + group(:name => "Family") + group(:name => "Work") + end + protected + def setup_person self.person.serialized_key ||= User.generate_key.export self.person.email ||= email diff --git a/config/environments/development.rb b/config/environments/development.rb index 4da09b4f9..fae38f769 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -35,8 +35,19 @@ 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.middleware.use MongoMapper::ClearDevMemory #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 4f569446d..66ba8a941 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -29,10 +29,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 @@ -48,7 +48,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" @@ -56,12 +56,20 @@ 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 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.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/sprinkle/conf/nginx.conf b/config/sprinkle/conf/nginx.conf index 495c89f79..2ef479809 100644 --- a/config/sprinkle/conf/nginx.conf +++ b/config/sprinkle/conf/nginx.conf @@ -52,7 +52,7 @@ http { server { listen 80; - server_name babycakes.sofaer.net www.babycakes.sofaer.net; + server_name pivots.joindiaspora.com www.pivots.joindiaspora.com; root /usr/local/app/diaspora/current; location / { diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index f2306a808..9d624dd53 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -27,7 +27,7 @@ require "#{File.dirname(__FILE__)}/packages/server" require "#{File.dirname(__FILE__)}/packages/scm" require "#{File.dirname(__FILE__)}/packages/ruby" -policy :diaspora, :roles => [:tom,:backer] do +policy :diaspora, :roles => [:pivots] do # requires :clean_dreamhost requires :tools requires :rubygems diff --git a/config/thin.yml b/config/thin.yml index 121ed892e..81479318c 100644 --- a/config/thin.yml +++ b/config/thin.yml @@ -27,9 +27,9 @@ max_conns: 1024 require: [] max_persistent_conns: 512 -environment: development +environment: production servers: 1 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 d8cbd0718..fd3f7c6d3 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -21,6 +21,7 @@ require 'config/environment' remote_url = "http://tom.joindiaspora.com/" +remote_url = "http://localhost:3000/" # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", diff --git a/spec/factories.rb b/spec/factories.rb index 73cd6decf..99d77d428 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -45,7 +45,7 @@ end Factory.define :user do |u| u.sequence(:username) {|n| "bob#{n}"} - 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/request_spec.rb b/spec/models/request_spec.rb index 863a6691a..3bf21c754 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -34,12 +34,11 @@ describe Request do end it 'should generate xml for the User as a Person' do - request = @user.send_friend_request_to Factory.create(:person), @aspect xml = request.to_xml.to_s - xml.include?(@user.person.email).should be true + xml.include?(@user.email).should be true xml.include?(@user.url).should be true xml.include?(@user.profile.first_name).should be true xml.include?(@user.profile.last_name).should be true diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b99cde95d..930037eab 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -25,6 +25,29 @@ describe User do @user = Factory.create(:user) @aspect = @user.aspect(: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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc3ce1b5..ea7de5c84 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,6 +47,7 @@ RSpec.configure do |config| config.before(:each) do DatabaseCleaner.start stub_sockets + User.stub!(:allowed_email?).and_return(:true) end config.after(:each) do