Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
7160e9f85b
16 changed files with 354 additions and 138 deletions
|
|
@ -122,6 +122,7 @@ GEM
|
||||||
selenium-webdriver (>= 0.0.3)
|
selenium-webdriver (>= 0.0.3)
|
||||||
childprocess (0.0.7)
|
childprocess (0.0.7)
|
||||||
ffi (~> 0.6.3)
|
ffi (~> 0.6.3)
|
||||||
|
columnize (0.3.1)
|
||||||
crack (0.1.8)
|
crack (0.1.8)
|
||||||
cucumber (0.9.2)
|
cucumber (0.9.2)
|
||||||
builder (~> 2.1.2)
|
builder (~> 2.1.2)
|
||||||
|
|
@ -162,6 +163,7 @@ GEM
|
||||||
i18n (0.4.1)
|
i18n (0.4.1)
|
||||||
json (1.4.6)
|
json (1.4.6)
|
||||||
json_pure (1.4.6)
|
json_pure (1.4.6)
|
||||||
|
linecache (0.43)
|
||||||
mail (2.2.7)
|
mail (2.2.7)
|
||||||
activesupport (>= 2.3.6)
|
activesupport (>= 2.3.6)
|
||||||
mime-types
|
mime-types
|
||||||
|
|
@ -223,6 +225,11 @@ GEM
|
||||||
rspec-expectations (= 2.0.0)
|
rspec-expectations (= 2.0.0)
|
||||||
rspec-rails (2.0.0)
|
rspec-rails (2.0.0)
|
||||||
rspec (= 2.0.0)
|
rspec (= 2.0.0)
|
||||||
|
ruby-debug (0.10.3)
|
||||||
|
columnize (>= 0.1)
|
||||||
|
ruby-debug-base (~> 0.10.3.0)
|
||||||
|
ruby-debug-base (0.10.3)
|
||||||
|
linecache (>= 0.3)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
selenium-webdriver (0.0.29)
|
selenium-webdriver (0.0.29)
|
||||||
childprocess (>= 0.0.7)
|
childprocess (>= 0.0.7)
|
||||||
|
|
@ -280,6 +287,7 @@ DEPENDENCIES
|
||||||
roxml!
|
roxml!
|
||||||
rspec (>= 2.0.0)
|
rspec (>= 2.0.0)
|
||||||
rspec-rails (>= 2.0.0)
|
rspec-rails (>= 2.0.0)
|
||||||
|
ruby-debug
|
||||||
sprinkle!
|
sprinkle!
|
||||||
thin
|
thin
|
||||||
webmock
|
webmock
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,18 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
class RegistrationsController < Devise::RegistrationsController
|
class RegistrationsController < Devise::RegistrationsController
|
||||||
def new
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
begin
|
begin
|
||||||
user = User.instantiate!(params[:user])
|
user = User.instantiate!(params[:user])
|
||||||
rescue MongoMapper::DocumentNotValid => e
|
rescue MongoMapper::DocumentNotValid => e
|
||||||
user = nil
|
|
||||||
flash[:error] = e.message
|
flash[:error] = e.message
|
||||||
|
redirect_to new_user_registration_path
|
||||||
end
|
end
|
||||||
if user
|
if user.save
|
||||||
flash[:notice] = I18n.t 'registrations.create.success'
|
flash[:notice] = I18n.t 'registrations.create.success'
|
||||||
sign_in_and_redirect(:user, user)
|
sign_in_and_redirect(:user, user)
|
||||||
else
|
else
|
||||||
|
flash[:error] = user.errors.full_messages.join(', ')
|
||||||
redirect_to new_user_registration_path
|
redirect_to new_user_registration_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,14 @@ module StatusMessagesHelper
|
||||||
return I18n.t('status_messages.helper.no_message_to_display')
|
return I18n.t('status_messages.helper.no_message_to_display')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def make_links(message)
|
||||||
|
# If there should be some kind of bb-style markup, email/diaspora highlighting, it could go here.
|
||||||
|
|
||||||
|
# next line is important due to XSS! (h is rail's make_html_safe-function)
|
||||||
|
message = h(message).html_safe
|
||||||
|
message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2');
|
||||||
|
return message.gsub(/(http|ftp):\/\/([^ ]+)/, '<a target="_blank" href="\1://\2">\2</a>');
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -17,47 +17,56 @@ end
|
||||||
|
|
||||||
class User
|
class User
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
plugin MongoMapper::Devise
|
|
||||||
include Diaspora::UserModules
|
include Diaspora::UserModules
|
||||||
include Encryptor::Private
|
include Encryptor::Private
|
||||||
|
|
||||||
|
plugin MongoMapper::Devise
|
||||||
|
|
||||||
QUEUE = MessageHandler.new
|
QUEUE = MessageHandler.new
|
||||||
|
|
||||||
devise :invitable, :database_authenticatable, :registerable,
|
devise :invitable, :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
key :username, :unique => true
|
|
||||||
key :serialized_private_key, String
|
|
||||||
|
|
||||||
key :invites, Integer, :default => 5
|
key :username
|
||||||
key :invitation_token, String
|
key :serialized_private_key, String
|
||||||
key :invitation_sent_at, DateTime
|
key :invites, Integer, :default => 5
|
||||||
key :inviter_ids, Array
|
key :invitation_token, String
|
||||||
key :friend_ids, Array
|
key :invitation_sent_at, DateTime
|
||||||
|
key :inviter_ids, Array
|
||||||
|
key :friend_ids, Array
|
||||||
key :pending_request_ids, Array
|
key :pending_request_ids, Array
|
||||||
key :visible_post_ids, Array
|
key :visible_post_ids, Array
|
||||||
key :visible_person_ids, Array
|
key :visible_person_ids, Array
|
||||||
|
|
||||||
|
before_validation :strip_username, :on => :create
|
||||||
|
validates_presence_of :username
|
||||||
|
validates_uniqueness_of :username, :case_sensitive => false
|
||||||
|
validates_format_of :username, :without => /\s/
|
||||||
|
|
||||||
|
validates_with InvitedUserValidator
|
||||||
|
|
||||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||||
|
|
||||||
many :inviters, :in => :inviter_ids, :class_name => 'User'
|
many :inviters, :in => :inviter_ids, :class_name => 'User'
|
||||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||||
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||||
|
|
||||||
many :aspects, :class_name => 'Aspect'
|
many :aspects, :class_name => 'Aspect'
|
||||||
|
|
||||||
after_create :seed_aspects
|
after_create :seed_aspects
|
||||||
|
|
||||||
before_validation :downcase_username, :on => :create
|
|
||||||
validates_with InvitedUserValidator
|
|
||||||
|
|
||||||
before_destroy :unfriend_everyone, :remove_person
|
before_destroy :unfriend_everyone, :remove_person
|
||||||
|
|
||||||
def self.find_for_authentication(conditions={})
|
def strip_username
|
||||||
|
if username.present?
|
||||||
|
username.strip!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.find_for_authentication(conditions={})
|
||||||
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
|
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
|
||||||
conditions[:email] = conditions.delete(:username)
|
conditions[:email] = conditions.delete(:username)
|
||||||
else
|
|
||||||
conditions[:username].downcase!
|
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
@ -74,12 +83,12 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
######### Aspects ######################
|
######### Aspects ######################
|
||||||
def aspect( opts = {} )
|
def aspect(opts = {})
|
||||||
opts[:user] = self
|
opts[:user] = self
|
||||||
Aspect.create(opts)
|
Aspect.create(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def drop_aspect( aspect )
|
def drop_aspect(aspect)
|
||||||
if aspect.people.size == 0
|
if aspect.people.size == 0
|
||||||
aspect.destroy
|
aspect.destroy
|
||||||
else
|
else
|
||||||
|
|
@ -87,7 +96,7 @@ class User
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_friend( opts = {})
|
def move_friend(opts = {})
|
||||||
return true if opts[:to] == opts[:from]
|
return true if opts[:to] == opts[:from]
|
||||||
friend = Person.first(:_id => opts[:friend_id])
|
friend = Person.first(:_id => opts[:friend_id])
|
||||||
if self.friend_ids.include?(friend.id)
|
if self.friend_ids.include?(friend.id)
|
||||||
|
|
@ -98,7 +107,7 @@ class User
|
||||||
to_aspect.people << friend
|
to_aspect.people << friend
|
||||||
to_aspect.posts << posts_to_move
|
to_aspect.posts << posts_to_move
|
||||||
from_aspect.person_ids.delete(friend.id.to_id)
|
from_aspect.person_ids.delete(friend.id.to_id)
|
||||||
posts_to_move.each{ |x| from_aspect.post_ids.delete(x.id)}
|
posts_to_move.each { |x| from_aspect.post_ids.delete(x.id) }
|
||||||
from_aspect.save
|
from_aspect.save
|
||||||
to_aspect.save
|
to_aspect.save
|
||||||
return true
|
return true
|
||||||
|
|
@ -111,8 +120,8 @@ class User
|
||||||
def post(class_name, options = {})
|
def post(class_name, options = {})
|
||||||
if class_name == :photo
|
if class_name == :photo
|
||||||
raise ArgumentError.new("No album_id given") unless options[:album_id]
|
raise ArgumentError.new("No album_id given") unless options[:album_id]
|
||||||
aspect_ids = aspects_with_post( options[:album_id] )
|
aspect_ids = aspects_with_post(options[:album_id])
|
||||||
aspect_ids.map!{ |aspect| aspect.id }
|
aspect_ids.map! { |aspect| aspect.id }
|
||||||
else
|
else
|
||||||
aspect_ids = options.delete(:to)
|
aspect_ids = options.delete(:to)
|
||||||
end
|
end
|
||||||
|
|
@ -129,7 +138,7 @@ class User
|
||||||
post
|
post
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_post( post, post_hash = {} )
|
def update_post(post, post_hash = {})
|
||||||
if self.owns? post
|
if self.owns? post
|
||||||
post.update_attributes(post_hash)
|
post.update_attributes(post_hash)
|
||||||
end
|
end
|
||||||
|
|
@ -155,7 +164,7 @@ class User
|
||||||
aspect_ids
|
aspect_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_post( class_name, options = {})
|
def build_post(class_name, options = {})
|
||||||
options[:person] = self.person
|
options[:person] = self.person
|
||||||
model_class = class_name.to_s.camelize.constantize
|
model_class = class_name.to_s.camelize.constantize
|
||||||
post = model_class.instantiate(options)
|
post = model_class.instantiate(options)
|
||||||
|
|
@ -165,18 +174,18 @@ class User
|
||||||
post
|
post
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to_aspects( post, aspect_ids )
|
def push_to_aspects(post, aspect_ids)
|
||||||
if aspect_ids == :all || aspect_ids == "all"
|
if aspect_ids == :all || aspect_ids == "all"
|
||||||
aspects = self.aspects
|
aspects = self.aspects
|
||||||
elsif aspect_ids.is_a?(Array) && aspect_ids.first.class == Aspect
|
elsif aspect_ids.is_a?(Array) && aspect_ids.first.class == Aspect
|
||||||
aspects = aspect_ids
|
aspects = aspect_ids
|
||||||
else
|
else
|
||||||
aspects = self.aspects.find_all_by_id( aspect_ids )
|
aspects = self.aspects.find_all_by_id(aspect_ids)
|
||||||
end
|
end
|
||||||
#send to the aspects
|
#send to the aspects
|
||||||
target_people = []
|
target_people = []
|
||||||
|
|
||||||
aspects.each{ |aspect|
|
aspects.each { |aspect|
|
||||||
aspect.posts << post
|
aspect.posts << post
|
||||||
aspect.save
|
aspect.save
|
||||||
target_people = target_people | aspect.people
|
target_people = target_people | aspect.people
|
||||||
|
|
@ -189,15 +198,15 @@ class User
|
||||||
|
|
||||||
def push_to_people(post, people)
|
def push_to_people(post, people)
|
||||||
salmon = salmon(post)
|
salmon = salmon(post)
|
||||||
people.each{|person|
|
people.each { |person|
|
||||||
xml = salmon.xml_for person
|
xml = salmon.xml_for person
|
||||||
push_to_person( person, xml)
|
push_to_person(person, xml)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to_person( person, xml )
|
def push_to_person(person, xml)
|
||||||
Rails.logger.debug("#{self.real_name} is adding xml to message queue to #{person.receive_url}")
|
Rails.logger.debug("#{self.real_name} is adding xml to message queue to #{person.receive_url}")
|
||||||
QUEUE.add_post_request( person.receive_url, xml )
|
QUEUE.add_post_request(person.receive_url, xml)
|
||||||
QUEUE.process
|
QUEUE.process
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -206,7 +215,7 @@ class User
|
||||||
QUEUE.add_hub_notification(APP_CONFIG[:pubsub_server], self.public_url)
|
QUEUE.add_hub_notification(APP_CONFIG[:pubsub_server], self.public_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def salmon( post )
|
def salmon(post)
|
||||||
created_salmon = Salmon::SalmonSlap.create(self, post.to_diaspora_xml)
|
created_salmon = Salmon::SalmonSlap.create(self, post.to_diaspora_xml)
|
||||||
created_salmon
|
created_salmon
|
||||||
end
|
end
|
||||||
|
|
@ -221,7 +230,7 @@ class User
|
||||||
comment
|
comment
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_comment( text, options = {})
|
def build_comment(text, options = {})
|
||||||
raise "must comment on something!" unless options[:on]
|
raise "must comment on something!" unless options[:on]
|
||||||
comment = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on])
|
comment = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on])
|
||||||
comment.creator_signature = comment.sign_with_key(encryption_key)
|
comment.creator_signature = comment.sign_with_key(encryption_key)
|
||||||
|
|
@ -233,7 +242,7 @@ class User
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dispatch_comment( comment )
|
def dispatch_comment(comment)
|
||||||
if owns? comment.post
|
if owns? comment.post
|
||||||
comment.post_creator_signature = comment.sign_with_key(encryption_key)
|
comment.post_creator_signature = comment.sign_with_key(encryption_key)
|
||||||
comment.save
|
comment.save
|
||||||
|
|
@ -245,9 +254,9 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
######### Posts and Such ###############
|
######### Posts and Such ###############
|
||||||
def retract( post )
|
def retract(post)
|
||||||
aspect_ids = aspects_with_post( post.id )
|
aspect_ids = aspects_with_post(post.id)
|
||||||
aspect_ids.map!{|aspect| aspect.id.to_s}
|
aspect_ids.map! { |aspect| aspect.id.to_s }
|
||||||
|
|
||||||
post.unsocket_from_uid(self.id, :aspect_ids => aspect_ids) if post.respond_to? :unsocket_from_uid
|
post.unsocket_from_uid(self.id, :aspect_ids => aspect_ids) if post.respond_to? :unsocket_from_uid
|
||||||
retraction = Retraction.for(post)
|
retraction = Retraction.for(post)
|
||||||
|
|
@ -266,7 +275,7 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
###Invitations############
|
###Invitations############
|
||||||
def invite_user( opts = {} )
|
def invite_user(opts = {})
|
||||||
if self.invites > 0
|
if self.invites > 0
|
||||||
|
|
||||||
aspect_id = opts.delete(:aspect_id)
|
aspect_id = opts.delete(:aspect_id)
|
||||||
|
|
@ -276,9 +285,9 @@ class User
|
||||||
raise "Must invite to your aspect"
|
raise "Must invite to your aspect"
|
||||||
end
|
end
|
||||||
request = Request.instantiate(
|
request = Request.instantiate(
|
||||||
:to => "http://local_request.example.com",
|
:to => "http://local_request.example.com",
|
||||||
:from => self.person,
|
:from => self.person,
|
||||||
:into => aspect_id
|
:into => aspect_id
|
||||||
)
|
)
|
||||||
|
|
||||||
invited_user = User.invite!(:email => opts[:email], :request => request, :inviter => self)
|
invited_user = User.invite!(:email => opts[:email], :request => request, :inviter => self)
|
||||||
|
|
@ -316,7 +325,7 @@ class User
|
||||||
invitable
|
invitable
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_invitation!( opts = {} )
|
def accept_invitation!(opts = {})
|
||||||
if self.invited?
|
if self.invited?
|
||||||
self.username = opts[:username]
|
self.username = opts[:username]
|
||||||
self.password = opts[:password]
|
self.password = opts[:password]
|
||||||
|
|
@ -338,7 +347,7 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def self.instantiate!( opts = {} )
|
def self.instantiate!(opts = {})
|
||||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
|
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
|
||||||
opts[:person][:url] = APP_CONFIG[:pod_url]
|
opts[:person][:url] = APP_CONFIG[:pod_url]
|
||||||
|
|
||||||
|
|
@ -356,17 +365,13 @@ class User
|
||||||
"#{self.username}@#{APP_CONFIG[:terse_pod_url]}"
|
"#{self.username}@#{APP_CONFIG[:terse_pod_url]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def downcase_username
|
|
||||||
username.downcase! if username
|
|
||||||
end
|
|
||||||
|
|
||||||
def as_json(opts={})
|
def as_json(opts={})
|
||||||
{
|
{
|
||||||
:user => {
|
:user => {
|
||||||
:posts => self.raw_visible_posts.each{|post| post.as_json},
|
:posts => self.raw_visible_posts.each { |post| post.as_json },
|
||||||
:friends => self.friends.each {|friend| friend.as_json},
|
:friends => self.friends.each { |friend| friend.as_json },
|
||||||
:aspects => self.aspects.each {|aspect| aspect.as_json},
|
:aspects => self.aspects.each { |aspect| aspect.as_json },
|
||||||
:pending_requests => self.pending_requests.each{|request| request.as_json},
|
:pending_requests => self.pending_requests.each { |request| request.as_json },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
@ -377,9 +382,9 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
def encryption_key
|
def encryption_key
|
||||||
OpenSSL::PKey::RSA.new( serialized_private_key )
|
OpenSSL::PKey::RSA.new(serialized_private_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def remove_person
|
def remove_person
|
||||||
|
|
@ -387,11 +392,11 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
def unfriend_everyone
|
def unfriend_everyone
|
||||||
friends.each{ |friend|
|
friends.each { |friend|
|
||||||
if friend.owner?
|
if friend.owner?
|
||||||
friend.owner.unfriended_by self.person
|
friend.owner.unfriended_by self.person
|
||||||
else
|
else
|
||||||
self.unfriend friend
|
self.unfriend friend
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
= render "shared/reshare", :post => post, :current_user => current_user
|
= render "shared/reshare", :post => post, :current_user => current_user
|
||||||
= link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
= link_to t('.delete'), status_message_path(post), :confirm => t('.are_you_sure'), :method => :delete, :remote => true, :class => "delete"
|
||||||
|
|
||||||
= post.message
|
= make_links(post.message)
|
||||||
|
|
||||||
.info
|
.info
|
||||||
%span.time= link_to(how_long_ago(post), object_path(post))
|
%span.time= link_to(how_long_ago(post), object_path(post))
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,15 @@
|
||||||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
en:
|
en:
|
||||||
|
activemodel:
|
||||||
|
errors:
|
||||||
|
models:
|
||||||
|
user:
|
||||||
|
attributes:
|
||||||
|
username:
|
||||||
|
taken: "is already taken"
|
||||||
|
email:
|
||||||
|
taken: "is already taken"
|
||||||
hello: "Hello world"
|
hello: "Hello world"
|
||||||
application:
|
application:
|
||||||
helper:
|
helper:
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
## Diaspora RPM tools
|
## Diaspora RPM tools
|
||||||
|
|
||||||
NOTE: This does not work ATM, see discussions on Gemfile.lock in
|
NOTE: This does not work ATM, see http://bugs.joindiaspora.com/issues/372
|
||||||
attached to a commit 12/10 (yea, I know, you calll it 10/12, but you
|
|
||||||
are wrong ;)
|
|
||||||
|
|
||||||
Creates diaspora source tarballs and RPM packages
|
Creates diaspora source tarballs and RPM packages
|
||||||
|
|
||||||
|
|
@ -89,6 +87,19 @@ The source tarball is as retrieved from diaspora with following differences:
|
||||||
- The file .bundle/config is patched. Remove before doing
|
- The file .bundle/config is patched. Remove before doing
|
||||||
*bundle install*
|
*bundle install*
|
||||||
|
|
||||||
|
./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The
|
||||||
|
root cause is a bad Gemfile in the git repo. Possible fixes includes
|
||||||
|
using a older version known to work:
|
||||||
|
|
||||||
|
% ./make-dist.sh -c c818885b6 bundle
|
||||||
|
% ./make-dist.sh -c c818885b6 source
|
||||||
|
|
||||||
|
or forcing a complete update of Gemfile.lock using 'bundle update' (a
|
||||||
|
potential problematic operation):
|
||||||
|
|
||||||
|
% ./make-dist.sh -f bundle
|
||||||
|
|
||||||
|
|
||||||
Routines uses last available version from master branch at github. The
|
Routines uses last available version from master branch at github. The
|
||||||
version contains a time stamp and an abbreviated git commit id.
|
version contains a time stamp and an abbreviated git commit id.
|
||||||
Using -c, a specific commit can be used for source build.
|
Using -c, a specific commit can be used for source build.
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ pushd bundle/ruby/1.8/
|
||||||
chmod 755 gems/thin-1.2.7/example/async_tailer.ru
|
chmod 755 gems/thin-1.2.7/example/async_tailer.ru
|
||||||
chmod 644 gems/i18n-0.4.1/MIT-LICENSE
|
chmod 644 gems/i18n-0.4.1/MIT-LICENSE
|
||||||
chmod 755 gems/abstract-1.0.0/abstract.gemspec
|
chmod 755 gems/abstract-1.0.0/abstract.gemspec
|
||||||
chmod 644 gems/mini_magick-2.1/MIT-LICENSE
|
chmod 644 gems/mini_magick-2.1/MIT-LICENSE || :
|
||||||
chmod 755 gems/thin-1.2.7/lib/thin/controllers/service.sh.erb
|
chmod 755 gems/thin-1.2.7/lib/thin/controllers/service.sh.erb
|
||||||
chmod 644 gems/treetop-1.4.8/spec/compiler/test_grammar.tt
|
chmod 644 gems/treetop-1.4.8/spec/compiler/test_grammar.tt
|
||||||
popd
|
popd
|
||||||
|
|
@ -201,8 +201,8 @@ pushd bundle/ruby/1.8/gems/selenium-webdriver-0.0.28/lib/selenium/webdriver/
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor
|
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/
|
||||||
cp -ar bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor
|
cp -ar bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/
|
||||||
|
|
||||||
find %{buildroot}/%{_libdir}/diaspora-bundle \
|
find %{buildroot}/%{_libdir}/diaspora-bundle \
|
||||||
-type d -fprintf dirs '%%%dir "%%p"\n'
|
-type d -fprintf dirs '%%%dir "%%p"\n'
|
||||||
|
|
@ -220,7 +220,7 @@ cat files >> dirs && cp dirs files
|
||||||
|
|
||||||
%files -f files
|
%files -f files
|
||||||
%defattr(-, diaspora, diaspora, 0755)
|
%defattr(-, diaspora, diaspora, 0755)
|
||||||
%doc COPYRIGHT Gemfile AUTHORS GNU-AGPL-3.0
|
%doc COPYRIGHT Gemfile Gemfile.lock AUTHORS GNU-AGPL-3.0
|
||||||
|
|
||||||
%files -f dev-files devel
|
%files -f dev-files devel
|
||||||
%defattr(-, root, root, 0644)
|
%defattr(-, root, root, 0644)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
|
# Turn off the brp-python-bytecompile script
|
||||||
|
%global __os_install_post %(echo '%{__os_install_post}' | \
|
||||||
|
sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
%define git_release 1010092232_b313272
|
|
||||||
|
%define git_release HEAD
|
||||||
|
|
||||||
Summary: A social network server
|
Summary: A social network server
|
||||||
Name: diaspora
|
Name: diaspora
|
||||||
|
|
@ -13,19 +17,30 @@ Source: %{name}-%{version}-%{git_release}.tar.gz
|
||||||
Source1: diaspora-wsd
|
Source1: diaspora-wsd
|
||||||
Source2: diaspora-setup
|
Source2: diaspora-setup
|
||||||
Source3: diaspora.logconf
|
Source3: diaspora.logconf
|
||||||
Source4: make_rel_symlink.py
|
Source4: make_rel_symlink.py
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
BuildRoot: %{_rmpdir}/not-used-in-fedora/
|
BuildRoot: %{_rmpdir}/not-used-in-fedora/
|
||||||
|
|
||||||
Requires: mongodb-server
|
Requires: mongodb-server
|
||||||
Requires: ruby(abi) = 1.8
|
Requires: ruby(abi) = 1.8
|
||||||
Requires: diaspora-bundle = 0.0-1.1010081636_d1a4ee0.fc13
|
Requires: diaspora-bundle = %{version}
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A privacy aware, personally controlled, do-it-all and
|
A privacy aware, personally controlled, do-it-all and
|
||||||
open source social network server.
|
open source social network server.
|
||||||
|
|
||||||
|
%package wsd
|
||||||
|
Summary: Sys V init script for diaspora websocket daemon
|
||||||
|
Group: Applications/Communications
|
||||||
|
Requires: %{name} = %{version}
|
||||||
|
|
||||||
|
%description wsd
|
||||||
|
Tools to use the diaspora websocket daemon as a service e. g., when
|
||||||
|
using papche passenger or system-wide installed thin server to run
|
||||||
|
diaspora.
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}-%{git_release}
|
%setup -q -n %{name}-%{version}-%{git_release}
|
||||||
|
|
||||||
|
|
@ -34,12 +49,13 @@ find . -perm /u+x -type f -exec \
|
||||||
|
|
||||||
%build
|
%build
|
||||||
rm -rf master/vendor/bundle
|
rm -rf master/vendor/bundle
|
||||||
|
mkdir master/tmp || :
|
||||||
|
|
||||||
%install
|
%install
|
||||||
rm -fr $RPM_BUILD_ROOT
|
rm -fr $RPM_BUILD_ROOT
|
||||||
|
|
||||||
sed -i \
|
sed -i \
|
||||||
'/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/master/vendor/bundle|' \
|
'/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/bundle|' \
|
||||||
master/.bundle/config
|
master/.bundle/config
|
||||||
|
|
||||||
cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS .
|
cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS .
|
||||||
|
|
@ -55,6 +71,9 @@ cp %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
||||||
cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
||||||
|
cp -ar master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master
|
||||||
|
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads
|
||||||
|
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/tmp
|
||||||
cp %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
cp %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/diaspora
|
||||||
|
|
||||||
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora
|
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora
|
||||||
|
|
@ -79,11 +98,10 @@ sed -i -e '\|.*/master/config.ru"$|d' \
|
||||||
files
|
files
|
||||||
|
|
||||||
|
|
||||||
%post
|
%post wsd
|
||||||
/sbin/chkconfig --add diaspora-wsd
|
/sbin/chkconfig --add diaspora-wsd || :
|
||||||
|
|
||||||
|
%preun wsd
|
||||||
%preun
|
|
||||||
if [ $1 -eq 0 ] ; then
|
if [ $1 -eq 0 ] ; then
|
||||||
service diaspora-wsd stop &>/dev/null || :
|
service diaspora-wsd stop &>/dev/null || :
|
||||||
/sbin/chkconfig --del diaspora-wsd
|
/sbin/chkconfig --del diaspora-wsd
|
||||||
|
|
@ -102,15 +120,19 @@ rm -fr $RPM_BUILD_ROOT
|
||||||
%attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora
|
%attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora
|
||||||
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads
|
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads
|
||||||
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp
|
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp
|
||||||
|
|
||||||
%{_datadir}/diaspora/master/tmp
|
%{_datadir}/diaspora/master/tmp
|
||||||
%{_datadir}/diaspora/master/public/uploads
|
%{_datadir}/diaspora/master/public/uploads
|
||||||
%{_datadir}/diaspora/master/log
|
%{_datadir}/diaspora/master/log
|
||||||
|
|
||||||
%config(noreplace) %{_sysconfdir}/logrotate.d/diaspora
|
%config(noreplace) %{_sysconfdir}/logrotate.d/diaspora
|
||||||
|
|
||||||
|
%files wsd
|
||||||
|
%defattr(-, root, root, 0755)
|
||||||
%{_sysconfdir}/init.d/diaspora-wsd
|
%{_sysconfdir}/init.d/diaspora-wsd
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1010092232_b313272.fc13
|
* Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1009280542_859ec2d
|
||||||
|
|
||||||
- Initial attempt to create a spec fi+le
|
- Initial attempt to create a spec fi+le
|
||||||
|
|
||||||
# rubygem-term-ansicolor in repo (1.0.5)
|
# rubygem-term-ansicolor in repo (1.0.5)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@ function checkout()
|
||||||
git clone --quiet $GIT_REPO;
|
git clone --quiet $GIT_REPO;
|
||||||
(
|
(
|
||||||
cd diaspora;
|
cd diaspora;
|
||||||
git remote add upstream $GIT_REPO
|
git remote add upstream \
|
||||||
|
git://github.com/diaspora/diaspora.git
|
||||||
for p in ../../*.patch; do
|
for p in ../../*.patch; do
|
||||||
git apply --whitespace=fix $p > /dev/null
|
git apply --whitespace=fix $p > /dev/null
|
||||||
done &> /dev/null || :
|
done &> /dev/null || :
|
||||||
|
|
@ -166,9 +167,6 @@ function make_src
|
||||||
find $PWD -name .git\* | xargs rm -rf
|
find $PWD -name .git\* | xargs rm -rf
|
||||||
rm -rf .bundle
|
rm -rf .bundle
|
||||||
/usr/bin/patch -p1 -s <../../../add-bundle.diff
|
/usr/bin/patch -p1 -s <../../../add-bundle.diff
|
||||||
for p in ../../../*.patch; do
|
|
||||||
/usr/bin/patch -p1 -s < $p
|
|
||||||
done &> /dev/null || :
|
|
||||||
)
|
)
|
||||||
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \
|
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \
|
||||||
rm -rf ${RELEASE_DIR}
|
rm -rf ${RELEASE_DIR}
|
||||||
|
|
@ -183,6 +181,7 @@ function make_bundle()
|
||||||
# Usage: make_bundle [ commit, defaults to HEAD]
|
# Usage: make_bundle [ commit, defaults to HEAD]
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
|
set -x
|
||||||
checkout ${1:-'HEAD'} >/dev/null
|
checkout ${1:-'HEAD'} >/dev/null
|
||||||
bundle_id=$( git_id dist/diaspora/Gemfile)
|
bundle_id=$( git_id dist/diaspora/Gemfile)
|
||||||
bundle_name="diaspora-bundle-$VERSION-$bundle_id"
|
bundle_name="diaspora-bundle-$VERSION-$bundle_id"
|
||||||
|
|
@ -192,11 +191,14 @@ function make_bundle()
|
||||||
rm -rf $bundle_name
|
rm -rf $bundle_name
|
||||||
mkdir -p $bundle_name/bundle
|
mkdir -p $bundle_name/bundle
|
||||||
pushd diaspora > /dev/null
|
pushd diaspora > /dev/null
|
||||||
|
if [ "$BUNDLE_FIX" = 'yes' ]; then
|
||||||
|
bundle update
|
||||||
|
fi
|
||||||
bundle install --deployment \
|
bundle install --deployment \
|
||||||
--path="../$bundle_name/bundle" \
|
--path="../$bundle_name/bundle" \
|
||||||
--without=test rdoc
|
--without=test rdoc
|
||||||
|
|
||||||
cp -ar AUTHORS Gemfile GNU-AGPL-3.0 COPYRIGHT \
|
cp -ar AUTHORS Gemfile Gemfile.lock GNU-AGPL-3.0 COPYRIGHT \
|
||||||
"../$bundle_name"
|
"../$bundle_name"
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
tar czf $bundle_name.tar.gz $bundle_name
|
tar czf $bundle_name.tar.gz $bundle_name
|
||||||
|
|
@ -204,8 +206,7 @@ function make_bundle()
|
||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
echo "Repo: $GIT_REPO"
|
echo "Bundle: dist/$bundle_name.tar.gz"
|
||||||
echo "Bundle: dist/$bundle_name.tar.gz"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -269,6 +270,8 @@ function usage()
|
||||||
-r release Mark with specified release, defaults to 1.
|
-r release Mark with specified release, defaults to 1.
|
||||||
-u uri Git repository URI, defaults to
|
-u uri Git repository URI, defaults to
|
||||||
$GIT_REPO.
|
$GIT_REPO.
|
||||||
|
-f For bundle, fix dependencies by running 'bundle update'
|
||||||
|
before 'bundle install'
|
||||||
|
|
||||||
source Build a diaspora application tarball.
|
source Build a diaspora application tarball.
|
||||||
bundle Build a bundler(1) bundle for diaspora.
|
bundle Build a bundler(1) bundle for diaspora.
|
||||||
|
|
@ -280,8 +283,10 @@ function usage()
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
commit='HEAD'
|
commit='HEAD'
|
||||||
while getopts ":r:c:u:h" opt
|
BUNDLE_FIX='no'
|
||||||
|
while getopts ":r:c:fh" opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
u) GIT_REPO="$OPTARG"
|
u) GIT_REPO="$OPTARG"
|
||||||
|
|
@ -290,6 +295,8 @@ do
|
||||||
;;
|
;;
|
||||||
r) RELEASE="$OPTARG:"
|
r) RELEASE="$OPTARG:"
|
||||||
;;
|
;;
|
||||||
|
f) BUNDLE_FIX='yes'
|
||||||
|
;;
|
||||||
h) usage
|
h) usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
@ -300,7 +307,7 @@ do
|
||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
typeset -r GIT_REPO RELEASE
|
typeset -r GIT_REPO RELEASE BUNDLE_FIX
|
||||||
export LANG=C
|
export LANG=C
|
||||||
|
|
||||||
test $# -gt 1 -o $# -eq 0 && {
|
test $# -gt 1 -o $# -eq 0 && {
|
||||||
|
|
@ -310,7 +317,7 @@ test $# -gt 1 -o $# -eq 0 && {
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|
||||||
"bundle") make_bundle $commit
|
"bundle") make_bundle $commit $BUNDLE_FIX
|
||||||
;;
|
;;
|
||||||
'source') make_src $commit
|
'source') make_src $commit
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
## Package-oriented install for ubuntu.
|
## Package-oriented install for ubuntu.
|
||||||
|
|
||||||
NOTE: This does not work ATM, see discussions on Gemfile.lock in
|
NOTE: This does not work ATM, see http://bugs.joindiaspora.com/issues/372
|
||||||
attached to a commit 12/10 (yea, I know, you calll it 10/12, but you
|
|
||||||
are wrong ;)
|
|
||||||
|
|
||||||
|
|
||||||
Here are somediaspora-installdiaspora-install scripts to install diaspora on Ubuntu. They are designed to
|
Here are somediaspora-installdiaspora-install scripts to install diaspora on Ubuntu. They are designed to
|
||||||
work as a first step towards packaging, but should be usable as is.
|
work as a first step towards packaging, but should be usable as is.
|
||||||
|
|
@ -52,6 +49,16 @@ OK to use. If it's not, it will build a new.
|
||||||
|
|
||||||
### Notes
|
### Notes
|
||||||
|
|
||||||
|
./make-dist.sh bundle|source occasionally fails on bad Gemfile.lock. The
|
||||||
|
root cause is a bad Gemfile.lock in the git repo. Possible fixes includes
|
||||||
|
using a older version known to work:
|
||||||
|
% ./make-dist.sh -c c818885b6 bundle
|
||||||
|
% ./make-dist.sh -c c818885b6 source
|
||||||
|
|
||||||
|
or forcing a complete update of Gemfile.lock using 'bundle update' (a
|
||||||
|
potential problematic operation):
|
||||||
|
% ./make-dist.sh -f bundle
|
||||||
|
|
||||||
The application lives in /usr/share/diaspora/master. All writable areas
|
The application lives in /usr/share/diaspora/master. All writable areas
|
||||||
(log, uploads, tmp) are links to /var/lib/diaspora. The config file lives
|
(log, uploads, tmp) are links to /var/lib/diaspora. The config file lives
|
||||||
in /etc/diaspora. All files in /usr/share are read-only, owned by root.
|
in /etc/diaspora. All files in /usr/share are read-only, owned by root.
|
||||||
|
|
@ -59,7 +66,7 @@ in /etc/diaspora. All files in /usr/share are read-only, owned by root.
|
||||||
The bundle lives in /usr/lib/diaspora-bundle, readonly, owned by root.
|
The bundle lives in /usr/lib/diaspora-bundle, readonly, owned by root.
|
||||||
Application finds it through the patched .bundle/config in root dir.
|
Application finds it through the patched .bundle/config in root dir.
|
||||||
|
|
||||||
Once diaspora ins installed ,makedist.sh et. al. are available in
|
Once diaspora is installed, makedist.sh et. al. are available in
|
||||||
/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout
|
/usr/share/diaspora/master/pkg/ubuntu, so there's no need to checkout
|
||||||
the stuff using git in this case.
|
the stuff using git in this case.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
require File.join(Rails.root, "spec", "spec_helper")
|
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
||||||
|
|
||||||
describe DevUtilitiesController do
|
describe DevUtilitiesController do
|
||||||
render_views
|
render_views
|
||||||
|
|
|
||||||
56
spec/controllers/registrations_controller_spec.rb
Normal file
56
spec/controllers/registrations_controller_spec.rb
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
||||||
|
|
||||||
|
describe RegistrationsController do
|
||||||
|
include Devise::TestHelpers
|
||||||
|
|
||||||
|
render_views
|
||||||
|
|
||||||
|
before do
|
||||||
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||||
|
@valid_params = {"user" => {"username" => "jdoe",
|
||||||
|
"email" => "jdoe@example.com",
|
||||||
|
"password" => "password",
|
||||||
|
"password_confirmation" => "password",
|
||||||
|
"person" => {
|
||||||
|
"profile" => {
|
||||||
|
"first_name" => "John",
|
||||||
|
"last_name" => "Doe"}}}}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#create" do
|
||||||
|
context "with valid parameters" do
|
||||||
|
it "creates a user" do
|
||||||
|
lambda { get :create, @valid_params }.should change(User, :count).by(1)
|
||||||
|
end
|
||||||
|
it "sets the flash" do
|
||||||
|
get :create, @valid_params
|
||||||
|
flash[:notice].should_not be_empty
|
||||||
|
end
|
||||||
|
it "redirects to the root path" do
|
||||||
|
get :create, @valid_params
|
||||||
|
response.should redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context "with invalid parameters" do
|
||||||
|
before do
|
||||||
|
@valid_params["user"].delete("username")
|
||||||
|
@invalid_params = @valid_params
|
||||||
|
end
|
||||||
|
it "does not create a user" do
|
||||||
|
lambda { get :create, @invalid_params }.should_not change(User, :count)
|
||||||
|
end
|
||||||
|
it "sets the flash error" do
|
||||||
|
get :create, @invalid_params
|
||||||
|
flash[:error].should_not be_blank
|
||||||
|
end
|
||||||
|
it "goes back to the form" do
|
||||||
|
get :create, @invalid_params
|
||||||
|
response.should redirect_to new_user_registration_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -32,7 +32,7 @@ Factory.define :user do |u|
|
||||||
u.password_confirmation "bluepin7"
|
u.password_confirmation "bluepin7"
|
||||||
u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export
|
u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export
|
||||||
u.after_build do |user|
|
u.after_build do |user|
|
||||||
user.person = Factory(:person, :owner_id => user._id,
|
user.person = Factory.build(:person, :owner_id => user._id,
|
||||||
:serialized_public_key => user.encryption_key.public_key.export,
|
:serialized_public_key => user.encryption_key.public_key.export,
|
||||||
:diaspora_handle => "#{user.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
|
:diaspora_handle => "#{user.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
43
spec/helpers/status_messages_helper_spec.rb
Normal file
43
spec/helpers/status_messages_helper_spec.rb
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe StatusMessagesHelper do
|
||||||
|
it "should not allow basic XSS/HTML" do
|
||||||
|
make_links("<script>alert('XSS is evil')</script>").should == "<script>alert('XSS is evil')</script>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should recognize basic http links (1/3)" do
|
||||||
|
proto="http"
|
||||||
|
url="bugs.joindiaspora.com/issues/332"
|
||||||
|
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should recognize basic http links (2/3)" do
|
||||||
|
proto="http"
|
||||||
|
url="www.youtube.com/watch?v=b15yaPYNDRU"
|
||||||
|
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should recognize basic http links (3/3)" do
|
||||||
|
proto="http"
|
||||||
|
url="127.0.0.1:3000/users/sign_in"
|
||||||
|
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should recognize basic ftp links" do
|
||||||
|
proto="ftp"
|
||||||
|
url="ftp.uni-kl.de/CCC/26C3/mp4/26c3-3540-en-a_hackers_utopia.mp4"
|
||||||
|
# I did not watch that one, but the title sounds nice :P
|
||||||
|
make_links(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should recognize www links" do
|
||||||
|
url="www.joindiaspora.com"
|
||||||
|
make_links(url).should == "<a target=\"_blank\" href=\"http://"+url+"\">"+url+"</a>"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
@ -5,36 +5,77 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
let(:user) { Factory(:user) }
|
let(:user) { Factory(:user) }
|
||||||
let(:aspect) { user.aspect(:name => 'heroes') }
|
let(:aspect) { user.aspect(:name => 'heroes') }
|
||||||
let(:user2) { Factory(:user) }
|
let(:user2) { Factory(:user) }
|
||||||
let(:aspect2) { user2.aspect(:name => 'stuff') }
|
let(:aspect2) { user2.aspect(:name => 'stuff') }
|
||||||
let(:user3) { Factory(:user) }
|
let(:user3) { Factory(:user) }
|
||||||
let(:aspect3) { user3.aspect(:name => 'stuff') }
|
let(:aspect3) { user3.aspect(:name => 'stuff') }
|
||||||
|
|
||||||
describe "validations" do
|
describe "validation" do
|
||||||
it "downcases the username" do
|
describe "of passwords" do
|
||||||
user = Factory.build(:user, :username => "ALLUPPERCASE")
|
it "fails if password doesn't match confirmation" do
|
||||||
user.valid?
|
user = Factory.build(:user, :password => "password", :password_confirmation => "nope")
|
||||||
user.username.should == "alluppercase"
|
user.should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
user = Factory.build(:user, :username => "someUPPERCASE")
|
it "succeeds if password matches confirmation" do
|
||||||
user.valid?
|
user = Factory.build(:user, :password => "password", :password_confirmation => "password")
|
||||||
user.username.should == "someuppercase"
|
user.should be_valid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "confirms the password" do
|
describe "of username" do
|
||||||
pending "I cannot figure out why this doesn't work. --Raphael"
|
it "requires presence" do
|
||||||
user = User.instantiate!(
|
user = Factory.build(:user, :username => nil)
|
||||||
:email => "tom@tom.joindiaspora.com",
|
user.should_not be_valid
|
||||||
:username => "tom",
|
end
|
||||||
:password => "evankorth",
|
|
||||||
:password_confirmation => "potatoes",
|
it "requires uniqueness" do
|
||||||
:person => Person.new(
|
duplicate_user = Factory.build(:user, :username => user.username)
|
||||||
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
duplicate_user.should_not be_valid
|
||||||
)
|
end
|
||||||
user.created_at.should be_nil
|
|
||||||
user.valid?.should be_false
|
it "keeps the original case" do
|
||||||
|
user = Factory.build(:user, :username => "WeIrDcAsE")
|
||||||
|
user.should be_valid
|
||||||
|
user.username.should == "WeIrDcAsE"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if the requested username is only different in case from an existing username" do
|
||||||
|
duplicate_user = Factory.build(:user, :username => user.username.upcase)
|
||||||
|
duplicate_user.should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "strips leading and trailing whitespace" do
|
||||||
|
user = Factory.build(:user, :username => " janie ")
|
||||||
|
user.should be_valid
|
||||||
|
user.username.should == "janie"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails if there's whitespace in the middle" do
|
||||||
|
user = Factory.build(:user, :username => "bobby tables")
|
||||||
|
user.should_not be_valid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "of email" do
|
||||||
|
it "requires email address" do
|
||||||
|
user = Factory.build(:user, :email => nil)
|
||||||
|
user.should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "requires a unique email address" do
|
||||||
|
duplicate_user = Factory.build(:user, :email => user.email)
|
||||||
|
duplicate_user.should_not be_valid
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ".find_for_authentication" do
|
||||||
|
it "preserves case" do
|
||||||
|
User.find_for_authentication(:username => user.username).should == user
|
||||||
|
User.find_for_authentication(:username => user.username.upcase).should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -46,10 +87,10 @@ describe User do
|
||||||
|
|
||||||
context 'profiles' do
|
context 'profiles' do
|
||||||
it 'should be able to update their profile and send it to their friends' do
|
it 'should be able to update their profile and send it to their friends' do
|
||||||
updated_profile = { :profile => {
|
updated_profile = {:profile => {
|
||||||
:first_name => 'bob',
|
:first_name => 'bob',
|
||||||
:last_name => 'billytown',
|
:last_name => 'billytown',
|
||||||
:image_url => "http://clown.com"} }
|
:image_url => "http://clown.com"}}
|
||||||
|
|
||||||
user.update_profile(updated_profile).should be true
|
user.update_profile(updated_profile).should be true
|
||||||
user.profile.image_url.should == "http://clown.com"
|
user.profile.image_url.should == "http://clown.com"
|
||||||
|
|
@ -66,7 +107,7 @@ describe User do
|
||||||
it 'should not delete an aspect with friends' do
|
it 'should not delete an aspect with friends' do
|
||||||
friend_users(user, aspect, user2, aspect2)
|
friend_users(user, aspect, user2, aspect2)
|
||||||
aspect.reload
|
aspect.reload
|
||||||
proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/
|
proc { user.drop_aspect(aspect) }.should raise_error /Aspect not empty/
|
||||||
user.aspects.include?(aspect).should == true
|
user.aspects.include?(aspect).should == true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -76,27 +117,27 @@ describe User do
|
||||||
friend_users(user, aspect, user2, aspect2)
|
friend_users(user, aspect, user2, aspect2)
|
||||||
friend_users(user, aspect, user3, aspect3)
|
friend_users(user, aspect, user3, aspect3)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unfriend everyone' do
|
it 'should unfriend everyone' do
|
||||||
user.should_receive(:unfriend_everyone)
|
user.should_receive(:unfriend_everyone)
|
||||||
user.destroy
|
user.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remove person' do
|
it 'should remove person' do
|
||||||
user.should_receive(:remove_person)
|
user.should_receive(:remove_person)
|
||||||
user.destroy
|
user.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'should remove all aspects' do
|
it 'should remove all aspects' do
|
||||||
pending "this should use :dependant => :destroy on the many assoc...but that screws this test suite..."
|
pending "this should use :dependant => :destroy on the many assoc...but that screws this test suite..."
|
||||||
aspects = user.aspects
|
aspects = user.aspects
|
||||||
user.destroy
|
user.destroy
|
||||||
proc{ aspects.reload }.should raise_error /does not exist/
|
proc { aspects.reload }.should raise_error /does not exist/
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe '#remove_person' do
|
describe '#remove_person' do
|
||||||
it 'should remove the person object' do
|
it 'should remove the person object' do
|
||||||
person = user.person
|
person = user.person
|
||||||
|
|
@ -109,7 +150,7 @@ describe User do
|
||||||
message = user.post(:status_message, :message => "hi", :to => aspect.id)
|
message = user.post(:status_message, :message => "hi", :to => aspect.id)
|
||||||
user.reload
|
user.reload
|
||||||
user.destroy
|
user.destroy
|
||||||
proc{ message.reload }.should raise_error /does not exist/
|
proc { message.reload }.should raise_error /does not exist/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -124,7 +165,7 @@ describe User do
|
||||||
user.destroy
|
user.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unfriend local people' do
|
it 'should unfriend local people' do
|
||||||
user2.friends.count.should be 1
|
user2.friends.count.should be 1
|
||||||
user.destroy
|
user.destroy
|
||||||
user2.reload
|
user2.reload
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue