Merge remote branch 'upstream/master'
Conflicts: pkg/fedora/make-dist.sh
This commit is contained in:
commit
d6dec71225
49 changed files with 684 additions and 486 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
|||
# Configuration files
|
||||
config/app_config.yml
|
||||
config/fb_config.yml
|
||||
config/oauth_keys.yml
|
||||
config/initializers/secret_token.rb
|
||||
.bundle
|
||||
vendor/bundle/*
|
||||
|
|
|
|||
6
Gemfile
6
Gemfile
|
|
@ -9,6 +9,10 @@ gem "chef"
|
|||
gem 'devise', '1.1.3'
|
||||
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
|
||||
gem 'devise_invitable', '~> 0.3.4'
|
||||
|
||||
#Authentication
|
||||
gem 'omniauth'
|
||||
gem 'twitter'
|
||||
#Mongo
|
||||
gem 'mongo_mapper', :branch => 'rails3', :git => 'git://github.com/jnunemaker/mongomapper.git'
|
||||
gem 'bson_ext', '1.1'
|
||||
|
|
@ -54,7 +58,7 @@ group :test do
|
|||
gem 'rspec', '>= 2.0.0'
|
||||
gem 'rspec-rails', '>= 2.0.0'
|
||||
gem 'mocha'
|
||||
gem 'database_cleaner'
|
||||
gem 'database_cleaner', '0.5.2'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
|
|
|
|||
99
Gemfile.lock
99
Gemfile.lock
|
|
@ -1,8 +1,8 @@
|
|||
GIT
|
||||
remote: git://github.com/Empact/roxml.git
|
||||
revision: 33034d3e632b3a14565a791af0a63c7e23ec0de4
|
||||
revision: d411519add92e0cd5a985253f376d25c26884324
|
||||
specs:
|
||||
roxml (3.1.5)
|
||||
roxml (3.1.6)
|
||||
activesupport (>= 2.3.0)
|
||||
nokogiri (>= 1.3.3)
|
||||
|
||||
|
|
@ -98,7 +98,6 @@ GEM
|
|||
activesupport (= 3.0.1)
|
||||
activesupport (3.0.1)
|
||||
addressable (2.2.2)
|
||||
archive-tar-minitar (0.5.2)
|
||||
arel (1.0.1)
|
||||
activesupport (~> 3.0.0)
|
||||
aws (2.3.22)
|
||||
|
|
@ -142,10 +141,10 @@ GEM
|
|||
columnize (0.3.1)
|
||||
configuration (1.1.0)
|
||||
crack (0.1.8)
|
||||
cucumber (0.9.2)
|
||||
cucumber (0.9.3)
|
||||
builder (~> 2.1.2)
|
||||
diff-lcs (~> 1.1.2)
|
||||
gherkin (~> 2.2.5)
|
||||
gherkin (~> 2.2.9)
|
||||
json (~> 1.4.6)
|
||||
term-ansicolor (~> 1.0.5)
|
||||
cucumber-rails (0.3.2)
|
||||
|
|
@ -170,6 +169,10 @@ GEM
|
|||
factory_girl_rails (1.0)
|
||||
factory_girl (~> 1.3)
|
||||
rails (>= 3.0.0.beta4)
|
||||
faraday (0.5.1)
|
||||
addressable (~> 2.2.2)
|
||||
multipart-post (~> 1.0.1)
|
||||
rack (~> 1.2.1)
|
||||
ffi (0.6.3)
|
||||
rake (>= 0.8.7)
|
||||
gherkin (2.2.9)
|
||||
|
|
@ -179,18 +182,20 @@ GEM
|
|||
hashie (0.4.0)
|
||||
highline (1.6.1)
|
||||
http_connection (1.4.0)
|
||||
i18n (0.4.1)
|
||||
httparty (0.6.1)
|
||||
crack (= 0.1.8)
|
||||
i18n (0.4.2)
|
||||
json (1.4.6)
|
||||
json_pure (1.4.6)
|
||||
launchy (0.3.7)
|
||||
configuration (>= 0.0.5)
|
||||
rake (>= 0.8.1)
|
||||
linecache19 (0.5.11)
|
||||
ruby_core_source (>= 0.1.4)
|
||||
mail (2.2.7)
|
||||
linecache (0.43)
|
||||
mail (2.2.9)
|
||||
activesupport (>= 2.3.6)
|
||||
mime-types
|
||||
treetop (>= 1.4.5)
|
||||
i18n (~> 0.4.1)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.16)
|
||||
mini_fb (1.1.3)
|
||||
hashie
|
||||
|
|
@ -202,11 +207,14 @@ GEM
|
|||
mixlib-cli (1.2.0)
|
||||
mixlib-config (1.1.2)
|
||||
mixlib-log (1.2.0)
|
||||
mocha (0.9.8)
|
||||
mocha (0.9.9)
|
||||
rake
|
||||
moneta (0.6.0)
|
||||
mongo (1.1)
|
||||
bson (>= 1.0.5)
|
||||
multi_json (0.0.4)
|
||||
multipart-post (1.0.1)
|
||||
net-ldap (0.1.1)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
net-sftp (2.0.5)
|
||||
|
|
@ -215,6 +223,33 @@ GEM
|
|||
net-ssh-gateway (1.0.1)
|
||||
net-ssh (>= 1.99.1)
|
||||
nokogiri (1.4.3.1)
|
||||
oa-basic (0.1.6)
|
||||
multi_json (~> 0.0.2)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.6)
|
||||
rest-client (~> 1.6.0)
|
||||
oa-core (0.1.6)
|
||||
rack (~> 1.1)
|
||||
oa-enterprise (0.1.6)
|
||||
net-ldap (~> 0.1.1)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.6)
|
||||
pyu-ruby-sasl (~> 0.0.3.1)
|
||||
rubyntlm (~> 0.1.1)
|
||||
oa-oauth (0.1.6)
|
||||
multi_json (~> 0.0.2)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.6)
|
||||
oauth (~> 0.4.0)
|
||||
oauth2 (~> 0.1.0)
|
||||
oa-openid (0.1.6)
|
||||
oa-core (= 0.1.6)
|
||||
rack-openid (~> 1.2.0)
|
||||
ruby-openid-apps-discovery
|
||||
oauth (0.4.3)
|
||||
oauth2 (0.1.0)
|
||||
faraday (~> 0.5.0)
|
||||
multi_json (~> 0.0.4)
|
||||
ohai (0.5.8)
|
||||
extlib
|
||||
json (>= 1.4.4, <= 1.4.6)
|
||||
|
|
@ -222,15 +257,25 @@ GEM
|
|||
mixlib-config
|
||||
mixlib-log
|
||||
systemu
|
||||
omniauth (0.1.6)
|
||||
oa-basic (= 0.1.6)
|
||||
oa-core (= 0.1.6)
|
||||
oa-enterprise (= 0.1.6)
|
||||
oa-oauth (= 0.1.6)
|
||||
oa-openid (= 0.1.6)
|
||||
plucky (0.3.6)
|
||||
mongo (~> 1.1)
|
||||
polyglot (0.3.1)
|
||||
pubsubhubbub (0.1.1)
|
||||
em-http-request (>= 0.1.5)
|
||||
eventmachine (>= 0.12.9)
|
||||
pyu-ruby-sasl (0.0.3.2)
|
||||
rack (1.2.1)
|
||||
rack-mount (0.6.13)
|
||||
rack (>= 1.0.0)
|
||||
rack-openid (1.2.0)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.5.6)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.1)
|
||||
|
|
@ -261,16 +306,15 @@ GEM
|
|||
rspec-expectations (~> 2.0.1)
|
||||
rspec-rails (2.0.1)
|
||||
rspec (~> 2.0.0)
|
||||
ruby-debug-base19 (0.11.24)
|
||||
columnize (>= 0.3.1)
|
||||
linecache19 (>= 0.5.11)
|
||||
ruby_core_source (>= 0.1.4)
|
||||
ruby-debug19 (0.11.6)
|
||||
columnize (>= 0.3.1)
|
||||
linecache19 (>= 0.5.11)
|
||||
ruby-debug-base19 (>= 0.11.19)
|
||||
ruby_core_source (0.1.4)
|
||||
archive-tar-minitar (>= 0.5.2)
|
||||
ruby-debug (0.10.3)
|
||||
columnize (>= 0.1)
|
||||
ruby-debug-base (~> 0.10.3.0)
|
||||
ruby-debug-base (0.10.3)
|
||||
linecache (>= 0.3)
|
||||
ruby-openid (2.1.8)
|
||||
ruby-openid-apps-discovery (1.2.0)
|
||||
ruby-openid (>= 2.1.7)
|
||||
rubyntlm (0.1.1)
|
||||
rubyzip (0.9.4)
|
||||
selenium-webdriver (0.0.29)
|
||||
childprocess (>= 0.0.7)
|
||||
|
|
@ -287,6 +331,11 @@ GEM
|
|||
thor (0.14.3)
|
||||
treetop (1.4.8)
|
||||
polyglot (>= 0.3.1)
|
||||
twitter (0.9.12)
|
||||
hashie (~> 0.4.0)
|
||||
httparty (~> 0.6.1)
|
||||
multi_json (~> 0.0.4)
|
||||
oauth (~> 0.4.3)
|
||||
tzinfo (0.3.23)
|
||||
uuidtools (2.1.1)
|
||||
warden (0.10.7)
|
||||
|
|
@ -310,7 +359,7 @@ DEPENDENCIES
|
|||
carrierwave!
|
||||
chef
|
||||
cucumber-rails (= 0.3.2)
|
||||
database_cleaner
|
||||
database_cleaner (= 0.5.2)
|
||||
devise (= 1.1.3)
|
||||
devise-mongo_mapper!
|
||||
devise_invitable (~> 0.3.4)
|
||||
|
|
@ -325,14 +374,16 @@ DEPENDENCIES
|
|||
mini_magick
|
||||
mocha
|
||||
mongo_mapper!
|
||||
omniauth
|
||||
pubsubhubbub
|
||||
rails (>= 3.0.0)
|
||||
redfinger!
|
||||
roxml!
|
||||
rspec (>= 2.0.0)
|
||||
rspec-rails (>= 2.0.0)
|
||||
ruby-debug19
|
||||
ruby-debug
|
||||
sprinkle!
|
||||
thin
|
||||
twitter
|
||||
webmock
|
||||
will_paginate (= 3.0.pre2)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ You can find an introduction to the source code [here](http://github.com/diaspor
|
|||
Bugs and pending features are on our [issue tracker](http://bugs.joindiaspora.com). Here are a few good places to start:
|
||||
|
||||
- Run "rake spec" to run our [Rspec](http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/)
|
||||
unit test suite. Take a look at the pending specs, make one pass!
|
||||
unit test suite. [Here](http://github.com/diaspora/diaspora/wiki/Introduction-to-Our-Rspec-Convention) is an introduction to our Rspec convention. Take a look at the pending specs, make one pass!
|
||||
|
||||
- Run "rake cucumber" to run our [Cucumber](http://rubylearning.com/blog/2010/10/05/outside-in-development/)
|
||||
integration test suite. As you can see, we need more integration tests. Pick a feature and write one!
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
before_filter :set_friends_and_status, :except => [:create, :update]
|
||||
before_filter :count_requests
|
||||
before_filter :fb_user_info
|
||||
before_filter :set_invites
|
||||
|
||||
layout :layout_by_resource
|
||||
|
|
@ -44,16 +43,4 @@ class ApplicationController < ActionController::Base
|
|||
@invites = current_user.invites
|
||||
end
|
||||
end
|
||||
|
||||
def fb_user_info
|
||||
if current_user
|
||||
@access_token = warden.session[:access_token]
|
||||
@logged_in = @access_token.present?
|
||||
end
|
||||
end
|
||||
|
||||
def logged_into_fb?
|
||||
@logged_in
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,9 +11,6 @@ class AspectsController < ApplicationController
|
|||
def index
|
||||
@posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
@aspect = :all
|
||||
|
||||
@fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
|
||||
:scope=>MiniFB.scopes.join(","))
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
@ -51,20 +48,11 @@ class AspectsController < ApplicationController
|
|||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@friends = @aspect.people
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
respond_with @aspect
|
||||
end
|
||||
end
|
||||
|
||||
def public
|
||||
# @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
|
||||
# :scope=>MiniFB.scopes.join(","))
|
||||
|
||||
@posts = current_user.visible_posts(:person_id => current_user.person.id, :public => true).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
|
||||
respond_with @aspect
|
||||
end
|
||||
|
||||
def manage
|
||||
@aspect = :manage
|
||||
@remote_requests = current_user.requests_for_me
|
||||
|
|
@ -109,11 +97,4 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
private
|
||||
def clean_hash(params)
|
||||
return {
|
||||
:name => params[:name]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ class PeopleController < ApplicationController
|
|||
@profile = @person.profile
|
||||
@aspects_with_person = current_user.aspects_with_person(@person)
|
||||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
|
||||
@post_count = @posts.count
|
||||
respond_with @person
|
||||
end
|
||||
end
|
||||
|
|
@ -34,4 +32,38 @@ class PeopleController < ApplicationController
|
|||
respond_with :location => root_url
|
||||
end
|
||||
|
||||
def edit
|
||||
@aspect = :person_edit
|
||||
@person = current_user.person
|
||||
@profile = @person.profile
|
||||
@photos = current_user.visible_posts(:person_id => @person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def update
|
||||
prep_image_url(params[:person])
|
||||
|
||||
if current_user.update_profile params[:person][:profile]
|
||||
flash[:notice] = "Profile updated"
|
||||
else
|
||||
flash[:error] = "Failed to update profile"
|
||||
end
|
||||
|
||||
redirect_to edit_person_path
|
||||
end
|
||||
|
||||
private
|
||||
def prep_image_url(params)
|
||||
url = APP_CONFIG[:pod_url].dup
|
||||
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
if params[:profile][:image_url].empty?
|
||||
params[:profile].delete(:image_url)
|
||||
else
|
||||
if /^http:\/\// =~ params[:profile][:image_url]
|
||||
params[:profile][:image_url] = params[:profile][:image_url]
|
||||
else
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,37 +4,42 @@
|
|||
|
||||
|
||||
class ServicesController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@services = current_user.services
|
||||
end
|
||||
|
||||
def create
|
||||
puts 'services/create'
|
||||
p params
|
||||
auth = request.env['omniauth.auth']
|
||||
|
||||
code = params['code'] # Facebooks verification string
|
||||
if code
|
||||
access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code)
|
||||
p access_token_hash
|
||||
@access_token = access_token_hash["access_token"]
|
||||
provider = auth['provider']
|
||||
user = auth['user_info']
|
||||
|
||||
# TODO: This is where you'd want to store the token in your database
|
||||
# but for now, we'll just keep it in the session so we don't need a database
|
||||
warden.session[:access_token] = @access_token
|
||||
flash[:success] = "Authentication successful."
|
||||
if provider == 'twitter'
|
||||
access_token = auth['extra']['access_token']
|
||||
current_user.services.create(:nickname => user['nickname'],
|
||||
:access_token => access_token.token,
|
||||
:access_secret => access_token.secret,
|
||||
:provider => provider,
|
||||
:uid => auth['uid'])
|
||||
|
||||
elsif provider == 'facebook'
|
||||
current_user.services.create(:nickname => user['nickname'],
|
||||
:access_token => auth['credentials']['token'],
|
||||
:provider => provider,
|
||||
:uid => auth['uid'])
|
||||
end
|
||||
redirect_to edit_user_url current_user
|
||||
|
||||
|
||||
flash[:notice] = "Authentication successful."
|
||||
redirect_to services_url
|
||||
end
|
||||
|
||||
def destroy
|
||||
warden.session[:access_token] = nil
|
||||
warden.session[:user_id] = nil
|
||||
redirect_to edit_user_url current_user
|
||||
@service = current_user.services.find(params[:id])
|
||||
@service.destroy
|
||||
flash[:notice] = "Successfully destroyed authentication."
|
||||
redirect_to services_url
|
||||
end
|
||||
|
||||
def fb_post
|
||||
id = 'me'
|
||||
type = 'feed'
|
||||
|
||||
@res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>params)
|
||||
redirect_to edit_user_url current_user
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ class StatusMessagesController < ApplicationController
|
|||
respond_to :json, :only => :show
|
||||
|
||||
def create
|
||||
public_flag = params[:status_message][:public]
|
||||
public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false
|
||||
params[:status_message][:public] = public_flag
|
||||
|
||||
data = clean_hash params[:status_message]
|
||||
|
||||
if logged_into_fb? && params[:status_message][:public] == '1'
|
||||
current_user.post_to_message_fb(params[:status_message][:message], @access_token)
|
||||
end
|
||||
|
||||
@status_message = current_user.post(:status_message, data)
|
||||
message = params[:status_message][:message]
|
||||
status_message = current_user.post(:status_message, data)
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
|
|
@ -27,11 +27,7 @@ class StatusMessagesController < ApplicationController
|
|||
|
||||
def show
|
||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||
unless @status_message
|
||||
render :status => 404
|
||||
else
|
||||
respond_with @status_message
|
||||
end
|
||||
respond_with @status_message
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -14,14 +14,8 @@ class UsersController < ApplicationController
|
|||
respond_to :html
|
||||
|
||||
def edit
|
||||
@aspect = :user_edit
|
||||
@user = current_user
|
||||
@person = @user.person
|
||||
@profile = @user.person.profile
|
||||
@photos = current_user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
||||
@fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
|
||||
:scope=>MiniFB.scopes.join(","))
|
||||
@aspect = :user_edit
|
||||
@user = current_user
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
@ -35,16 +29,9 @@ class UsersController < ApplicationController
|
|||
else
|
||||
flash[:error] = "Password Change Failed"
|
||||
end
|
||||
else
|
||||
prep_image_url(params[:user])
|
||||
if @user.update_profile params[:user][:profile]
|
||||
flash[:notice] = "Profile updated"
|
||||
else
|
||||
flash[:error] = "Failed to update profile"
|
||||
end
|
||||
end
|
||||
redirect_to edit_user_path(@user)
|
||||
|
||||
redirect_to edit_user_path(@user)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
@ -103,19 +90,5 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
|
||||
private
|
||||
def prep_image_url(params)
|
||||
url = APP_CONFIG[:pod_url].dup
|
||||
url.chop! if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
if params[:profile][:image_url].empty?
|
||||
params[:profile].delete(:image_url)
|
||||
else
|
||||
if /^http:\/\// =~ params[:profile][:image_url]
|
||||
params[:profile][:image_url] = params[:profile][:image_url]
|
||||
else
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -78,9 +78,4 @@ module ApplicationHelper
|
|||
def post_yield_tag(post)
|
||||
(':' + post.id.to_s).to_sym
|
||||
end
|
||||
|
||||
def connected_fb_as token
|
||||
response_hash = MiniFB.get(token, 'me')
|
||||
"Connected to facebook as #{response_hash[:name]}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ class Person
|
|||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
ensure_index :diaspora_handle
|
||||
|
||||
def self.search(query)
|
||||
return Person.all if query.to_s.empty?
|
||||
query_tokens = query.to_s.strip.split(" ")
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ class Request
|
|||
validates_presence_of :destination_url, :callback_url
|
||||
before_validation :clean_link
|
||||
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) }
|
||||
|
||||
def self.instantiate(options = {})
|
||||
person = options[:from]
|
||||
self.new(:destination_url => options[:to],
|
||||
|
|
|
|||
15
app/models/service.rb
Normal file
15
app/models/service.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
class Service
|
||||
include MongoMapper::Document
|
||||
|
||||
belongs_to :user
|
||||
|
||||
key :provider, String
|
||||
key :uid, String
|
||||
key :access_token, String
|
||||
key :access_secret, String
|
||||
key :nickname, String
|
||||
end
|
||||
|
|
@ -32,11 +32,11 @@ class User
|
|||
key :invites, Integer, :default => 5
|
||||
key :invitation_token, String
|
||||
key :invitation_sent_at, DateTime
|
||||
key :inviter_ids, Array
|
||||
key :friend_ids, Array
|
||||
key :pending_request_ids, Array
|
||||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
key :inviter_ids, Array, :typecast => 'ObjectId'
|
||||
key :friend_ids, Array, :typecast => 'ObjectId'
|
||||
key :pending_request_ids, Array, :typecast => 'ObjectId'
|
||||
key :visible_post_ids, Array, :typecast => 'ObjectId'
|
||||
key :visible_person_ids, Array, :typecast => 'ObjectId'
|
||||
|
||||
key :invite_messages, Hash
|
||||
|
||||
|
|
@ -61,6 +61,8 @@ class User
|
|||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||
many :aspects, :class_name => 'Aspect', :dependent => :destroy
|
||||
|
||||
many :services, :class_name => "Service"
|
||||
|
||||
#after_create :seed_aspects
|
||||
|
||||
before_destroy :unfriend_everyone, :remove_person
|
||||
|
|
@ -149,23 +151,31 @@ class User
|
|||
|
||||
aspect_ids = validate_aspect_permissions(aspect_ids)
|
||||
|
||||
intitial_post(class_name, aspect_ids, options)
|
||||
end
|
||||
|
||||
def post_to_message_fb(message, access_token)
|
||||
id = 'me'
|
||||
type = 'feed'
|
||||
Rails.logger.info("Sending a message: #{message} to Facebook")
|
||||
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{access_token}").post
|
||||
end
|
||||
|
||||
def intitial_post(class_name, aspect_ids, options = {})
|
||||
post = build_post(class_name, options)
|
||||
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
|
||||
push_to_aspects(post, aspect_ids)
|
||||
|
||||
if options[:public] == true
|
||||
self.services.each do |service|
|
||||
self.send("post_to_#{service.provider}".to_sym, service, post.message)
|
||||
end
|
||||
end
|
||||
|
||||
post
|
||||
end
|
||||
|
||||
def post_to_facebook(service, message)
|
||||
Rails.logger.info("Sending a message: #{message} to Facebook")
|
||||
EventMachine::HttpRequest.new("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{service.access_token}").post
|
||||
end
|
||||
|
||||
def post_to_twitter(service, message)
|
||||
oauth = Twitter::OAuth.new(SERVICES['twitter']['consumer_token'], SERVICES['twitter']['consumer_secret'])
|
||||
oauth.authorize_from_access(service.access_token, service.access_secret)
|
||||
client = Twitter::Base.new(oauth)
|
||||
client.update(message)
|
||||
end
|
||||
|
||||
def update_post(post, post_hash = {})
|
||||
if self.owns? post
|
||||
post.update_attributes(post_hash)
|
||||
|
|
|
|||
|
|
@ -55,8 +55,9 @@
|
|||
.avatar
|
||||
= owner_image_tag
|
||||
= link_to current_user.real_name, '#'
|
||||
%li= link_to "profile", current_user.person
|
||||
%li= link_to "settings", edit_user_path(current_user)
|
||||
%li= link_to "view profile", current_user.person
|
||||
%li= link_to "edit profile", edit_person_path(current_user.person)
|
||||
%li= link_to "account settings", edit_user_path(current_user)
|
||||
%li= link_to t('.logout.'), destroy_user_session_path
|
||||
|
||||
= render "shared/aspect_nav"
|
||||
|
|
|
|||
67
app/views/people/edit.html.haml
Normal file
67
app/views/people/edit.html.haml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
#section_header
|
||||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
%h2 Profile
|
||||
= form_for @person do |person|
|
||||
= person.error_messages
|
||||
|
||||
= person.fields_for :profile do |p|
|
||||
|
||||
%h3="#{t('.picture')}"
|
||||
%div#image_picker
|
||||
= p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
||||
|
||||
- unless @photos.nil? || @photos.empty?
|
||||
- for photo in @photos
|
||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||
= check_box_tag 'checked_photo', true, true
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
- else
|
||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
||||
= check_box_tag 'checked_photo'
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
|
||||
- else
|
||||
=t('.you_dont_have_any_photos')
|
||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
||||
=t('.page_to_upload_some')
|
||||
|
||||
=will_paginate @photos
|
||||
|
||||
%br
|
||||
|
||||
%h3="#{t('.info')}"
|
||||
|
||||
%p
|
||||
%b
|
||||
="#{t('.diaspora_username')}:"
|
||||
= @person.diaspora_handle
|
||||
|
||||
%p
|
||||
= p.label :first_name
|
||||
= p.text_field :first_name, :value => @profile.first_name
|
||||
%p
|
||||
= p.label :last_name
|
||||
= p.text_field :last_name, :value => @profile.last_name
|
||||
|
||||
.submit_block
|
||||
= link_to t('.cancel'), edit_user_path(current_user)
|
||||
= t('.or')
|
||||
= person.submit t('.update_profile')
|
||||
|
||||
#content_bottom
|
||||
.back
|
||||
= link_to "⇧ #{t('.home')}", root_path
|
||||
|
||||
28
app/views/services/index.html.haml
Normal file
28
app/views/services/index.html.haml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
#section_header
|
||||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
%h2
|
||||
Services
|
||||
|
||||
%ul#stream
|
||||
- for service in @services
|
||||
%h3
|
||||
%b= service.provider
|
||||
logged in as
|
||||
%b
|
||||
= service.nickname
|
||||
= link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete
|
||||
|
||||
%h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= ""
|
||||
%h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !=""
|
||||
|
||||
|
|
@ -15,11 +15,6 @@
|
|||
- for friend in @friends
|
||||
= person_image_link(friend)
|
||||
|
||||
- if @logged_in && (@aspect == :public)
|
||||
%h3 Facebook Friends
|
||||
- @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends")
|
||||
- @fb_friends[:data].each do |friend|
|
||||
= image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" )
|
||||
-unless (@aspect == :all)
|
||||
= link_to (image_tag('add_friend_button.png', :title => "add to #{@aspect}")), "#add_request_pane", :id => 'add_request_button'
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,14 @@
|
|||
Public messages will be available for others outside of Diaspora to see.
|
||||
%br
|
||||
%br
|
||||
- if @logged_in
|
||||
= connected_fb_as(@access_token)
|
||||
- else
|
||||
= link_to "Connect to Facebook", @fb_access_url
|
||||
|
||||
- if current_user.services
|
||||
- for service in current_user.services
|
||||
= "logged in to #{service.provider}"
|
||||
%br
|
||||
|
||||
= link_to "manage connected services", services_path
|
||||
|
||||
%br
|
||||
%br
|
||||
= link_to "OK", '#', :class => "button", :onClick => '$.fancybox.close();'
|
||||
|
|
|
|||
|
|
@ -2,20 +2,22 @@
|
|||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
:javascript
|
||||
$("div.public_toggle input").live("click", function(evt){
|
||||
if("#{@logged_in}" == "false" && $(this).attr('checked') == true){
|
||||
$(".question_mark").click();
|
||||
};
|
||||
});
|
||||
|
||||
$("#publisher textarea, #publisher input").live("focus", function(evt){
|
||||
$("#publisher .options_and_submit").fadeIn(50);
|
||||
});
|
||||
|
||||
$("#publisher form").live("submit", function(evt){
|
||||
$("#publisher .options_and_submit").hide();
|
||||
});
|
||||
- content_for :head do
|
||||
:javascript
|
||||
$("div.public_toggle input").live("click", function(evt){
|
||||
if($(this).attr('checked') == true){
|
||||
$(".question_mark").click();
|
||||
};
|
||||
});
|
||||
|
||||
$("#publisher textarea, #publisher input").live("focus", function(evt){
|
||||
$("#publisher .options_and_submit").fadeIn(50);
|
||||
});
|
||||
|
||||
$("#publisher form").live("submit", function(evt){
|
||||
$("#publisher .options_and_submit").hide();
|
||||
});
|
||||
|
||||
#publisher
|
||||
= owner_image_tag
|
||||
|
|
@ -33,7 +35,7 @@
|
|||
|
||||
- if aspect == :all
|
||||
.public_toggle
|
||||
= status.check_box( :public, :value => false )
|
||||
= status.check_box( :public, {}, true, false )
|
||||
make public
|
||||
= link_to '(?)', "#question_mark_pane", :class => 'question_mark'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h2 Account
|
||||
|
||||
= link_to "invite friends", new_user_invitation_path(current_user)
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Change Password
|
||||
= form_for @user do |f|
|
||||
= f.error_messages
|
||||
|
||||
%p
|
||||
= f.label :password, "New Password"
|
||||
= f.password_field :password
|
||||
%p
|
||||
= f.label :password_confirmation
|
||||
= f.password_field :password_confirmation
|
||||
|
||||
.submit_block
|
||||
= link_to "Cancel", edit_user_path(current_user)
|
||||
or
|
||||
= f.submit 'Change password'
|
||||
|
||||
%h3 Export Data
|
||||
= link_to "download my xml", users_export_path, :class => "button"
|
||||
= link_to "download my photos", users_export_photos_path, :class => "button"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Close Account
|
||||
= link_to "Close Account", current_user,
|
||||
:confirm => "Are you sure?", :method => :delete,
|
||||
:class => "button"
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h2 Profile
|
||||
= form_for @user do |f|
|
||||
= f.error_messages
|
||||
|
||||
= f.fields_for :profile do |p|
|
||||
|
||||
%h3="#{t('.picture')}"
|
||||
%div#image_picker
|
||||
= p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
|
||||
|
||||
- unless @photos.nil? || @photos.empty?
|
||||
- for photo in @photos
|
||||
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||
= check_box_tag 'checked_photo', true, true
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
- else
|
||||
%div.small_photo{:id => photo.url(:thumb_medium)}
|
||||
= check_box_tag 'checked_photo'
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
|
||||
- else
|
||||
=t('.you_dont_have_any_photos')
|
||||
= link_to t('.albums'), albums_path(:aspect => 'all')
|
||||
=t('.page_to_upload_some')
|
||||
|
||||
=will_paginate @photos
|
||||
|
||||
%br
|
||||
|
||||
%h3="#{t('.info')}"
|
||||
|
||||
%p
|
||||
%b
|
||||
="#{t('.diaspora_username')}:"
|
||||
= @user.diaspora_handle
|
||||
|
||||
%p
|
||||
= p.label :first_name
|
||||
= p.text_field :first_name, :value => @profile.first_name
|
||||
%p
|
||||
= p.label :last_name
|
||||
= p.text_field :last_name, :value => @profile.last_name
|
||||
|
||||
.submit_block
|
||||
= link_to t('.cancel'), edit_user_path(current_user)
|
||||
= t('.or')
|
||||
= f.submit t('.update_profile')
|
||||
|
||||
#content_bottom
|
||||
.back
|
||||
= link_to "⇧ #{t('.home')}", root_path
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h2 Services
|
||||
|
||||
- if FACEBOOK
|
||||
%h3 Facebook
|
||||
%p
|
||||
- if @logged_in
|
||||
= connected_fb_as(@access_token)
|
||||
|
||||
%p
|
||||
- @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends")
|
||||
- @fb_friends[:data].each do |friend|
|
||||
= image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" )
|
||||
|
||||
= link_to "Disconnect from Facebook", services_destroy_path
|
||||
- else
|
||||
= link_to "Connect to Facebook", @fb_access_url
|
||||
|
||||
#content_bottom
|
||||
.back
|
||||
= link_to "⇧ home", root_path
|
||||
|
||||
|
|
@ -16,17 +16,44 @@
|
|||
%h2
|
||||
Settings
|
||||
%ul#settings_nav
|
||||
%li=link_to 'Profile', '#', :class => 'profile'
|
||||
%li=link_to 'Account', '#', :class => 'account'
|
||||
%li=link_to 'Services', '#', :class => 'services'
|
||||
%li=link_to 'Profile', edit_person_path(current_user.person)
|
||||
%li=link_to 'Account', edit_user_path(current_user)
|
||||
%li=link_to 'Services', services_path
|
||||
|
||||
.span-19.prepend-5.last
|
||||
#profile.settings_pane{:style=>"display:block;"}
|
||||
= render 'users/profile'
|
||||
%h2 Account
|
||||
|
||||
#account.settings_pane
|
||||
= render 'users/account'
|
||||
= link_to "invite friends", new_user_invitation_path(current_user)
|
||||
|
||||
#services.settings_pane
|
||||
= render 'users/services'
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Change Password
|
||||
= form_for @user do |f|
|
||||
= f.error_messages
|
||||
|
||||
%p
|
||||
= f.label :password, "New Password"
|
||||
= f.password_field :password
|
||||
%p
|
||||
= f.label :password_confirmation
|
||||
= f.password_field :password_confirmation
|
||||
|
||||
.submit_block
|
||||
= link_to "Cancel", edit_user_path(current_user)
|
||||
or
|
||||
= f.submit 'Change password'
|
||||
|
||||
%h3 Export Data
|
||||
= link_to "download my xml", users_export_path, :class => "button"
|
||||
= link_to "download my photos", users_export_photos_path, :class => "button"
|
||||
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
|
||||
%h3 Close Account
|
||||
= link_to "Close Account", current_user,
|
||||
:confirm => "Are you sure?", :method => :delete,
|
||||
:class => "button"
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ namespace :deploy do
|
|||
run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml"
|
||||
end
|
||||
|
||||
task :symlink_fb_config do
|
||||
run "touch #{shared_path}/fb_config.yml"
|
||||
run "ln -s -f #{shared_path}/fb_config.yml #{current_path}/config/fb_config.yml"
|
||||
task :symlink_oauth_keys_config do
|
||||
run "touch #{shared_path}/oauth_keys.yml"
|
||||
run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml"
|
||||
end
|
||||
|
||||
task :start do
|
||||
|
|
@ -157,4 +157,4 @@ namespace :db do
|
|||
|
||||
end
|
||||
|
||||
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_fb_config'
|
||||
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_oauth_keys_config'
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32}
|
||||
fb_secret: {7fe864834726f8a5e65bc93928b99a53}
|
||||
fb_app_id: {120373411325347}
|
||||
host: http://localhost:3000/
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
fb_api_key: {key}
|
||||
fb_secret: {secret}
|
||||
fb_app_id: {app_id}
|
||||
host: http://localhost:3000/
|
||||
19
config/initializers/_load_services.rb
Normal file
19
config/initializers/_load_services.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
def load_config_yaml filename
|
||||
YAML.load(File.read(filename))
|
||||
end
|
||||
|
||||
oauth_keys_file = "#{Rails.root}/config/oauth_keys.yml"
|
||||
|
||||
|
||||
SERVICES = nil
|
||||
silence_warnings do
|
||||
if File.exist? oauth_keys_file
|
||||
SERVICES = load_config_yaml(oauth_keys_file)
|
||||
else
|
||||
SERVICES = load_config_yaml("#{oauth_keys_file}.example")
|
||||
end
|
||||
end
|
||||
9
config/initializers/omniauth.rb
Normal file
9
config/initializers/omniauth.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :twitter, SERVICES['twitter']['consumer_key'], SERVICES['twitter']['consumer_secret']
|
||||
provider :facebook, SERVICES['facebook']['app_id'], SERVICES['facebook']['app_secret']
|
||||
end
|
||||
|
||||
|
|
@ -116,18 +116,6 @@ en:
|
|||
users:
|
||||
edit:
|
||||
editing_profile: "Editing profile"
|
||||
profile:
|
||||
cancel: "Cancel"
|
||||
update_profile: "Update Profile"
|
||||
home: "Home"
|
||||
diaspora_username: "DIASPORA USERNAME"
|
||||
info: "Info"
|
||||
picture: "Picture"
|
||||
editing_profile: "Editing profile"
|
||||
albums: "Albums"
|
||||
you_dont_have_any_photos: "You don't have any photos! Go to the"
|
||||
page_to_upload_some: "page to upload some."
|
||||
or: "or"
|
||||
destroy: "Account successfully closed."
|
||||
comments:
|
||||
comment:
|
||||
|
|
@ -218,6 +206,18 @@ en:
|
|||
are_you_sure: "Are you sure?"
|
||||
remove_friend: "remove friend"
|
||||
no_posts: "no posts to display!"
|
||||
edit:
|
||||
cancel: "Cancel"
|
||||
update_profile: "Update Profile"
|
||||
home: "Home"
|
||||
diaspora_username: "DIASPORA USERNAME"
|
||||
info: "Info"
|
||||
picture: "Picture"
|
||||
editing_profile: "Editing profile"
|
||||
albums: "Albums"
|
||||
you_dont_have_any_photos: "You don't have any photos! Go to the"
|
||||
page_to_upload_some: "page to upload some."
|
||||
or: "or"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Add a new friend to"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@
|
|||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
fr-informal:
|
||||
activemodel:
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
attributes:
|
||||
username:
|
||||
taken: "est déjà pris"
|
||||
email:
|
||||
taken: "est déjà pris"
|
||||
hello: "Bonjour tout le monde"
|
||||
application:
|
||||
helper:
|
||||
|
|
@ -38,6 +47,7 @@ fr-informal:
|
|||
share: "Partager"
|
||||
aspect_friends:
|
||||
add_friends: "ajouter des amis"
|
||||
photos: "photos"
|
||||
albums:
|
||||
album:
|
||||
you: "toi"
|
||||
|
|
@ -69,10 +79,14 @@ fr-informal:
|
|||
friends_albums: "Albums d’amis"
|
||||
your_albums: "Tes albums"
|
||||
aspects:
|
||||
index:
|
||||
photos: "photos"
|
||||
show:
|
||||
photos: "photos"
|
||||
no_friends_message:
|
||||
nobody: "Tu as forcément des amis, n’hésite pas à les ramener sur Diaspora !"
|
||||
nobody_in_aspect: "Ton aspect '%{aspect_name}' est vide."
|
||||
add_friend: "Ajouter un ami"
|
||||
add_friend_to: "Ajouter quelqu’un à %{aspect_name}"
|
||||
invite: "Inviter quelqu’un à rejoindre Diaspora !"
|
||||
no_posts_message:
|
||||
start_talking: "Personne n’a encore rien dit. Commence dès à présent la conversation !"
|
||||
manage:
|
||||
add_a_new_aspect: "Ajouter un nouvel aspect"
|
||||
add_a_new_friend: "Ajouter un nouvel ami"
|
||||
|
|
@ -90,12 +104,12 @@ fr-informal:
|
|||
success: "%{name} a été supprimé avec succès."
|
||||
update:
|
||||
success: "Ton aspect, %{name}, a été édité avec succès."
|
||||
move_friends:
|
||||
failure: "L’édition de l’aspect concernant ton ami %{real_name} a échoué."
|
||||
success: "Les aspects ont été édités avec succès."
|
||||
move_friend:
|
||||
failure: "ne fonctionne pas %{inspect}"
|
||||
success: "Tu montres à présent à ton ami un aspect différent au tiens."
|
||||
success: "Personne déplacée vers le nouvel aspect"
|
||||
add_to_aspect:
|
||||
failure: "L’ajout de l’ami vers l’aspect a échoué."
|
||||
success: "Tu as ajouté l’ami à l’aspect avec succès."
|
||||
helper:
|
||||
remove: "supprimer"
|
||||
aspect_not_empty: "L’aspect n’est pas vide"
|
||||
|
|
@ -136,6 +150,8 @@ fr-informal:
|
|||
photo:
|
||||
show_comments: "afficher les commentaires"
|
||||
posted_a_new_photo_to: "a publié une nouvelle photo dans"
|
||||
delete: "Supprimer"
|
||||
are_you_sure: "Es-tu sûr(e) ?"
|
||||
new:
|
||||
new_photo: "Nouvelle photo"
|
||||
back_to_list: "Retourner à la liste"
|
||||
|
|
@ -159,6 +175,7 @@ fr-informal:
|
|||
sent: 'Ton invitation a été envoyée.'
|
||||
no_more: 'Tu n’as plus d’invitation.'
|
||||
already_sent: 'Tu as déjà invité cette personne.'
|
||||
already_friends: 'Tu es déjà ami avec cette personne'
|
||||
invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !'
|
||||
updated: 'Ton mot de passe a été réglé avec succès. Tu es à présent connecté.'
|
||||
|
||||
|
|
@ -200,6 +217,7 @@ fr-informal:
|
|||
save: "sauver"
|
||||
are_you_sure: "Es-tu sûr(e) ?"
|
||||
remove_friend: "supprimer de mes amis"
|
||||
no_posts: "aucun message à afficher !"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Ajouter un nouvel ami à"
|
||||
|
|
@ -212,6 +230,9 @@ fr-informal:
|
|||
ignore: "Requête d’ami ignorée."
|
||||
create:
|
||||
error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !"
|
||||
already_friends: "Vous êtes déjà amis avec %{destination_url}!"
|
||||
invalid_identity: "Cette identité n’est pas proprement formatée"
|
||||
error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?"
|
||||
yourself: "Tu ne peux pas être ami avec toi-même !"
|
||||
already_friends: "Tu es déjà ami avec %{destination_url}!"
|
||||
success: "Une requête d’ami a été envoyée à %{destination_url}."
|
||||
horribly_wrong: "Quelque chose d’horrible s’est produit."
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@
|
|||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
fr:
|
||||
activemodel:
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
attributes:
|
||||
username:
|
||||
taken: "est déjà pris"
|
||||
email:
|
||||
taken: "est déjà pris"
|
||||
hello: "Bonjour tout le monde"
|
||||
application:
|
||||
helper:
|
||||
|
|
@ -38,6 +47,7 @@ fr:
|
|||
share: "Partager"
|
||||
aspect_friends:
|
||||
add_friends: "ajouter des amis"
|
||||
photos: "photos"
|
||||
albums:
|
||||
album:
|
||||
you: "vous"
|
||||
|
|
@ -69,10 +79,14 @@ fr:
|
|||
friends_albums: "Albums d’amis"
|
||||
your_albums: "Vos albums"
|
||||
aspects:
|
||||
index:
|
||||
photos: "photos"
|
||||
show:
|
||||
photos: "photos"
|
||||
no_friends_message:
|
||||
nobody: "Vous avez forcément des amis, n’hésitez pas à les ramener sur Diaspora !"
|
||||
nobody_in_aspect: "Votre aspect '%{aspect_name}' est vide."
|
||||
add_friend: "Ajouter un ami"
|
||||
add_friend_to: "Ajouter quelqu’un à %{aspect_name}"
|
||||
invite: "Inviter quelqu’un à rejoindre Diaspora !"
|
||||
no_posts_message:
|
||||
start_talking: "Personne n’a encore rien dit. Commencez dès à présent la conversation !"
|
||||
manage:
|
||||
add_a_new_aspect: "Ajouter un nouvel aspect"
|
||||
add_a_new_friend: "Ajouter un nouvel ami"
|
||||
|
|
@ -90,12 +104,12 @@ fr:
|
|||
success: "%{name} a été supprimé avec succès."
|
||||
update:
|
||||
success: "Votre aspect, %{name}, a été édité avec succès."
|
||||
move_friends:
|
||||
failure: "L’édition de l’aspect concernant votre ami %{real_name} a échoué."
|
||||
success: "Les aspects ont été édités avec succès."
|
||||
move_friend:
|
||||
failure: "ne fonctionne pas %{inspect}"
|
||||
success: "Vous montrez à présent à votre ami un aspect différent au vôtre."
|
||||
success: "Personne déplacée vers le nouvel aspect"
|
||||
add_to_aspect:
|
||||
failure: "L’ajout de l’ami vers l’aspect a échoué."
|
||||
success: "Vous avez ajouté l’ami vers l’aspect avec succès."
|
||||
helper:
|
||||
remove: "supprimer"
|
||||
aspect_not_empty: "L’aspect n’est pas vide"
|
||||
|
|
@ -136,6 +150,8 @@ fr:
|
|||
photo:
|
||||
show_comments: "afficher les commentaires"
|
||||
posted_a_new_photo_to: "a publié une nouvelle photo dans"
|
||||
delete: "Supprimer"
|
||||
are_you_sure: "Êtes-vous sûr(e) ?"
|
||||
new:
|
||||
new_photo: "Nouvelle photo"
|
||||
back_to_list: "Retourner à la liste"
|
||||
|
|
@ -159,6 +175,7 @@ fr:
|
|||
sent: 'Votre invitation a été envoyée.'
|
||||
no_more: 'Vous n’avez plus d’invitation.'
|
||||
already_sent: 'Vous avez déjà invité cette personne.'
|
||||
already_friends: 'Vous êtes déjà ami avec cette personne'
|
||||
invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !'
|
||||
updated: 'Votre mot de passe a été réglé avec succès. Vous êtes à présent connecté.'
|
||||
|
||||
|
|
@ -200,6 +217,7 @@ fr:
|
|||
save: "sauver"
|
||||
are_you_sure: "Êtes-vous sûr(e) ?"
|
||||
remove_friend: "supprimer de mes amis"
|
||||
no_posts: "aucun message à afficher !"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Ajouter un nouvel ami à"
|
||||
|
|
@ -212,6 +230,9 @@ fr:
|
|||
ignore: "Requête d’ami ignorée."
|
||||
create:
|
||||
error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !"
|
||||
already_friends: "Vous êtes déjà amis avec %{destination_url}!"
|
||||
invalid_identity: "Cette identité n’est pas proprement formatée"
|
||||
error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?"
|
||||
yourself: "Vous ne pouvez pas être ami avec vous-même !"
|
||||
already_friends: "Vous êtes déjà ami avec %{destination_url}!"
|
||||
success: "Une requête d’ami a été envoyée à %{destination_url}."
|
||||
horribly_wrong: "Quelque chose d’horrible s’est produit."
|
||||
|
|
|
|||
6
config/oauth_keys.yml.example
Normal file
6
config/oauth_keys.yml.example
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
twitter:
|
||||
consumer_key: ""
|
||||
consumer_secret: ""
|
||||
facebook:
|
||||
app_id: ""
|
||||
app_secret: ""
|
||||
|
|
@ -3,34 +3,32 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
Diaspora::Application.routes.draw do
|
||||
resources :people, :only => [:index, :show, :destroy]
|
||||
resources :people
|
||||
resources :status_messages, :only => [:create, :destroy, :show]
|
||||
resources :comments, :except => [:index]
|
||||
resources :requests, :except => [:edit, :update]
|
||||
resources :photos, :except => [:index]
|
||||
resources :albums
|
||||
resources :services
|
||||
|
||||
match '/auth/:provider/callback' => 'services#create'
|
||||
|
||||
devise_for :users, :controllers => {:registrations => "registrations",
|
||||
:password => "devise/passwords",
|
||||
:invitations => "invitations"}
|
||||
:invitations => "invitations"}
|
||||
# added public route to user
|
||||
match 'public/:username', :to => 'users#public'
|
||||
match 'users/export', :to => 'users#export'
|
||||
match 'users/import', :to => 'users#import'
|
||||
match 'users/export_photos', :to => 'users#export_photos'
|
||||
resources :users, :except => [:create, :new, :show]
|
||||
resources :users, :except => [:create, :new, :show]
|
||||
|
||||
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
|
||||
match 'aspects/add_to_aspect',:to => 'aspects#add_to_aspect', :as => 'add_to_aspect'
|
||||
match 'aspects/remove_from_aspect',:to => 'aspects#remove_from_aspect', :as => 'remove_from_aspect'
|
||||
match 'aspects/manage', :to => 'aspects#manage'
|
||||
match 'aspects/public', :to => 'aspects#public'
|
||||
resources :aspects, :except => [:edit]
|
||||
|
||||
match 'services/create', :to => "services#create"
|
||||
match 'services/destroy', :to => "services#destroy"
|
||||
match 'services/fb_post', :to => "services#fb_post"
|
||||
|
||||
match 'warzombie', :to => "dev_utilities#warzombie"
|
||||
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
||||
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ module Diaspora
|
|||
end
|
||||
|
||||
def accept_friend_request(friend_request_id, aspect_id)
|
||||
request = Request.find_by_id(friend_request_id)
|
||||
pending_requests.delete(request)
|
||||
|
||||
request = pending_requests.find!(friend_request_id)
|
||||
pending_request_ids.delete(request.id.to_id)
|
||||
activate_friend(request.person, aspect_by_id(aspect_id))
|
||||
|
||||
request.reverse_for(self)
|
||||
|
|
@ -45,16 +44,16 @@ module Diaspora
|
|||
end
|
||||
|
||||
def accept_and_respond(friend_request_id, aspect_id)
|
||||
requester = Request.find_by_id(friend_request_id).person
|
||||
requester = pending_requests.find!(friend_request_id).person
|
||||
reversed_request = accept_friend_request(friend_request_id, aspect_id)
|
||||
dispatch_friend_acceptance reversed_request, requester
|
||||
end
|
||||
|
||||
def ignore_friend_request(friend_request_id)
|
||||
request = Request.find_by_id(friend_request_id)
|
||||
request = pending_requests.find!(friend_request_id)
|
||||
person = request.person
|
||||
|
||||
self.pending_requests.delete(request)
|
||||
self.pending_request_ids.delete(request.id)
|
||||
self.save
|
||||
|
||||
person.save
|
||||
|
|
|
|||
|
|
@ -25,8 +25,12 @@ $(function() {
|
|||
revert: true,
|
||||
start: function(event,ui){
|
||||
$(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200);
|
||||
$(this).children("img").tipsy("hide");
|
||||
$(".draggable_info").fadeIn(100);
|
||||
},
|
||||
drag: function(event,ui){
|
||||
$(this).children("img").tipsy("hide"); //ensure this is hidden
|
||||
},
|
||||
stop: function(event,ui){
|
||||
$(this).children("img").animate({'height':70, 'width':70, 'opacity':1},200);
|
||||
$(".draggable_info").fadeOut(100);
|
||||
|
|
@ -88,7 +92,7 @@ $(function() {
|
|||
'aspect_id' : person.attr('data-aspect_id') }
|
||||
});
|
||||
}
|
||||
person.fadeOut('slow', $(this).remove());
|
||||
person.fadeOut(400, function(){person.remove();});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ $(document).ready(function(){
|
|||
|
||||
$("img", "#left_pane").tipsy({live:true});
|
||||
$(".add_aspect_button", "#aspect_nav").tipsy({gravity:'w'});
|
||||
$(".person img", ".dropzone").tipsy({live:true});
|
||||
|
||||
});//end document ready
|
||||
|
||||
|
|
|
|||
|
|
@ -105,8 +105,12 @@ header
|
|||
:margin -2em
|
||||
:bottom 2em
|
||||
:color #000
|
||||
|
||||
:background
|
||||
:color #333
|
||||
:background -webkit-gradient( linear, left bottom, left top, color-stop(0.01, rgb(31,31,31)), color-stop(0.12, rgb(51,51,51)))
|
||||
:background -moz-linear-gradient( center bottom, rgb(31,31,31) 1%, rgb(51,51,51) 12%)
|
||||
|
||||
:padding 0
|
||||
:top 5px
|
||||
:color #CCC
|
||||
|
|
@ -855,6 +859,9 @@ h1.big_text
|
|||
:padding 4px 10px
|
||||
:color #CCC
|
||||
|
||||
:background
|
||||
:color #222
|
||||
|
||||
&:hover
|
||||
:background
|
||||
:color #000
|
||||
|
|
@ -870,7 +877,7 @@ h1.big_text
|
|||
:font
|
||||
:weight bold
|
||||
:background
|
||||
:color rgba(252,252,252,1)
|
||||
:color rgb(252,252,252)
|
||||
|
||||
:color #444
|
||||
&:hover
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ describe AlbumsController do
|
|||
end
|
||||
|
||||
it "should update the name of an album" do
|
||||
sign_in :user, @user
|
||||
put :update, :id => @album.id, :album => { :name => "new_name"}
|
||||
@album.reload.name.should eql("new_name")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,22 +6,22 @@ require 'spec_helper'
|
|||
|
||||
describe PeopleController do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
|
||||
sign_in :user, @user
|
||||
@user.aspect(:name => "lame-os")
|
||||
let(:user) { Factory(:user) }
|
||||
let!(:aspect) { user.aspect(:name => "lame-os") }
|
||||
|
||||
before do
|
||||
sign_in :user, user
|
||||
end
|
||||
|
||||
it "index should yield search results for substring of person name" do
|
||||
|
||||
eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"})
|
||||
get :index, :q => "Eu"
|
||||
assigns[:people].should include eugene
|
||||
end
|
||||
|
||||
it 'should go to the current_user show page' do
|
||||
get :show, :id => @user.person.id
|
||||
get :show, :id => user.person.id
|
||||
end
|
||||
|
||||
it "doesn't error out on an invalid id" do
|
||||
|
|
@ -29,6 +29,25 @@ describe PeopleController do
|
|||
end
|
||||
|
||||
it "doesn't error out on a nonexistent person" do
|
||||
get :show, :id => @user.id
|
||||
get :show, :id => user.id
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
context 'with a profile photo set' do
|
||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||
user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||
user.person.profile.save
|
||||
|
||||
params = {"profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => user.person.profile.last_name,
|
||||
"first_name" => user.person.profile.first_name}}
|
||||
|
||||
image_url = user.person.profile.image_url
|
||||
put("update", :id => user.person.id, "person" => params)
|
||||
|
||||
user.person.profile.image_url.should == image_url
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
48
spec/controllers/services_controller_spec.rb
Normal file
48
spec/controllers/services_controller_spec.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# 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 ServicesController do
|
||||
render_views
|
||||
let(:user) { Factory(:user) }
|
||||
let!(:aspect) { user.aspect(:name => "lame-os") }
|
||||
|
||||
let!(:service1) {a = Factory(:service); user.services << a; a}
|
||||
let!(:service2) {a = Factory(:service); user.services << a; a}
|
||||
let!(:service3) {a = Factory(:service); user.services << a; a}
|
||||
let!(:service4) {a = Factory(:service); user.services << a; a}
|
||||
|
||||
let(:mock_access_token) { Object.new }
|
||||
|
||||
let(:omniauth_auth) {{ 'provider' => 'twitter', 'uid' => '2',
|
||||
'user_info' => { 'nickname' => 'grimmin' },
|
||||
'extra' => { 'access_token' => mock_access_token }}}
|
||||
|
||||
before do
|
||||
sign_in :user, user
|
||||
mock_access_token.stub!(:token).and_return("12345")
|
||||
mock_access_token.stub!(:secret).and_return("56789")
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
it 'displays all connected serivices for a user' do
|
||||
get :index
|
||||
assigns[:services].should == user.services
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
it 'creates a new OmniauthService' do
|
||||
request.env['omniauth.auth'] = omniauth_auth
|
||||
lambda{post :create}.should change(user.services, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
it 'should destroy a service of a users with the id' do
|
||||
lambda{delete :destroy, :id => service1.id.to_s}.should change(user.services, :count).by(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -12,27 +12,40 @@ describe StatusMessagesController do
|
|||
|
||||
before do
|
||||
sign_in :user, user
|
||||
@controller.stub!(:current_user).and_return(user)
|
||||
end
|
||||
|
||||
describe '#create' do
|
||||
let(:status_message_hash) {{"status_message"=>{"public"=>"1", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}}
|
||||
|
||||
before do
|
||||
@controller.stub!(:logged_into_fb?).and_return(true)
|
||||
end
|
||||
let(:status_message_hash) {{"status_message"=>{"public"=>"true", "message"=>"facebook, is that you?", "to" =>"#{aspect.id}"}}}
|
||||
|
||||
it 'should post to facebook when public is set' do
|
||||
my_mock = mock("http")
|
||||
my_mock.stub!(:post)
|
||||
EventMachine::HttpRequest.should_receive(:new).and_return(my_mock)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
|
||||
it 'should not post to facebook when public in not set' do
|
||||
status_message_hash['status_message']['public'] = '0'
|
||||
EventMachine::HttpRequest.should_not_receive(:new)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
context "posting out to facebook" do
|
||||
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
||||
|
||||
it 'should post to facebook when public is set' do
|
||||
user.should_receive(:post_to_facebook)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
|
||||
it 'should not post to facebook when public is not set' do
|
||||
status_message_hash['status_message']['public'] = 'false'
|
||||
user.should_not_receive(:post_to_facebook)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
end
|
||||
|
||||
context "posting to twitter" do
|
||||
let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }
|
||||
|
||||
it 'should post to twitter if public is set' do
|
||||
user.should_receive(:post_to_twitter).and_return(true)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
|
||||
it 'should not post to twitter when public in not set' do
|
||||
status_message_hash['status_message']['public'] = 'false'
|
||||
user.should_not_receive(:post_to_twitter)
|
||||
post :create, status_message_hash
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,14 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe UsersController do
|
||||
|
||||
let(:user) { Factory(:user) }
|
||||
let!(:aspect) { user.aspect(:name => "lame-os") }
|
||||
|
||||
let!(:old_password) { user.encrypted_password }
|
||||
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
sign_in :user, @user
|
||||
@user.aspect(:name => "lame-os")
|
||||
sign_in :user, user
|
||||
end
|
||||
|
||||
describe '#export' do
|
||||
|
|
@ -18,67 +22,29 @@ describe UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe '#update' do
|
||||
context 'with a profile photo set' do
|
||||
before do
|
||||
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||
@user.person.profile.save
|
||||
|
||||
@params = {"profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}}
|
||||
end
|
||||
|
||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||
image_url = @user.person.profile.image_url
|
||||
put("update", :id => @user.id, "user" => @params)
|
||||
|
||||
@user.person.profile.image_url.should == image_url
|
||||
end
|
||||
it "doesn't overwrite random attributes" do
|
||||
new_user = Factory.create(:user)
|
||||
@params[:owner_id] = new_user.id
|
||||
person = @user.person
|
||||
put('update', :id => @user.id, "user" => @params)
|
||||
Person.find(person.id).owner_id.should == @user.id
|
||||
end
|
||||
it "doesn't overwrite random attributes" do
|
||||
params = {:diaspora_handle => "notreal@stuff.com"}
|
||||
proc{ put 'update', :id => user.id, "user" => params }.should_not change(user, :diaspora_handle)
|
||||
end
|
||||
|
||||
context 'should allow the user to update their password' do
|
||||
it 'should change a users password ' do
|
||||
old_password = @user.encrypted_password
|
||||
|
||||
put("update", :id => @user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
|
||||
@user.reload
|
||||
@user.encrypted_password.should_not == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz"})
|
||||
user.reload
|
||||
user.encrypted_password.should_not == old_password
|
||||
end
|
||||
|
||||
it 'should not change a password if they do not match' do
|
||||
old_password = @user.encrypted_password
|
||||
put("update", :id => @user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
@user.reload
|
||||
@user.encrypted_password.should == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same"})
|
||||
user.reload
|
||||
user.encrypted_password.should == old_password
|
||||
end
|
||||
|
||||
|
||||
it 'should not update if the password fields are left blank' do
|
||||
|
||||
old_password = @user.encrypted_password
|
||||
put("update", :id => @user.id, "user"=> {"password" => "", 'password_confirmation' => "","profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
@user.reload
|
||||
@user.encrypted_password.should == old_password
|
||||
put("update", :id => user.id, "user"=> {"password" => "", 'password_confirmation' => ""})
|
||||
user.reload
|
||||
user.encrypted_password.should == old_password
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,22 +52,19 @@ Factory.define :status_message do |m|
|
|||
m.person
|
||||
end
|
||||
|
||||
Factory.define :blog do |b|
|
||||
b.sequence(:title) {|n| "bobby's #{n} penguins"}
|
||||
b.sequence(:body) {|n| "jimmy's huge #{n} whales"}
|
||||
end
|
||||
|
||||
Factory.define :bookmark do |b|
|
||||
b.link "http://www.yahooligans.com/"
|
||||
end
|
||||
|
||||
Factory.define :post do |p|
|
||||
end
|
||||
|
||||
Factory.define :photo do |p|
|
||||
p.image File.open( File.dirname(__FILE__) + '/fixtures/button.png')
|
||||
|
||||
end
|
||||
|
||||
Factory.define :service do |service|
|
||||
service.nickname "sirrobertking"
|
||||
service.provider "twitter"
|
||||
|
||||
service.sequence(:uid) { |token| "00000#{token}" }
|
||||
service.sequence(:access_token) { |token| "12345#{token}" }
|
||||
service.sequence(:access_secret) { |token| "98765#{token}" }
|
||||
end
|
||||
|
||||
Factory.define(:comment) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,17 +31,6 @@ describe Request do
|
|||
xml.should include user.exported_key
|
||||
end
|
||||
|
||||
it 'should allow me to see only friend requests sent to me' do
|
||||
remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/")
|
||||
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => user.person, :to => remote_person.receive_url).save
|
||||
Request.instantiate(:into => aspect.id, :from => remote_person, :to => user.receive_url).save
|
||||
|
||||
Request.for_user(user).all.count.should == 1
|
||||
end
|
||||
|
||||
it 'should strip the destination url' do
|
||||
person_request = Request.new
|
||||
person_request.destination_url = " http://google.com/ "
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@ require 'spec_helper'
|
|||
describe User do
|
||||
|
||||
let!(:user) { Factory(:user) }
|
||||
let!(:user2) { Factory(:user) }
|
||||
|
||||
let!(:aspect) { user.aspect(:name => 'heroes') }
|
||||
let!(:aspect1) { user.aspect(:name => 'other') }
|
||||
|
||||
let!(:user2) { Factory(:user) }
|
||||
let!(:aspect2) { user2.aspect(:name => 'losers') }
|
||||
|
||||
let!(:service1) { s = Factory(:service, :provider => 'twitter'); user.services << s; s }
|
||||
let!(:service2) { s = Factory(:service, :provider => 'facebook'); user.services << s; s }
|
||||
|
||||
|
||||
describe '#validate_aspect_permissions' do
|
||||
it 'requires an aspect' do
|
||||
proc {
|
||||
|
|
@ -44,11 +48,26 @@ describe User do
|
|||
aspect.reload
|
||||
aspect.posts.should include album
|
||||
end
|
||||
|
||||
it "should add the post to that user's visible posts" do
|
||||
status_message = user.post :status_message, :message => "hi", :to => aspect.id
|
||||
user.reload
|
||||
user.raw_visible_posts.include?(status_message).should be true
|
||||
end
|
||||
|
||||
it "posts to services if post is public" do
|
||||
message = "hello, world!"
|
||||
user.should_receive(:post_to_twitter).with(service1, message).exactly(1).times
|
||||
user.should_receive(:post_to_facebook).with(service2, message).exactly(1).times
|
||||
user.post :status_message, :message => message, :to => "all", :public => true
|
||||
end
|
||||
|
||||
it "does not post to services if post is not public" do
|
||||
user.should_receive(:post_to_twitter).exactly(0).times
|
||||
user.should_receive(:post_to_facebook).exactly(0).times
|
||||
user.post :status_message, :message => "hi", :to => "all"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#update_post' do
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
context 'friend requesting' do
|
||||
it "should assign a request to a aspect" do
|
||||
it "should assign a request to a aspect for the user that sent it out" do
|
||||
aspect.requests.size.should == 0
|
||||
|
||||
user.send_friend_request_to(friend, aspect)
|
||||
|
|
@ -34,21 +34,42 @@ describe Diaspora::UserModules::Friending do
|
|||
aspect.requests.size.should == 1
|
||||
end
|
||||
|
||||
it "should be able to accept a pending friend request" do
|
||||
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||
r.save
|
||||
describe '#receive_friend_request' do
|
||||
it 'adds a request to pending if it was not sent by user' do
|
||||
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||
r.save
|
||||
user.receive_friend_request(r)
|
||||
user.reload.pending_requests.should include r
|
||||
end
|
||||
|
||||
it 'should autoaccept a request the user sent' do
|
||||
request = user.send_friend_request_to(user2.person, aspect)
|
||||
request.reverse_for(user2)
|
||||
proc{user.receive_friend_request(request)}.should change(user.reload.friends, :count).by(1)
|
||||
end
|
||||
|
||||
proc { user.accept_friend_request(r.id, aspect.id) }.should change {
|
||||
Request.for_user(user).all.count }.by(-1)
|
||||
end
|
||||
|
||||
it 'should be able to ignore a pending friend request' do
|
||||
friend = Factory.create(:person)
|
||||
r = Request.instantiate(:to => user.receive_url, :from => friend)
|
||||
r.save
|
||||
context 'received a friend request' do
|
||||
|
||||
proc { user.ignore_friend_request(r.id) }.should change {
|
||||
Request.for_user(user).count }.by(-1)
|
||||
let(:request_for_user) {Request.instantiate(:to => user.receive_url, :from => friend)}
|
||||
let(:request2_for_user) {Request.instantiate(:to => user.receive_url, :from => person_one)}
|
||||
before do
|
||||
request_for_user.save
|
||||
user.receive_friend_request(request_for_user)
|
||||
user.receive_friend_request(request2_for_user)
|
||||
user.reload
|
||||
end
|
||||
|
||||
it "should delete an accepted friend request" do
|
||||
proc { user.accept_friend_request(request2_for_user.id, aspect.id) }.should change(
|
||||
user.reload.pending_requests, :count ).by(-1)
|
||||
end
|
||||
|
||||
it 'should be able to ignore a pending friend request' do
|
||||
proc { user.ignore_friend_request(request_for_user.id) }.should change (
|
||||
user.reload.pending_requests, :count ).by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not be able to friend request an existing friend' do
|
||||
|
|
@ -168,20 +189,20 @@ describe Diaspora::UserModules::Friending do
|
|||
user.receive_friend_request @request
|
||||
|
||||
person_two.destroy
|
||||
user.pending_requests.size.should be 1
|
||||
user.reload.pending_requests.size.should be 1
|
||||
user.friends.size.should be 0
|
||||
|
||||
user.receive_friend_request @request_two
|
||||
user.pending_requests.size.should be 2
|
||||
user.reload.pending_requests.size.should be 2
|
||||
user.friends.size.should be 0
|
||||
|
||||
user.accept_friend_request @request.id, aspect.id
|
||||
user.pending_requests.size.should be 1
|
||||
user.reload.pending_requests.size.should be 1
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_one).should be true
|
||||
|
||||
user.ignore_friend_request @request_two.id
|
||||
user.pending_requests.size.should be 0
|
||||
user.reload.pending_requests.size.should be 0
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_two).should be false
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ ImageUploader.enable_processing = false
|
|||
|
||||
def friend_users(user1, aspect1, user2, aspect2)
|
||||
request = user1.send_friend_request_to(user2.person, aspect1)
|
||||
user2.receive_friend_request(request)
|
||||
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
||||
user1.reload
|
||||
user1.receive reversed_request.to_diaspora_xml, user2.person
|
||||
|
|
|
|||
Loading…
Reference in a new issue