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
|
class UsersController < ApplicationController
|
||||||
|
before_filter :authenticate_user!, :except => [:new, :create]
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
def index
|
def index
|
||||||
@users = User.sort(:created_at.desc).all
|
@users = User.sort(:created_at.desc).all
|
||||||
end
|
end
|
||||||
|
|
@ -27,9 +27,9 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
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."
|
flash[:notice] = "Successfully signed up."
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
module StatusMessagesHelper
|
module StatusMessagesHelper
|
||||||
|
|
||||||
def my_latest_message
|
def my_latest_message
|
||||||
unless @latest_status_message.nil?
|
unless @latest_status_message.nil?
|
||||||
return @latest_status_message.message
|
return @latest_status_message.message
|
||||||
|
|
@ -7,7 +6,4 @@ module StatusMessagesHelper
|
||||||
return "No message to display."
|
return "No message to display."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,11 @@ class User
|
||||||
|
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
|
def self.instantiate( opts = {} )
|
||||||
|
opts[:person][:email] = opts[:email]
|
||||||
|
opts[:person][:serialized_key] = generate_key
|
||||||
|
User.create( opts)
|
||||||
|
end
|
||||||
|
|
||||||
def terse_url
|
def terse_url
|
||||||
terse= self.url.gsub(/https?:\/\//, '')
|
terse= self.url.gsub(/https?:\/\//, '')
|
||||||
|
|
@ -145,4 +149,8 @@ class User
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.generate_key
|
||||||
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,24 @@
|
||||||
= devise_error_messages!
|
= devise_error_messages!
|
||||||
%p
|
%p
|
||||||
= f.label :email
|
= f.label :email
|
||||||
%br/
|
|
||||||
= f.text_field :email
|
= f.text_field :email
|
||||||
%p
|
%p
|
||||||
= f.label :password
|
= f.label :password
|
||||||
%br/
|
|
||||||
= f.password_field :password
|
= f.password_field :password
|
||||||
%p
|
%p
|
||||||
= f.label :password_confirmation
|
= f.label :password_confirmation
|
||||||
%br/
|
|
||||||
= f.password_field :password_confirmation
|
= 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"
|
%p= f.submit "Sign up"
|
||||||
= render :partial => "devise/shared/links"
|
= render :partial => "devise/shared/links"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,20 @@ describe User do
|
||||||
Person.count.should == n+1
|
Person.count.should == n+1
|
||||||
end
|
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
|
describe 'friend requesting' do
|
||||||
it "should be able to accept a pending friend request" do
|
it "should be able to accept a pending friend request" do
|
||||||
friend = Factory.create(:person)
|
friend = Factory.create(:person)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue