Merge branch 'friend-refactor' of github.com:diaspora/diaspora_rails into friend-refactor
This commit is contained in:
commit
b9718c079b
5 changed files with 39 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
class UsersController < ApplicationController
|
||||
before_filter :authenticate_user!, :except => [:new, :create]
|
||||
|
||||
before_filter :authenticate_user!
|
||||
def index
|
||||
@users = User.sort(:created_at.desc).all
|
||||
end
|
||||
|
|
@ -27,9 +27,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
@user = User.instantiate(params[:user])
|
||||
|
||||
if @user.save!
|
||||
if @user.created_at && @user.person.created_at
|
||||
flash[:notice] = "Successfully signed up."
|
||||
redirect_to root_path
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
module StatusMessagesHelper
|
||||
|
||||
def my_latest_message
|
||||
unless @latest_status_message.nil?
|
||||
return @latest_status_message.message
|
||||
|
|
@ -7,7 +6,4 @@ module StatusMessagesHelper
|
|||
return "No message to display."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -118,7 +118,11 @@ 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?:\/\//, '')
|
||||
|
|
@ -145,4 +149,8 @@ class User
|
|||
OpenSSL::PKey::RSA::generate 1024
|
||||
end
|
||||
|
||||
def self.generate_key
|
||||
OpenSSL::PKey::RSA::generate 1024
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,15 +3,24 @@
|
|||
= devise_error_messages!
|
||||
%p
|
||||
= f.label :email
|
||||
%br/
|
||||
= f.text_field :email
|
||||
%p
|
||||
= f.label :password
|
||||
%br/
|
||||
= f.password_field :password
|
||||
%p
|
||||
= f.label :password_confirmation
|
||||
%br/
|
||||
= f.password_field :password_confirmation
|
||||
|
||||
= f.fields_for :person do |p|
|
||||
= p.hidden_field :url, :value => "http://google.com/"
|
||||
|
||||
= p.fields_for :profile do |pr|
|
||||
%p
|
||||
= pr.label :first_name
|
||||
= pr.text_field :first_name
|
||||
%p
|
||||
= pr.label :last_name
|
||||
= pr.text_field :last_name
|
||||
|
||||
%p= f.submit "Sign up"
|
||||
= render :partial => "devise/shared/links"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,20 @@ describe User do
|
|||
Person.count.should == n+1
|
||||
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 be able to accept a pending friend request" do
|
||||
friend = Factory.create(:person)
|
||||
|
|
|
|||
Loading…
Reference in a new issue