From a23df47dbc119aa586788e30d7ee50cfdd44877e Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 18 Aug 2010 21:10:42 -0700 Subject: [PATCH] Trying to merge in the pivots changes that we want in master --- app/controllers/application_controller.rb | 1 - app/controllers/users_controller.rb | 14 ------- app/models/user.rb | 20 ++++------ app/views/devise/confirmations/new.html.haml | 3 +- 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/registrations/new.html.haml | 2 +- app/views/devise/sessions/new.html.haml | 6 ++- app/views/devise/unlocks/new.html.haml | 3 +- app/views/groups/index.html.haml | 2 +- config/routes.rb | 8 ++-- config/sprinkle/packages/server.rb | 37 +----------------- config/sprinkle/provision.rb | 39 +------------------ spec/controllers/people_controller_spec.rb | 5 ++- spec/models/user_spec.rb | 16 -------- 16 files changed, 36 insertions(+), 129 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 291246750..f173633c4 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/controllers/users_controller.rb b/app/controllers/users_controller.rb index 69b728755..5d407e724 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,19 +23,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 3b269f135..56f7882d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,8 +16,7 @@ class User many :groups, :class_name => 'Group' - before_validation_on_create :assign_key - before_validation :do_bad_things + after_validation_on_create :setup_person ######## Making things work ######## key :email, String @@ -297,12 +296,6 @@ class User ###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\./, '') @@ -310,10 +303,6 @@ class User terse end - def do_bad_things - self.password_confirmation = self.password - end - def visible_person_by_id( id ) id = ensure_bson id return self.person if id == self.person.id @@ -329,6 +318,13 @@ class User id = ensure_bson person.id groups.select {|group| group.person_ids.include? id} end + + def setup_person + self.person.serialized_key ||= generate_key.export + self.person.email = email + self.person.save! + end + protected def assign_key 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/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/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/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" 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/app/views/groups/index.html.haml b/app/views/groups/index.html.haml index 6d8389727..89ef12f84 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/index.html.haml @@ -1,5 +1,5 @@ %h1 - welcome home, + welcome, = current_user.profile.first_name - @group.nil? ? group_id = nil : group_id = @group.id diff --git a/config/routes.rb b/config/routes.rb index e8d5616f0..b0e12b30b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,10 +15,10 @@ 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"} - 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 + 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 # diff --git a/config/sprinkle/packages/server.rb b/config/sprinkle/packages/server.rb index 99f326c8b..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 @@ -18,35 +17,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 63302b874..e085a2602 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -1,39 +1,13 @@ #!/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 => [:tom, :backer] do +policy :diaspora, :roles => [:tom,:backer] do # requires :clean_dreamhost requires :tools requires :rubygems @@ -43,16 +17,9 @@ policy :diaspora, :roles => [:tom, :backer] do requires :webserver requires :scm requires :vim + requires :nginx_conf 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 +40,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. 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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 146547edb..548966548 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 'profiles' do it 'should be able to update their profile and send it to their friends' do Factory.create(:person) @@ -32,6 +18,4 @@ describe User do @user.profile.image_url.should == "http://clown.com" end end - - end