diff --git a/.gitignore b/.gitignore
index 89b33da60..571cd38ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,21 @@
.bundle
+.DS_Store
.idea
+.rvmrc
*.swap
-*.swp
*.swo
+*.swp
*~
-.bundle
+bin/*
+config/app_config.yml
+config/fb_config.yml
+config/initializers/secret_token.rb
db/*.sqlite3
log/*
-tmp/**/*
+nbproject
gpg/diaspora-development/*.gpg
gpg/diaspora-production/*.gpg
gpg/*/random_seed
public/uploads/*
-.rvmrc
+public/source.tar
+tmp/**/*
diff --git a/COPYRIGHT b/COPYRIGHT
index c1e5ed876..b150ae948 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1 +1,23 @@
-Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed under the Affero General Public License version 3, the text of which can be found in GNU-AGPL-3.0, unless otherwise noted. Components of Diaspora, including Rails, JQuery, and Devise, are licensed under the MIT/X11 license. Blueprint-CSS is licensed under a modified version of the MIT/X11 license. All unmodified files from these and other sources retain their original copyright and license notices: see the relevant individual files. Attribution information for Diaspora is contained in the AUTHORS file.
+Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed
+under the Affero General Public License version 3, the text of which can
+be found in GNU-AGPL-3.0, or any later version of the AGPL, unless otherwise
+noted. Components of Diaspora, including Rails, JQuery, and Devise, are
+licensed under the MIT/X11 license. Blueprint-CSS is licensed under a
+modified version of the MIT/X11 license. All unmodified files from these
+and other sources retain their original copyright and license notices: see
+the relevant individual files. Attribution information for Diaspora is
+contained in the AUTHORS file.
+
+In addition, as a special exception, the copyright holders give
+permission to link the code of portions of this program with the
+OpenSSL library under certain conditions as described in each
+individual source file, and distribute linked combinations
+including the two.
+
+You must obey the GNU Affero General Public License V3 or later in all respects
+for all of the code used other than OpenSSL or the components mentioned
+above. If you modify file(s) with this exception, you may extend this
+exception to your version of the file(s), but you are not obligated to
+do so. If you do not wish to do so, delete this exception statement from your
+version. If you delete this exception statement from all source files in the
+program, then also delete it here.
diff --git a/Capfile b/Capfile
index af77f235a..306a9d64b 100644
--- a/Capfile
+++ b/Capfile
@@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
diff --git a/Gemfile b/Gemfile
index cc92bec3d..29ad0f73d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,15 +1,13 @@
source 'http://rubygems.org'
gem 'rails', '3.0.0'
-gem 'bundler', '1.0.0'
-
+gem 'bundler', '>= 1.0.0'
#Security
gem 'devise', :git => 'http://github.com/BadMinus/devise.git'
#Mongo
-gem 'mongo_mapper', '0.8.4', :git => 'http://github.com/jnunemaker/mongomapper.git'
-gem 'jnunemaker-validatable', '1.8.4', :git => 'http://github.com/jnunemaker/validatable.git'
+gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'bson_ext', '1.0.7'
gem 'bson', '1.0.7'
@@ -21,6 +19,7 @@ gem 'will_paginate', '3.0.pre2'
gem 'roxml', :git => 'git://github.com/Empact/roxml.git'
gem 'addressable', :require => 'addressable/uri'
gem 'json'
+gem 'mini_fb'
#Standards
gem 'pubsubhubbub'
@@ -40,24 +39,23 @@ gem 'mini_magick'
group :test, :development do
gem 'factory_girl_rails'
+ gem 'ruby-debug' if RUBY_VERSION.include? "1.8"
end
group :test do
- gem 'rspec', '>= 2.0.0.beta.17'
- gem 'rspec-rails', '2.0.0.beta.17'
+ gem 'capybara', '~> 0.3.9'
+ gem 'cucumber-rails', '0.3.2'
+ gem 'rspec', '>= 2.0.0.beta.17'
+ gem 'rspec-rails', '2.0.0.beta.17'
gem 'mocha'
- gem 'webrat', '0.7.2.beta.1'
- gem 'redgreen'
+ gem 'redgreen' if RUBY_VERSION.include? "1.8"
gem 'autotest'
gem 'database_cleaner'
- gem 'saucelabs-adapter', '= 0.8.12'
- gem 'selenium-rc'
gem 'webmock'
end
group :development do
gem 'nifty-generators'
- gem 'ruby-debug'
end
group :deployment do
diff --git a/Gemfile.lock b/Gemfile.lock
index dd181b320..44d386e33 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -57,20 +57,14 @@ GIT
GIT
remote: http://github.com/jnunemaker/mongomapper.git
- revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
+ revision: b0eac421ef5b3bee782e15d391eca372a189d414
+ branch: rails3
specs:
mongo_mapper (0.8.4)
- activesupport (>= 2.3.4)
- jnunemaker-validatable (~> 1.8.4)
+ activemodel (~> 3.0.0)
+ activesupport (~> 3.0.0)
plucky (~> 0.3.5)
-GIT
- remote: http://github.com/jnunemaker/validatable.git
- revision: 8d7c3ce14133760e748a0e34b99dfe6ec4d69153
- specs:
- jnunemaker-validatable (1.8.4)
- activesupport (>= 2.3.4)
-
GEM
remote: http://rubygems.org/
specs:
@@ -115,8 +109,24 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
+ capybara (0.3.9)
+ culerity (>= 0.2.4)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (>= 0.0.3)
columnize (0.3.1)
crack (0.1.8)
+ cucumber (0.9.0)
+ builder (~> 2.1.2)
+ diff-lcs (~> 1.1.2)
+ gherkin (~> 2.2.2)
+ json (~> 1.4.6)
+ term-ansicolor (~> 1.0.5)
+ cucumber-rails (0.3.2)
+ cucumber (>= 0.8.0)
+ culerity (0.2.12)
daemons (1.1.0)
database_cleaner (0.5.2)
diff-lcs (1.1.2)
@@ -130,18 +140,27 @@ GEM
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
+ ffi (0.6.3)
+ rake (>= 0.8.7)
+ gherkin (2.2.4)
+ json (~> 1.4.6)
+ term-ansicolor (~> 1.0.5)
+ trollop (~> 1.16.2)
haml (3.0.18)
hashie (0.4.0)
highline (1.6.1)
i18n (0.4.1)
json (1.4.6)
+ json_pure (1.4.6)
linecache (0.43)
- lsof (0.3.0)
mail (2.2.6.1)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
mime-types (1.16)
+ mini_fb (1.1.3)
+ hashie
+ rest-client
mini_magick (2.1)
subexec (~> 0.0.4)
mocha (0.9.8)
@@ -203,16 +222,13 @@ GEM
ruby-debug-base (~> 0.10.3.0)
ruby-debug-base (0.10.3)
linecache (>= 0.3)
- saucelabs-adapter (0.8.12)
- lsof (>= 0.3.0)
- net-ssh (>= 2.0.12)
- net-ssh-gateway (>= 1.0.1)
- rest-client (>= 1.2.0)
- selenium-client (>= 1.2.17)
- selenium-client (1.2.18)
- selenium-rc (2.2.4)
- selenium-client (>= 1.2.18)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.0.28)
+ ffi (>= 0.6.1)
+ json_pure
+ rubyzip
subexec (0.0.4)
+ term-ansicolor (1.0.5)
thin (1.2.7)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
@@ -220,6 +236,7 @@ GEM
thor (0.14.0)
treetop (1.4.8)
polyglot (>= 0.3.1)
+ trollop (1.16.2)
tzinfo (0.3.23)
uuidtools (2.1.1)
warden (0.10.7)
@@ -241,20 +258,22 @@ DEPENDENCIES
autotest
bson (= 1.0.7)
bson_ext (= 1.0.7)
- bundler (= 1.0.0)
+ bundler (>= 1.0.0)
+ capybara (~> 0.3.9)
carrierwave!
+ cucumber-rails (= 0.3.2)
database_cleaner
devise!
em-http-request!
em-websocket
factory_girl_rails
haml
- jnunemaker-validatable (= 1.8.4)!
json
magent!
+ mini_fb
mini_magick
mocha
- mongo_mapper (= 0.8.4)!
+ mongo_mapper!
nifty-generators
pubsubhubbub
rails (= 3.0.0)
@@ -264,10 +283,7 @@ DEPENDENCIES
rspec (>= 2.0.0.beta.17)
rspec-rails (= 2.0.0.beta.17)
ruby-debug
- saucelabs-adapter (= 0.8.12)
- selenium-rc
sprinkle!
thin
webmock
- webrat (= 0.7.2.beta.1)
will_paginate (= 3.0.pre2)
diff --git a/README.md b/README.md
index 066e4171c..bac9cd40f 100644
--- a/README.md
+++ b/README.md
@@ -1,241 +1,66 @@
-## Commit Guidlines
-You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines.
-
-We need you to fill out a [contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq) before we can accept your patches. The agreement gives Diaspora joint ownership of the patch so the copyright isn't scattered. You can find it [here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq).
-
-All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec.
-
-GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have.
-
# Diaspora
-The privacy aware, personally controlled, do-it-all, open source social network.
+The privacy aware, personally controlled, do-it-all, open source social
+network.
**DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.**
-**PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS TO BE BROKEN**
+**PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS
+TO BE BROKEN**
-Also, we really want to continue to focus on features and improving the code base. When we think it is
-ready for general use, we will post more detailed instructions.
+Initial installation instructions are [here](http://github.com/diaspora/diaspora/wiki/Installing-and-Running-Diaspora).
+We are continuing to build features and improve the code base.
+When we think it is ready for general use, we will post more final
+instructions.
+## Commit Guidlines
-These instructions are for machines running [Ubuntu](http://www.ubuntu.com/), [Fedora](http://www.fedoraproject.org) or Mac OS X. We are developing Diaspora for the latest and greatest browsers, so please update your Firefox, Chrome or Safari to the latest and greatest.
+You are welcome to contribute, add to and extend Diaspora however you see fit. We
+will do our best to incorporate everything that meets our guidelines.
-## Preparing your system
-In order to run Diaspora, you will need to download the following dependencies (specific instructions follow):
+Please make your changes on a topic branch in your repo and submit your pull request
+from there, so that commits you don't want to submit aren't included.
-- Build Tools - Packages needed to compile the components that follow.
-- [Ruby](http://www.ruby-lang.org) - The Ruby programming language. (We're using **1.8.7**. It comes preinstalled on Mac OS X.)
-- [MongoDB](http://www.mongodb.org) - A snappy noSQL database.
-- [OpenSSL](http://www.openssl.org/) - An encryption library. (It comes preinstalled on Mac OS X and Ubuntu.)
-- [ImageMagick](http://www.imagemagick.org/) - An Image processing library used to resize uploaded photos.
-- [Git](http://git-scm.com/) - The fast version control system.
+Please do not rebase our tree into yours.
+See [here](http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html)
+for when to rebase.
-After you have Ruby installed on your system, you will need to get RubyGems, then install Bundler:
+All commits must be tested, and all your tests should be green
+before a pull request is sent. Please write your tests in Rspec.
-- [RubyGems](http://rubygems.org/) - Source for Ruby gems.
-- [Bundler](http://gembundler.com/) - Gem management tool for Ruby projects.
+GEMS: We would like to keep external dependencies unduplicated. We're using
+Nokogiri, Mongomapper, and EM::HttpRequest as much as possible. We have a few
+gems in the project we'd rather not use, but if you can, use dependencies we
+already have.
-**We suggest using a package management system to download these dependencies. Trust us, it's going to make your life a lot easier. If you're using Mac OS X, you can use [homebrew](http://mxcl.github.com/homebrew/); if you're using Ubuntu, just use [Synaptic](http://www.nongnu.org/synaptic/) (it comes pre-installed); if you're using Fedora simply use [yum](http://yum.baseurl.org/). The instructions below assume you have these installed.**
-
-### Build Tools
-
-To install build tools on **Ubuntu**, run the following (includes the gcc and xml parsing dependencies):
-
- sudo apt-get install build-essential libxslt1.1 libxslt1-dev libxml2
-
-To install build tools on **Fedora**, run the following:
-
- sudo yum install libxslt libxslt-devel libxml2 libxml2-devel
-
-To install build tools on **Mac OS X**, you need to download and install [Xcode](http://developer.apple.com/technologies/tools/xcode.html).
-
-### Ruby
-
-To install Ruby 1.8.7 on **Ubuntu**, run the following command:
-
- sudo apt-get install ruby-full
-
-Please note that you need to have Universe enabled in your /etc/apt/sources.list file to install ruby using apt-get.
-
-At this time Fedora does not have Ruby 1.8.7. As a workaround it is possible to use [rvm](http://rvm.beginrescueend.com/) with a locally compiled Ruby installation. A semi automated method for doing this is available. It is highly recommended that you review the script before running it so you understand what will occur. The script can be executed by running the following command:
-
- ./script/bootstrap-fedora-diaspora.sh
-
-After reviewing and executing the above script you will need to follow the "MongoDB" section and then you should skip all the way down to "Start Mongo".
-
-
-If you're on **Mac OS X**, you already have Ruby on your system. Yay!
-
-### MongoDB
-
-To install MongoDB on **Ubuntu**, add the official MongoDB repository from this link:
-
-http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages
-
-For Lucid, add the following line to your /etc/apt/sources.list (for other distros, see http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages):
-
- deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen
-
-And then run:
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
- sudo apt-get update
- sudo apt-get install mongodb-stable
-
-You can also run the binary directly by doing the following:
-
-If you're running a 32-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz`. If you're running a 64-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz`.
-
- # extract
- tar xzf mongodb-linux-i686-1.4.0.tgz
- # create the required data directory
- sudo mkdir -p /data/db
- sudo chmod -Rv 777 /data/
-
-
-To install MongoDB on a x86_64 **Fedora** system, add the official MongoDB repository from MongoDB (http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages) into /etc/yum.repos.d/10gen.repo:
-
- [10gen]
- name=10gen Repository
- baseurl=http://downloads.mongodb.org/distros/fedora/13/os/x86_64/
- gpgcheck=0
- enabled=1
-
-
-Then use yum to install the packages:
-
- sudo yum install mongo-stable mongo-stable-server
-
-
-If you're running a 32-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.2.tgz`. If you're running a 64-bit system, run `wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.2.tgz`.
-
- # extract
- tar xzf mongodb-linux-i686-1.4.0.tgz
- # create the required data directory
- sudo mkdir -p /data/db
- sudo chmod -Rv 777 /data/
-
-
-To install MongoDB on **Mac OS X**, run the following:
-
- brew install mongo
- sudo mkdir -p /data/db
- sudo chmod -Rv 777 /data/
-
-### OpenSSL
-
-If you're running either **Ubuntu**, **Fedora** or **Mac OS X** you already have OpenSSL installed!
-
-### ImageMagick
-
-To install ImageMagick on **Ubuntu**, run the following:
-
- sudo apt-get install imagemagick libmagick9-dev
-
-To install ImageMagick on **Fedora**, run the following:
-
- sudo yum install ImageMagick
-
-To install ImageMagick on **Mac OS X**, run the following:
-
- brew install imagemagick
-
-### Git
-
-To install Git on **Ubuntu**, run the following:
-
- sudo apt-get install git-core
-
-To install Git on **Fedora**, run the following:
-
- sudo yum install git
-
-
-To install Git on **Mac OS X**, run the following:
-
- brew install git
-
-
-### Rubygems
-
-On **Ubuntu** 10.04, run the following:
-
- sudo add-apt-repository ppa:maco.m/ruby
- sudo apt-get update
- sudo apt-get install rubygems
-
-This PPA is maintained by an Ubuntu Developer. For Ubuntu 10.10, this version of rubygems is in the repositories.
-
-On **Fedora**, run the following:
-
- sudo yum install rubygems
-
-On **Mac OS X**, RubyGems comes preinstalled; however, you might need to update it for use with the latest Bundler. To update RubyGems, run `sudo gem update --system`.
-
-
-### Bundler
-
-After RubyGems is updated, simply run `sudo gem install bundler` to get Bundler. If you're using Ubuntu repository .debs, bundler is found at /var/lib/gems/1.8/bin/bundle
-
-
-## Getting Diaspora
-
- git clone http://github.com/diaspora/diaspora.git
-
-If you have never used github before, their [help desk](http://help.github.com/) has a pretty awesome guide on getting setup.
-
-
-## Running Diaspora
-
-### Install required gems
-To start the app server for the first time, you need to use Bundler to install Diaspora's gem depencencies. Run `bundle install` from Diaspora's root directory. Bundler will also warn you if there is a new dependency and you need to bundle install again.
-
-### Start Mongo
-If you installed the Ubuntu package, MongoDB should already be running (if not, run `service mongodb start`). If you installed the binary manually, run `sudo mongod` from where mongo is installed to start mongo.
-
-If you installed the Fedora package, MongoDB will need to be started via `service mongodb start`. If you installed the binary manually, run `sudo mongod` from where mongo is installed to start mongo.
-
-If you installed the OsX package through "brew", MongoDB will need to be started via `sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist`. (before you have to go to /Library/LaunchDaemons and add a symlink to /usr/local/Cellar/mongodb/1.6.2-x86_64/org.mongodb.mongod.plist)
-
-Diaspora will not run unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora.
-
-### Run the server
-`./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions.
-
-### Run the app server
-Once mongo is running and bundler has finished, run `bundle exec thin start` from the root Diaspora directory. This will start the app server in development mode[.](http://bit.ly/9mwtUw)
-
-### Run the websocket server
-run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml.
-
-### Logging in
-Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb.
-
-
-### Testing
-Diaspora's test suite uses [rspec](http://rspec.info/), a behavior driven testing framework. In order to run the tests, run `bundle exec rspec spec`.
+We need you to fill out a
+[contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq)
+before we can accept your patches. The agreement gives Diaspora joint
+ownership of the patch so the copyright isn't scattered. You can find it
+[here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq).
## Resources
-We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can file [bug reports](https://github.com/diaspora/diaspora/issues) right here on github.
+We are maintaining a
+[public tracker project](http://www.pivotaltracker.com/projects/61641)
+and a
+[roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can
+file [bug reports](https://github.com/diaspora/diaspora/issues) right here on
+github.
Ongoing discussion:
+
- [Diaspora Developer Google Group](http://groups.google.com/group/diaspora-dev)
- [Diaspora Discussion Google Group](http://groups.google.com/group/diaspora-discuss)
- [Diaspora Q&A site](http://diaspora.shapado.com/)
-- [#diaspora-dev](irc://irc.freenode.net/#diaspora-dev)
+- [#diaspora-dev IRC channel](irc://irc.freenode.net/#diaspora-dev)
+ ([join via the web client](http://webchat.freenode.net?channels=diaspora-dev))
-More general info and updates about the project can be found on our [blog](http://joindiaspora.com), [twitter](http://twitter.com/joindiaspora). Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk).
-
-If you wish to contact us privately about any exploits in Diaspora you may find, you can email [exploits@joindiaspora.com](mailto:exploits@joindiaspora.com).
-
-
-## License
-Copyright 2010 Diaspora Inc.
-
-Diaspora is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
-
-Diaspora is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License along with Diaspora. If not, see .
+More general info and updates about the project can be found on:
+[Our blog](http://joindiaspora.com),
+[and on Twitter](http://twitter.com/joindiaspora).
+Also, be sure to join the official [mailing list](http://eepurl.com/Vebk).
+If you wish to contact us privately about any exploits in Diaspora you may
+find, you can email
+[exploits@joindiaspora.com](mailto:exploits@joindiaspora.com).
diff --git a/Rakefile b/Rakefile
index c9b50786e..fa9be254a 100644
--- a/Rakefile
+++ b/Rakefile
@@ -2,12 +2,11 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
ENV['GNUPGHOME'] = File.expand_path("../../gpg/diaspora-#{Rails.env}/", __FILE__)
+
Diaspora::Application.load_tasks
diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb
index dbd59c64e..9e4859830 100644
--- a/app/controllers/albums_controller.rb
+++ b/app/controllers/albums_controller.rb
@@ -15,9 +15,12 @@ class AlbumsController < ApplicationController
end
def create
- aspect = params[:album][:to]
- @album = current_user.post(:album, params[:album])
- flash[:notice] = "You've created an album called #{@album.name}."
+ aspect = params[:album][:to]
+
+ data = clean_hash(params[:album])
+
+ @album = current_user.post(:album, data)
+ flash[:notice] = I18n.t 'albums.create.success', :name => @album.name
redirect_to :action => :show, :id => @album.id, :aspect => aspect
end
@@ -26,34 +29,43 @@ class AlbumsController < ApplicationController
end
def destroy
- @album = current_user.album_by_id params[:id]
+ @album = current_user.find_visible_post_by_id params[:id]
@album.destroy
- flash[:notice] = "Album #{@album.name} deleted."
+ flash[:notice] = I18n.t 'albums.destroy.success', :name => @album.name
respond_with :location => albums_url
end
def show
@photo = Photo.new
- @album = Album.find_by_id params[:id]
+ @album = current_user.find_visible_post_by_id( params[:id] )
@album_photos = @album.photos
-
respond_with @album
end
def edit
- @album = current_user.album_by_id params[:id]
+ @album = current_user.find_visible_post_by_id params[:id]
redirect_to @album unless current_user.owns? @album
end
def update
- @album = current_user.album_by_id params[:id]
- if @album.update_attributes params[:album]
- flash[:notice] = "Album #{@album.name} successfully edited."
+ @album = current_user.find_visible_post_by_id params[:id]
+
+ data = clean_hash(params[:album])
+
+ if current_user.update_post( @album, data )
+ flash[:notice] = I18n.t 'albums.update.success', :name => @album.name
respond_with @album
else
- flash[:error] = "Failed to edit album #{@album.name}."
+ flash[:error] = I18n.t 'albums.update.failure', :name => @album.name
render :action => :edit
end
end
+ private
+ def clean_hash(params)
+ return {
+ :name => params[:name],
+ :to => params[:to]
+ }
+ end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index f0ca5bfc8..52975730b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,13 +2,13 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class ApplicationController < ActionController::Base
protect_from_forgery :except => :receive
before_filter :set_friends_and_status, :except => [:create, :update]
before_filter :count_requests
+ before_filter :fb_user_info
layout :layout_by_resource
@@ -22,7 +22,9 @@ class ApplicationController < ActionController::Base
def set_friends_and_status
if current_user
- if params[:aspect] == nil || params[:aspect] == 'all'
+ if params[:action] == 'public'
+ @aspect = :public
+ elsif params[:aspect] == nil || params[:aspect] == 'all'
@aspect = :all
else
@aspect = current_user.aspect_by_id( params[:aspect])
@@ -37,4 +39,11 @@ class ApplicationController < ActionController::Base
@request_count = Request.for_user(current_user).size if current_user
end
+ def fb_user_info
+ if current_user
+ @access_token = warden.session[:access_token]
+ @logged_in = @access_token.present?
+ end
+ end
+
end
diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb
index ab144ad12..81056ef10 100644
--- a/app/controllers/aspects_controller.rb
+++ b/app/controllers/aspects_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class AspectsController < ApplicationController
before_filter :authenticate_user!
@@ -15,8 +14,12 @@ class AspectsController < ApplicationController
end
def create
- @aspect = current_user.aspect params[:aspect]
- flash[:notice] = "Click on the plus on the left side to tell Diaspora who can see your new aspect."
+ @aspect = current_user.aspect(params[:aspect])
+ if @aspect.valid?
+ flash[:notice] = I18n.t('aspects.create.success')
+ else
+ flash[:error] = I18n.t('aspects.create.failure')
+ end
respond_with :location => aspects_manage_path
end
@@ -25,11 +28,11 @@ class AspectsController < ApplicationController
end
def destroy
- @aspect = Aspect.find_by_id params[:id]
+ @aspect = current_user.aspect_by_id params[:id]
begin
current_user.drop_aspect @aspect
- flash[:notice] = "#{@aspect.name} was successfully removed."
+ flash[:notice] = I18n.t 'aspects.destroy.success',:name => @aspect.name
rescue RuntimeError => e
flash[:error] = e.message
end
@@ -38,22 +41,33 @@ class AspectsController < ApplicationController
end
def show
- @aspect = Aspect.find_by_id params[:id]
+ @aspect = current_user.aspect_by_id params[:id]
@friends = @aspect.people
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
respond_with @aspect
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 = Request.for_user(current_user).all
end
def update
- @aspect = Aspect.find_by_id(params[:id])
- @aspect.update_attributes(params[:aspect])
- flash[:notice] = "Your aspect, #{@aspect.name}, has been successfully edited."
+ @aspect = current_user.aspect_by_id(params[:id])
+
+ data = clean_hash(params[:aspect])
+ @aspect.update_attributes( data )
+ flash[:notice] = I18n.t 'aspects.update.success',:name => @aspect.name
respond_with @aspect
end
@@ -61,26 +75,34 @@ class AspectsController < ApplicationController
params[:moves].each{ |move|
move = move[1]
unless current_user.move_friend(move)
- flash[:error] = "Aspect editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}."
- redirect_to Aspect.first, :action => "edit"
+ flash[:error] = I18n.t 'aspects.move_friends.failure', :real_name => Person.find_by_id( move[:friend_id] ).real_name
+ redirect_to aspects_manage_path
return
end
}
- flash[:notice] = "Aspects edited successfully."
- redirect_to Aspect.first, :action => "edit"
+ flash[:notice] = I18n.t 'aspects.move_friends.success'
+ redirect_to aspects_manage_path
end
def move_friend
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
- flash[:error] = "didn't work #{params.inspect}"
+ flash[:error] = I18n.t 'aspects.move_friend.error',:inspect => params.inspect
end
- if aspect = Aspect.first(:id => params[:to][:to])
- flash[:notice] = "You are now showing your friend a different aspect of yourself."
- respond_with aspect
+ if aspect = current_user.aspect_by_id(params[:to][:to])
+ flash[:notice] = I18n.t 'aspects.move_friend.success'
+ render :nothing => true
else
- flash[:notice] = "You are now showing your friend a different aspect of yourself."
- respond_with Person.first(:id => params[:friend_id])
+ flash[:notice] = I18n.t 'aspects.move_friend.failure'
+ render aspects_manage_path
end
end
+
+ private
+ def clean_hash(params)
+ return {
+ :name => params[:name]
+ }
+ end
+
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index dc115ab5b..d1efc3e10 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class CommentsController < ApplicationController
before_filter :authenticate_user!
@@ -10,16 +9,11 @@ class CommentsController < ApplicationController
respond_to :json, :only => :show
def create
- target = Post.find_by_id params[:comment][:post_id]
+ target = current_user.find_visible_post_by_id params[:comment][:post_id]
text = params[:comment][:text]
@comment = current_user.comment text, :on => target
render :nothing => true
end
- def show
- @comment = Comment.find_by_id params[:id]
- respond_with @comment
- end
-
end
diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb
index bcb0dd4f7..e8a40a4c2 100644
--- a/app/controllers/dev_utilities_controller.rb
+++ b/app/controllers/dev_utilities_controller.rb
@@ -2,29 +2,10 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class DevUtilitiesController < ApplicationController
before_filter :authenticate_user!, :except => [:set_backer_number]
include ApplicationHelper
include RequestsHelper
-def warzombie
- render :nothing => true
- if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
- current_user.post(:status_message, :message => "There's a bomb in the lasagna!?")
- current_user.post(:status_message, :message => "xkcd \nhttp://xkcd.com/743/" )
- current_user.post(:status_message, :message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :created_at => Time.now-930)
- current_user.post(:status_message, :message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :created_at => Time.now-43990)
- current_user.post(:status_message, :message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :created_at => Time.now-4390)
- current_user.post(:status_message, :message => "Reddit\nhttp://reddit.com", :created_at => Time.now-54390)
- current_user.post(:status_message, :message => "Commercials for IE make me SO MAD and my friends just don't get why.", :created_at => Time.now-30900)
- current_user.post(:status_message, :message => "Zombo.com\nhttp://zombo.com", :created_at => Time.now-9090)
- current_user.post(:status_message, :message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :created_at => Time.now-590000)
- current_user.post(:status_message, :message => "Mmm. Friday night. Acknowledged.", :created_at => Time.now-503900)
- current_user.post(:status_message, :message => "Getting a universal remote is the epitome of laziness, I do declare.", :created_at => Time.now-4400)
- current_user.post(:status_message, :message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :created_at => Time.now-400239)
- current_user.post(:status_message, :message => "A cool, cool morning for once.", :created_at => Time.now-150000)
- end
- end
def zombiefriends
render :nothing => true
@@ -34,7 +15,7 @@ def warzombie
bkr_info.each do |backer|
backer_email = "#{backer['username']}@#{backer['username']}.joindiaspora.com"
rel_hash = relationship_flow(backer_email)
- logger.info "Zombefriending #{backer['given_name']} #{backer['family_name']}"
+ logger.info "Zombiefriending #{backer['given_name']} #{backer['family_name']}"
logger.info "Calling send_friend_request with #{rel_hash[:friend]} and #{current_user.aspects.first}"
current_user.send_friend_request_to(rel_hash[:friend], current_user.aspects.first)
end
@@ -48,11 +29,6 @@ def warzombie
}
end
- def backer_info
- config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
- config['servers']['backer']
- end
-
def set_backer_number
render :nothing => true
seed_num_hash = {:seed_number => params[:number]}
@@ -62,7 +38,6 @@ def warzombie
end
def set_profile_photo
-
render :nothing => true
album = Album.create(:person => current_user.person, :name => "Profile Photos")
current_user.raw_visible_posts << album
@@ -71,7 +46,7 @@ def warzombie
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
- @fixture_name = File.dirname(__FILE__) + "/../../public/images/user/#{username}.jpg"
+ @fixture_name = File.join(File.dirname(__FILE__), "..", "..", "public", "images", "user", "#{username}.jpg")
photo = Photo.new(:person => current_user.person, :album => album)
photo.image.store! File.open(@fixture_name)
@@ -81,7 +56,6 @@ def warzombie
current_user.raw_visible_posts << photo
current_user.save
-
current_user.update_profile(:image_url => photo.url(:thumb_medium))
current_user.save
end
@@ -91,4 +65,11 @@ def warzombie
render "shared/log"
end
+
+ protected
+
+ def backer_info
+ config = YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "config", "deploy_config.yml"))
+ config['servers']['backer']
+ end
end
diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb
index d85c67691..be1f89991 100644
--- a/app/controllers/people_controller.rb
+++ b/app/controllers/people_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class PeopleController < ApplicationController
before_filter :authenticate_user!
@@ -22,7 +21,7 @@ class PeopleController < ApplicationController
@profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
- @posts = current_user.visible_posts_from_others(:from => @person).paginate :page => params[:page], :order => 'created_at DESC'
+ @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
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index cefc8f5d6..dca510374 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class PhotosController < ApplicationController
before_filter :authenticate_user!
@@ -10,8 +9,7 @@ class PhotosController < ApplicationController
respond_to :json, :only => :show
def create
-
- album = Album.find_by_id params[:album_id]
+ album = current_user.find_visible_post_by_id( params[:album_id] )
begin
@@ -21,9 +19,15 @@ class PhotosController < ApplicationController
# get file content type
att_content_type = (request.content_type.to_s == "") ? "application/octet-stream" : request.content_type.to_s
# create temporal file
- file = Tempfile.new(file_name)
+ begin
+ file = Tempfile.new(file_name, {:encoding => 'BINARY'})
+ file.print request.raw_post.force_encoding('BINARY')
+ rescue RuntimeError => e
+ raise e unless e.message.include?('cannot generate tempfile')
+ file = Tempfile.new(file_name) # Ruby 1.8 compatibility
+ file.print request.raw_post
+ end
# put data into this file from raw post request
- file.print request.raw_post
# create several required methods for this temporal file
Tempfile.send(:define_method, "content_type") {return att_content_type}
@@ -31,24 +35,26 @@ class PhotosController < ApplicationController
##############
-
params[:user_file] = file
- @photo = current_user.post(:photo, params)
+
+ data = clean_hash(params)
+
+ @photo = current_user.post(:photo, data)
respond_to do |format|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end
rescue TypeError
- message = "Photo upload failed. Are you sure an image was added?"
+ message = I18n.t 'photos.create.type_error'
respond_with :location => album, :error => message
rescue CarrierWave::IntegrityError
- message = "Photo upload failed. Are you sure that was an image?"
+ message = I18n.t 'photos.create.integrity_error'
respond_with :location => album, :error => message
rescue RuntimeError => e
- message = "Photo upload failed. Are you sure that your seatbelt is fastened?"
+ message = I18n.t 'photos.create.runtime_error'
respond_with :location => album, :error => message
raise e
end
@@ -61,34 +67,54 @@ class PhotosController < ApplicationController
end
def destroy
- @photo = Photo.find_by_id params[:id]
+ @photo = current_user.find_visible_post_by_id params[:id]
+
@photo.destroy
- flash[:notice] = "Photo deleted."
+ flash[:notice] = I18n.t 'photos.destroy.notice'
respond_with :location => @photo.album
end
def show
- @photo = Photo.find_by_id params[:id]
+ @photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album
-
respond_with @photo, @album
end
def edit
- @photo = Photo.find_by_id params[:id]
+ @photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album
redirect_to @photo unless current_user.owns? @album
end
def update
- @photo = Photo.find_by_id params[:id]
- if @photo.update_attributes params[:photo]
- flash[:notice] = "Photo successfully updated."
+ @photo = current_user.find_visible_post_by_id params[:id]
+
+ data = clean_hash(params)
+
+ if current_user.update_post( @photo, data[:photo] )
+ flash[:notice] = I18n.t 'photos.update.notice'
respond_with @photo
else
- flash[:error] = "Failed to edit photo."
+ flash[:error] = I18n.t 'photos.update.error'
render :action => :edit
end
end
+
+ private
+ def clean_hash(params)
+ if params[:photo]
+ return {
+ :photo => {
+ :caption => params[:photo][:caption],
+ }
+ }
+ else
+ return{
+ :album_id => params[:album_id],
+ :user_file => params[:user_file]
+ }
+ end
+ end
+
end
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index 6f2b09c43..f57b94540 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -2,15 +2,14 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class PublicsController < ApplicationController
- require 'lib/diaspora/parser'
+ require File.expand_path('../../../lib/diaspora/parser', __FILE__)
include Diaspora::Parser
+
layout false
def hcard
@person = Person.find_by_id params[:id]
- puts @person
unless @person.nil? || @person.owner.nil?
render 'hcard'
end
@@ -21,7 +20,7 @@ class PublicsController < ApplicationController
end
def webfinger
- @person = Person.by_webfinger(params[:q], :local => true)
+ @person = Person.by_webfinger(params[:q], :local => true) if params[:q]
unless @person.nil? || @person.owner.nil?
render 'webfinger', :content_type => 'application/xrd+xml'
else
@@ -29,13 +28,20 @@ class PublicsController < ApplicationController
end
end
+ def hub
+ if params['hub.mode'] == 'subscribe' || params['hub.mode'] == 'unsubscribe'
+ render :text => params['hub.challenge'], :status => 202, :layout => false
+ end
+ end
+
def receive
render :nothing => true
return unless params[:xml]
begin
- @user = Person.first(:id => params[:id]).owner
+ person = Person.first(:id => params[:id])
+ @user = person.owner
rescue NoMethodError => e
- Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
+ Rails.logger.error("Received post for nonexistent person #{params[:id]}")
return
end
@user.receive_salmon params[:xml]
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 8241aa294..b630c6617 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -15,9 +15,7 @@ class RegistrationsController < Devise::RegistrationsController
flash[:error] = e.message
end
if user
- #set_flash_message :notice, :signed_up
- flash[:notice] = "You've joined Diaspora!"
- #redirect_to root_url
+ flash[:notice] = I18n.t 'registrations.create.success'
sign_in_and_redirect(:user, user)
else
redirect_to new_user_registration_path
diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb
index 6087ebe85..31c6e6efd 100644
--- a/app/controllers/requests_controller.rb
+++ b/app/controllers/requests_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class RequestsController < ApplicationController
before_filter :authenticate_user!
include RequestsHelper
@@ -13,15 +12,15 @@ class RequestsController < ApplicationController
if params[:accept]
if params[:aspect_id]
@friend = current_user.accept_and_respond( params[:id], params[:aspect_id])
- flash[:notice] = "You are now friends."
+ flash[:notice] = I18n.t 'requests.destroy.success'
respond_with :location => current_user.aspect_by_id(params[:aspect_id])
else
- flash[:error] = "Please select an aspect!"
+ flash[:error] = I18n.t 'requests.destroy.error'
respond_with :location => requests_url
end
else
current_user.ignore_friend_request params[:id]
- flash[:notice] = "Ignored friend request."
+ flash[:notice] = I18n.t 'requests.destroy.ignore'
respond_with :location => requests_url
end
end
@@ -37,27 +36,28 @@ class RequestsController < ApplicationController
rel_hash = relationship_flow(params[:request][:destination_url])
rescue Exception => e
raise e unless e.message.include? "not found"
- flash[:error] = "No diaspora seed found with this email!"
+ flash[:error] = I18n.t 'requests.create.error'
respond_with :location => aspect
return
end
+ # rel_hash = {:friend => params[:friend_handle]}
Rails.logger.debug("Sending request: #{rel_hash}")
begin
@request = current_user.send_friend_request_to(rel_hash[:friend], aspect)
rescue Exception => e
- raise e unless e.message.include? "already friends"
- flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!"
+ raise e unless e.message.include? "already"
+ flash[:notice] = I18n.t 'requests.create.already_friends', :destination_url => params[:request][:destination_url]
respond_with :location => aspect
return
end
if @request
- flash[:notice] = "A friend request was sent to #{@request.destination_url}."
+ flash[:notice] = I18n.t 'requests.create.success',:destination_url => @request.destination_url
respond_with :location => aspect
else
- flash[:error] = "Something went horribly wrong."
+ flash[:error] = I18n.t 'requests.create.horribly_wrong'
respond_with :location => aspect
end
end
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
new file mode 100644
index 000000000..82a58c508
--- /dev/null
+++ b/app/controllers/services_controller.rb
@@ -0,0 +1,40 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3. See
+# the COPYRIGHT file.
+
+
+class ServicesController < ApplicationController
+
+ def create
+ puts 'services/create'
+ p params
+
+ 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"]
+
+ # 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."
+ end
+ redirect_to edit_user_url current_user
+ end
+
+ def destroy
+ warden.session[:access_token] = nil
+ warden.session[:user_id] = nil
+ redirect_to edit_user_url current_user
+ 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
diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb
index 9b90ea831..88d8e6b40 100644
--- a/app/controllers/sockets_controller.rb
+++ b/app/controllers/sockets_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class SocketsController < ApplicationController
include ApplicationHelper
include SocketsHelper
diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb
index 5a588fb99..137dd8a7e 100644
--- a/app/controllers/status_messages_controller.rb
+++ b/app/controllers/status_messages_controller.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class StatusMessagesController < ApplicationController
before_filter :authenticate_user!
@@ -11,18 +10,39 @@ class StatusMessagesController < ApplicationController
def create
params[:status_message][:to] = params[:aspect_ids]
- @status_message = current_user.post(:status_message, params[:status_message])
- respond_with @status_message
+
+ data = clean_hash params[:status_message]
+
+ if @logged_in && params[:status_message][:public] == 'true'
+ id = 'me'
+ type = 'feed'
+
+ Rails.logger.info("Sending a message: #{params[:status_message][:message]} to Facebook")
+ @res = MiniFB.post(@access_token, id, :type=>type,
+ :metadata=>true, :params=>{:message => params[:status_message][:message]})
+ end
+
+ @status_message = current_user.post(:status_message, data)
+ render :nothing => true
end
def destroy
- @status_message = StatusMessage.find_by_id params[:id]
+ @status_message = current_user.find_visible_post_by_id params[:id]
@status_message.destroy
respond_with :location => root_url
end
def show
- @status_message = StatusMessage.find_by_id params[:id]
+ @status_message = current_user.find_visible_post_by_id params[:id]
respond_with @status_message
end
+
+ private
+ def clean_hash(params)
+ return {
+ :message => params[:message],
+ :to => params[:to],
+ :public => params[:public]
+ }
+ end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 72666bc30..9b41b1fc9 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2,34 +2,83 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class UsersController < ApplicationController
- before_filter :authenticate_user!, :except => [:new, :create]
+ require File.expand_path('../../../lib/diaspora/ostatus_builder', __FILE__)
+
+ before_filter :authenticate_user!, :except => [:new, :create, :public]
respond_to :html
def edit
@user = current_user
@person = @user.person
- @profile = @user.profile
- @photos = Photo.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC'
+ @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(","))
end
def update
@user = current_user
- prep_image_url(params[:user])
+ data = clean_hash params[:user]
+ prep_image_url(data)
- @user.update_profile params[:user]
- respond_with(@user, :location => root_url)
+
+ params[:user].delete(:password) if params[:user][:password].blank?
+ params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
+
+ if params[:user][:password] && params[:user][:password_confirmation]
+ if @user.update_attributes(:password => params[:user][:password], :password_confirmation => params[:user][:password_confirmation])
+ flash[:notice] = "Password Changed"
+ else
+ flash[:error] = "Password Change Failed"
+ end
+
+ end
+
+ @user.update_profile data
+ redirect_to edit_user_path(@user)
+
+ end
+
+ def public
+ user = User.find_by_username(params[:username])
+
+ if user
+ director = Diaspora::Director.new
+ ostatus_builder = Diaspora::OstatusBuilder.new(user)
+
+ render :xml => director.build(ostatus_builder), :content_type => 'application/atom+xml'
+ else
+ flash[:error] = "User #{params[:username]} does not exist!"
+ redirect_to root_url
+ end
end
private
-
def prep_image_url(params)
+ url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
if params[:profile][:image_url].empty?
params[:profile].delete(:image_url)
else
- params[:profile][:image_url] = "http://" + request.host + ":" + request.port.to_s + params[:profile][:image_url]
+ 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
+
+ def clean_hash(params)
+ return {
+ :profile =>
+ {
+ :first_name => params[:profile][:first_name],
+ :last_name => params[:profile][:last_name],
+ :image_url => params[:profile][:image_url]
+ }
+ }
+ end
+
end
diff --git a/app/helpers/albums_helper.rb b/app/helpers/albums_helper.rb
index 50b7fbaf7..6d85c747c 100644
--- a/app/helpers/albums_helper.rb
+++ b/app/helpers/albums_helper.rb
@@ -2,21 +2,20 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module AlbumsHelper
def friends_albums_link
if params[:friends]
- "Friends Albums"
+ I18n.t('albums.helper.friends_albums')
else
- link_to 'Friends Albums', albums_path({:friends => true})
+ link_to I18n.t('albums.helper.friends_albums'), albums_path({:friends => true})
end
end
def your_albums_link
if params[:friends]
- link_to 'Your Albums', albums_path
+ link_to I18n.t('albums.helper.your_albums'), albums_path
else
- 'Your Albums'
+ I18n.t('albums.helper.your_albums')
end
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index f2a0a95fd..7745ace96 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module ApplicationHelper
-
def current_aspect?(aspect)
!@aspect.is_a?(Symbol) && @aspect.id == aspect.id
end
@@ -28,7 +26,7 @@ module ApplicationHelper
end
def how_long_ago(obj)
- "#{time_ago_in_words(obj.created_at)} ago."
+ "#{time_ago_in_words(obj.created_at)} ago"
end
def person_url(person)
@@ -38,16 +36,16 @@ module ApplicationHelper
when "Person"
person_path(person)
else
- "unknown person"
+ I18n.t('application.helper.unknown_person')
end
end
def owner_image_tag
- person_image_tag(current_user)
+ person_image_tag(current_user.person)
end
def owner_image_link
- person_image_link(current_user)
+ person_image_link(current_user.person)
end
def person_image_tag(person)
@@ -62,11 +60,15 @@ module ApplicationHelper
end
def new_request(request_count)
- "new_requests" if request_count > 0
+ I18n.t('application.helper.new_requests') if request_count > 0
end
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
diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb
index 1c8f69b8a..66baffca2 100644
--- a/app/helpers/aspects_helper.rb
+++ b/app/helpers/aspects_helper.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module AspectsHelper
def link_for_aspect( aspect )
link_to aspect.name, aspect
@@ -10,9 +9,9 @@ module AspectsHelper
def remove_link( aspect )
if aspect.people.size == 0
- link_to "remove", aspect, :method => :delete
+ link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete
else
- "remove"
+ "#{I18n.t('aspects.helper.remove')}"
end
end
end
diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb
index 542d938ee..e8a9d8f71 100644
--- a/app/helpers/dashboards_helper.rb
+++ b/app/helpers/dashboards_helper.rb
@@ -2,10 +2,8 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module DashboardsHelper
-
def title_for_page
- 'home'
+ I18n.t('dashboards.helper.home')
end
end
diff --git a/app/helpers/error_messages_helper.rb b/app/helpers/error_messages_helper.rb
index 699070b70..9a64dca36 100644
--- a/app/helpers/error_messages_helper.rb
+++ b/app/helpers/error_messages_helper.rb
@@ -2,13 +2,12 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
- options[:header_message] ||= "Invalid Fields"
- options[:message] ||= "Correct the following errors and try again."
+ options[:header_message] ||= I18n.t('error_messages.helper.invalid_fields')
+ options[:message] ||= I18n.t('error_messages.helper.correct_the_following_errors_and_try_again')
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
unless messages.empty?
content_tag(:div, :class => "error_messages") do
diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb
index 2398771a3..e33556c35 100644
--- a/app/helpers/layout_helper.rb
+++ b/app/helpers/layout_helper.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
# These helper methods can be called in your template to set variables to be used in the layout
# This module should be included in all views globally,
# to do so you may need to add this line to your ApplicationController
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
index 37d18d20f..f1fa6487f 100644
--- a/app/helpers/people_helper.rb
+++ b/app/helpers/people_helper.rb
@@ -2,14 +2,13 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module PeopleHelper
def search_or_index
if params[:q]
- " results for #{params[:q]}"
+ I18n.t 'people.helper.results_for',:params => params[:q]
else
- " people on pod is aware of"
+ I18n.t "people.helper.people_on_pod_are_aware_of"
end
end
diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb
index 2d0ddad6e..1f52daa0c 100644
--- a/app/helpers/photos_helper.rb
+++ b/app/helpers/photos_helper.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module PhotosHelper
-
def linked_scaled_photo(photo, album)
link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
end
diff --git a/app/helpers/publics_helper.rb b/app/helpers/publics_helper.rb
index 9e76f59f7..f14fad7a6 100644
--- a/app/helpers/publics_helper.rb
+++ b/app/helpers/publics_helper.rb
@@ -2,14 +2,12 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module PublicsHelper
def subscribe(opts = {})
subscriber = Subscriber.first(:url => opts[:callback], :topic => opts[:topic])
subscriber ||= Subscriber.new(:url => opts[:callback], :topic => opts[:topic])
if subscriber.save
-
if opts[:verify] == 'sync'
204
elsif opts[:verify] == 'async'
diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb
index 32ce79fd9..98ccc8f75 100644
--- a/app/helpers/requests_helper.rb
+++ b/app/helpers/requests_helper.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module RequestsHelper
-
def subscription_mode(profile)
if diaspora?(profile)
:friend
@@ -39,5 +37,4 @@ module RequestsHelper
end
{ action => person }
end
-
end
diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb
index cbe465e7b..892e15f59 100644
--- a/app/helpers/sockets_helper.rb
+++ b/app/helpers/sockets_helper.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module SocketsHelper
include ApplicationHelper
@@ -33,7 +32,4 @@ module SocketsHelper
action_hash.to_json
end
-
-
-
end
diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb
index ff6c2674a..08461b635 100644
--- a/app/helpers/status_messages_helper.rb
+++ b/app/helpers/status_messages_helper.rb
@@ -2,13 +2,12 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
module StatusMessagesHelper
def my_latest_message
unless @latest_status_message.nil?
return @latest_status_message.message
else
- return "No message to display."
+ return I18n.t('status_messages.helper.no_message_to_display')
end
end
end
diff --git a/app/models/album.rb b/app/models/album.rb
index 10737bdfa..f62cbdb79 100644
--- a/app/models/album.rb
+++ b/app/models/album.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Album < Post
xml_reader :name
@@ -17,7 +16,6 @@ class Album < Post
before_destroy :destroy_photos
-
def self.mine_or_friends(friend_param, current_user)
friend_param ? Album.find_all_by_person_id(current_user.friend_ids) : current_user.person.albums
end
diff --git a/app/models/aspect.rb b/app/models/aspect.rb
index 96f94e8fe..10f7aba14 100644
--- a/app/models/aspect.rb
+++ b/app/models/aspect.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Aspect
include MongoMapper::Document
@@ -39,5 +38,6 @@ class Aspect
}
}
end
+
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 3fa986503..4bf0dbd5e 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Comment
include MongoMapper::Document
include ROXML
@@ -19,7 +18,6 @@ class Comment
key :post_id, ObjectId
key :person_id, ObjectId
-
belongs_to :post, :class_name => "Post"
belongs_to :person, :class_name => "Person"
diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb
new file mode 100644
index 000000000..40d9cb16e
--- /dev/null
+++ b/app/models/fb_status.rb
@@ -0,0 +1,31 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3. See
+# the COPYRIGHT file.
+
+
+class FbStatus
+ include MongoMapper::Document
+
+ key :graph_id, String
+ key :author_id, String
+ key :author_name, String
+ key :message, String
+ key :updated_time, Time
+
+ timestamps!
+
+ validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time
+
+ def self.from_api(hash)
+ #just keeping them in memory for now
+ self.new(
+ :graph_id => hash['id'],
+ :author_id => hash['from']['id'],
+ :author_name => hash['from']['name'],
+ :message => hash['message'],
+ :updated_time => Time.parse(hash['updated_time'])
+ )
+ end
+
+end
+
diff --git a/app/models/person.rb b/app/models/person.rb
index 1e2a7b18d..8d1fee5d5 100644
--- a/app/models/person.rb
+++ b/app/models/person.rb
@@ -2,8 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-require 'lib/hcard'
+require File.expand_path('../../../lib/hcard', __FILE__)
class Person
include MongoMapper::Document
@@ -18,7 +17,7 @@ class Person
key :url, String
key :diaspora_handle, String, :unique => true
- key :serialized_key, String
+ key :serialized_public_key, String
key :owner_id, ObjectId
@@ -30,15 +29,13 @@ class Person
before_destroy :remove_all_traces
before_validation :clean_url
- validates_presence_of :url, :profile, :serialized_key
+ validates_presence_of :url, :profile, :serialized_public_key
validates_format_of :url, :with =>
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
-
def self.search(query)
- Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) ||
- this.profile.first_name.match(/^#{query}/i) ||
- this.profile.last_name.match(/^#{query}/i); }")
+ query = Regexp.escape( query.to_s.strip )
+ Person.all('profile.first_name' => /^#{query}/i) | Person.all('profile.last_name' => /^#{query}/i)
end
def real_name
@@ -52,36 +49,34 @@ class Person
"#{self.url}receive/users/#{self.id}/"
end
- def encryption_key
- OpenSSL::PKey::RSA.new( serialized_key )
+ def public_url
+ "#{self.url}public/#{self.owner.username}"
end
- def encryption_key= new_key
- raise TypeError unless new_key.class == OpenSSL::PKey::RSA
- serialized_key = new_key.export
- end
def public_key_hash
Base64.encode64 OpenSSL::Digest::SHA256.new(self.exported_key).to_s
end
def public_key
- encryption_key.public_key
+ OpenSSL::PKey::RSA.new( serialized_public_key )
end
def exported_key
- encryption_key.public_key.export
+ serialized_public_key
end
def exported_key= new_key
- raise "Don't change a key" if serialized_key
- @serialized_key = new_key
+ raise "Don't change a key" if serialized_public_key
+ @serialized_public_key = new_key
end
def self.by_webfinger( identifier, opts = {})
- local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', ''))
+ #need to check if this is a valid email structure, maybe should do in JS
+ local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', '').to_s.downcase)
if local_person
+ Rails.logger.info("Do not need to webfinger, found a local person #{local_person.real_name}")
local_person
elsif !identifier.include?("localhost") && !opts[:local]
begin
@@ -101,11 +96,11 @@ class Person
new_person = Person.new
public_key_entry = profile.links.select{|x| x.rel == 'diaspora-public-key'}
-
+
return nil unless public_key_entry
-
- public_key = public_key_entry.first.href
- new_person.exported_key = Base64.decode64 public_key
+
+ pubkey = public_key_entry.first.href
+ new_person.exported_key = Base64.decode64 pubkey
guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href
new_person.id = guid
@@ -115,7 +110,7 @@ class Person
hcard = HCard.find profile.hcard.first[:href]
new_person.url = hcard[:url]
- new_person.profile = Profile.new(:first_name => hcard[:given_name], :last_name => hcard[:family_name])
+ new_person.profile = Profile.new(:first_name => hcard[:given_name], :last_name => hcard[:family_name], :image_url => hcard[:photo])
if new_person.save
new_person
else
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 8792911f3..15d105739 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -2,7 +2,13 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
+class PhotoAlbumValidator < ActiveModel::Validator
+ def validate(document)
+ unless document.album.person_id == document.person_id
+ document.errors[:base] << "You post photos to that album"
+ end
+ end
+end
class Photo < Post
require 'carrierwave/orm/mongomapper'
include MongoMapper::Document
@@ -22,7 +28,7 @@ class Photo < Post
timestamps!
validates_presence_of :album
- validates_true_for :album_id, :logic => lambda {self.validate_album_person}
+ validates_with PhotoAlbumValidator
before_destroy :ensure_user_picture
@@ -36,10 +42,6 @@ class Photo < Post
photo
end
- def validate_album_person
- album.person_id == person_id
- end
-
def remote_photo
image.url.nil? ? (remote_photo_path + '/' + remote_photo_name) : image.url
end
@@ -70,3 +72,4 @@ class Photo < Post
{:thumb_url => url(:thumb_medium), :id => id, :album_id => album_id}
end
end
+
diff --git a/app/models/post.rb b/app/models/post.rb
index e9e135abb..aba822160 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -2,10 +2,9 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Post
- require 'lib/diaspora/websocket'
- require 'lib/encryptable'
+ require File.expand_path('../../../lib/encryptable', __FILE__)
+ require File.expand_path('../../../lib/diaspora/websocket', __FILE__)
include MongoMapper::Document
include ApplicationHelper
include ROXML
@@ -14,6 +13,9 @@ class Post
xml_accessor :_id
xml_accessor :person, :as => Person
+ xml_reader :public
+
+ key :public , Boolean, :default => false
key :person_id, ObjectId
key :user_refs, Integer, :default => 0
@@ -33,7 +35,6 @@ class Post
self.create params.to_hash
end
-
def as_json(opts={})
{
:post => {
diff --git a/app/models/profile.rb b/app/models/profile.rb
index f03843226..2b8303bd1 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -2,10 +2,9 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Profile
include MongoMapper::EmbeddedDocument
- require 'lib/diaspora/webhooks'
+ require File.expand_path('../../../lib/diaspora/webhooks', __FILE__)
include Diaspora::Webhooks
include ROXML
diff --git a/app/models/request.rb b/app/models/request.rb
index da62edd93..5ba4769a2 100644
--- a/app/models/request.rb
+++ b/app/models/request.rb
@@ -2,9 +2,8 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Request
- require 'lib/diaspora/webhooks'
+ require File.expand_path('../../../lib/diaspora/webhooks', __FILE__)
include MongoMapper::Document
include Diaspora::Webhooks
include ROXML
@@ -26,8 +25,8 @@ class Request
validates_presence_of :destination_url, :callback_url
before_validation :clean_link
- scope :for_user, lambda{ |user| where(:destination_url => user.receive_url) }
- scope :from_user, lambda{ |user| where(:destination_url.ne => user.receive_url) }
+ scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) }
+ scope :from_user, lambda{ |user| where(:destination_url.ne => user.person.receive_url) }
def self.instantiate(options = {})
person = options[:from]
diff --git a/app/models/retraction.rb b/app/models/retraction.rb
index 9c1f13f45..20f74bf29 100644
--- a/app/models/retraction.rb
+++ b/app/models/retraction.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class Retraction
include ROXML
include Diaspora::Webhooks
diff --git a/app/models/status_message.rb b/app/models/status_message.rb
index f75536205..b509bfe5a 100644
--- a/app/models/status_message.rb
+++ b/app/models/status_message.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class StatusMessage < Post
xml_name :status_message
@@ -11,16 +10,16 @@ class StatusMessage < Post
key :message, String
validates_presence_of :message
-
def to_activity
<<-XML
- http://activitystrea.ms/schema/1.0/post
- #{self.message}
-
- #{person.url}status_messages/#{self.id}
- #{self.created_at.xmlschema}
- #{self.updated_at.xmlschema}
+ #{self.message}
+
+ #{person.url}status_messages/#{self.id}
+ #{self.created_at.xmlschema}
+ #{self.updated_at.xmlschema}
+ http://activitystrea.ms/schema/1.0/post
+ http://activitystrea.ms/schema/1.0/note
XML
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 4ec528e70..238397bdc 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -2,29 +2,29 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-require 'lib/diaspora/user/friending.rb'
-require 'lib/diaspora/user/querying.rb'
-require 'lib/salmon/salmon'
+require File.expand_path('../../../lib/diaspora/user/friending', __FILE__)
+require File.expand_path('../../../lib/diaspora/user/querying', __FILE__)
+require File.expand_path('../../../lib/diaspora/user/receiving', __FILE__)
+require File.expand_path('../../../lib/salmon/salmon', __FILE__)
class User
include MongoMapper::Document
include Diaspora::UserModules::Friending
include Diaspora::UserModules::Querying
+ include Diaspora::UserModules::Receiving
include Encryptor::Private
QUEUE = MessageHandler.new
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
key :username, :unique => true
+ key :serialized_private_key, String
key :friend_ids, Array
key :pending_request_ids, Array
key :visible_post_ids, Array
key :visible_person_ids, Array
- key :url, String
-
one :person, :class_name => 'Person', :foreign_key => :owner_id
many :friends, :in => :friend_ids, :class_name => 'Person'
@@ -36,7 +36,7 @@ class User
after_create :seed_aspects
- before_validation_on_create :downcase_username
+ before_validation :downcase_username, :on => :create
def self.find_for_authentication(conditions={})
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
@@ -67,12 +67,11 @@ class User
def drop_aspect( aspect )
if aspect.people.size == 0
aspect.destroy
- else
+ else
raise "Aspect not empty"
end
end
-
def move_friend( opts = {})
return true if opts[:to] == opts[:from]
friend = Person.first(:_id => opts[:friend_id])
@@ -95,7 +94,6 @@ class User
######## Posting ########
def post(class_name, options = {})
-
if class_name == :photo
raise ArgumentError.new("No album_id given") unless options[:album_id]
aspect_ids = aspects_with_post( options[:album_id] )
@@ -104,17 +102,44 @@ class User
aspect_ids = options.delete(:to)
end
- aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
- raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty?
+ aspect_ids = validate_aspect_permissions(aspect_ids)
+ intitial_post(class_name, aspect_ids, options)
+ 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)
-
post
end
+ def update_post( post, post_hash = {} )
+ if self.owns? post
+ post.update_attributes(post_hash)
+ end
+ end
+
+ def validate_aspect_permissions(aspect_ids)
+ if aspect_ids == "all"
+ return aspect_ids
+ end
+
+ aspect_ids = [aspect_ids.to_s] unless aspect_ids.is_a? Array
+
+ if aspect_ids.nil? || aspect_ids.empty?
+ raise ArgumentError.new("You must post to someone.")
+ end
+
+ aspect_ids.each do |aspect_id|
+ unless self.aspects.find(aspect_id)
+ raise ArgumentError.new("Cannot post to an aspect you do not own.")
+ end
+ end
+
+ aspect_ids
+ end
+
def build_post( class_name, options = {})
options[:person] = self.person
model_class = class_name.to_s.camelize.constantize
@@ -141,26 +166,34 @@ class User
aspect.save
target_people = target_people | aspect.people
}
+
+ push_to_hub(post) if post.respond_to?(:public) && post.public
+
push_to_people(post, target_people)
end
def push_to_people(post, people)
+ salmon = salmon(post)
people.each{|person|
- salmon(post, :to => person)
+ xml = salmon.xml_for person
+ push_to_person( person, xml)
}
end
def push_to_person( person, xml )
- Rails.logger.debug("Adding xml for #{self} to message queue to #{url}")
- QUEUE.add_post_request( person.receive_url, person.encrypt(xml) )
- QUEUE.process
-
+ Rails.logger.debug("Adding xml for #{self} to message queue to #{self.url}")
+ QUEUE.add_post_request( person.receive_url, xml )
+ QUEUE.process
end
- def salmon( post, opts = {} )
- salmon = Salmon::SalmonSlap.create(self, post.to_diaspora_xml)
- push_to_person( opts[:to], salmon.to_xml)
- salmon
+ def push_to_hub(post)
+ Rails.logger.debug("Pushing update to pubsub server #{APP_CONFIG[:pubsub_server]} with url #{self.public_url}")
+ QUEUE.add_hub_notification(APP_CONFIG[:pubsub_server], self.public_url)
+ end
+
+ def salmon( post )
+ created_salmon = Salmon::SalmonSlap.create(self, post.to_diaspora_xml)
+ created_salmon
end
######## Commenting ########
@@ -192,7 +225,7 @@ class User
push_to_people comment, people_in_aspects(aspects_with_post(comment.post.id))
elsif owns? comment
comment.save
- salmon comment, :to => comment.post.person
+ push_to_people comment, [comment.post.person]
end
end
@@ -217,88 +250,13 @@ class User
end
end
- ###### Receiving #######
- def receive_salmon ciphertext
- cleartext = decrypt( ciphertext)
- Rails.logger.info("Received a salmon: #{cleartext}")
- salmon = Salmon::SalmonSlap.parse cleartext
- if salmon.verified_for_key?(salmon.author.public_key)
- Rails.logger.info("data in salmon: #{salmon.data}")
- self.receive(salmon.data)
- end
- end
-
- def receive xml
- object = Diaspora::Parser.from_xml(xml)
- Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
- Rails.logger.debug("From: #{object.person.inspect}") if object.person
-
- if object.is_a? Retraction
- if object.type == 'Person'
-
- Rails.logger.info( "the person id is #{object.post_id} the friend found is #{visible_person_by_id(object.post_id).inspect}")
- unfriended_by visible_person_by_id(object.post_id)
-else
- object.perform self.id
- aspects = self.aspects_with_person(object.person)
- aspects.each{ |aspect| aspect.post_ids.delete(object.post_id.to_id)
- aspect.save
- }
- end
- elsif object.is_a? Request
- person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
- person.serialized_key ||= object.exported_key
- object.person = person
- object.person.save
- old_request = Request.first(:id => object.id)
- object.aspect_id = old_request.aspect_id if old_request
- object.save
- receive_friend_request(object)
- elsif object.is_a? Profile
- person = Diaspora::Parser.owner_id_from_xml xml
- person.profile = object
- person.save
-
- elsif object.is_a?(Comment)
- object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil?
- self.visible_people = self.visible_people | [object.person]
- self.save
- Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil?
- object.person.save
- Rails.logger.debug("From: #{object.person.inspect}") if object.person
- raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.post.person == self.person || object.verify_post_creator_signature
- object.save
- unless owns?(object)
- dispatch_comment object
- end
- object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
- else
- Rails.logger.debug("Saving object: #{object}")
- object.user_refs += 1
- object.save
-
- self.raw_visible_posts << object
- self.save
-
- aspects = self.aspects_with_person(object.person)
- aspects.each{ |aspect|
- aspect.posts << object
- aspect.save
- object.socket_to_uid(id, :aspect_ids => [aspect.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
- }
-
- end
-
- end
-
###Helpers############
def self.instantiate!( opts = {} )
- hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '')
- hostname.chop! if hostname[-1, 1] == '/'
-
- opts[:person][:diaspora_handle] = "#{opts[:username]}@#{hostname}"
- puts opts[:person][:diaspora_handle]
- opts[:person][:serialized_key] = generate_key
+ opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
+ opts[:person][:url] = APP_CONFIG[:pod_url]
+
+ opts[:serialized_private_key] = generate_key
+ opts[:person][:serialized_public_key] = opts[:serialized_private_key].public_key
User.create(opts)
end
@@ -306,22 +264,15 @@ else
aspect(:name => "Family")
aspect(:name => "Work")
end
-
- def terse_url
- terse = self.url.gsub(/(https?:|www\.)\/\//, '')
- terse = terse.chop! if terse[-1, 1] == '/'
- terse
- end
def diaspora_handle
- "#{self.username}@#{self.terse_url}"
+ "#{self.username}@#{APP_CONFIG[:terse_pod_url]}"
end
def downcase_username
username.downcase! if username
end
-
def as_json(opts={})
{
:user => {
@@ -332,7 +283,14 @@ else
}
}
end
- def self.generate_key
- OpenSSL::PKey::RSA::generate 4096
- end
+
+
+ def self.generate_key
+ OpenSSL::PKey::RSA::generate 4096
+ end
+
+ def encryption_key
+ OpenSSL::PKey::RSA.new( serialized_private_key )
+ end
+
end
diff --git a/app/uploaders/image_uploader.rb b/app/uploaders/image_uploader.rb
index 6e5312341..58399c90d 100644
--- a/app/uploaders/image_uploader.rb
+++ b/app/uploaders/image_uploader.rb
@@ -2,7 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml
index f4893ed8f..4f41e5cfb 100644
--- a/app/views/albums/_album.html.haml
+++ b/app/views/albums/_album.html.haml
@@ -8,11 +8,11 @@
%div.time
by
- = link_to ((current_user.person == post.person)? 'you' : post.person.real_name), person_path(post.person)
+ = link_to ((current_user.person == post.person)? t('.you') : post.person.real_name), person_path(post.person)
%br
= link_to(how_long_ago(post), object_path(post, :aspect => @aspect))
%div.image_cycle
- for photo in post.photos[0..3]
= link_to (image_tag photo.url(:thumb_large)), album_path(post, :aspect => @aspect)
-
+
diff --git a/app/views/albums/_new_album.haml b/app/views/albums/_new_album.haml
index 8a37cb2c0..e0212a6b4 100644
--- a/app/views/albums/_new_album.haml
+++ b/app/views/albums/_new_album.haml
@@ -2,8 +2,7 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-%h1 Add a new album
+%h1=t('.add_a_new_album')
= form_for Album.new do |f|
= f.error_messages
@@ -11,4 +10,4 @@
= f.label :name
= f.text_field :name
= f.hidden_field :to, :value => aspect
- = f.submit 'create', :class => 'button'
+ = f.submit t('.create'), :class => 'button'
diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml
index a4bf3aef6..67cc3071d 100644
--- a/app/views/albums/edit.html.haml
+++ b/app/views/albums/edit.html.haml
@@ -2,14 +2,13 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
.back= link_to "⇧ #{@album.name}", @album
%h1.big_text
- = "Editing #{@album.name}"
+ = "#{t('.editing')} #{@album.name}"
.sub_header
- ="updated #{how_long_ago(@album)}"
+ ="#{t('.updated')} #{how_long_ago(@album)}"
- form_for @album do |a|
= a.error_messages
@@ -21,12 +20,12 @@
.photo_edit_block= image_tag photo.url(:thumb_medium)
#submit_block
- = link_to "Cancel", root_path
+ = link_to t('.cancel'), root_path
or
= a.submit
.button.delete
- = link_to 'Delete Album', @album, :confirm => 'Are you sure?', :method => :delete
+ = link_to t('.delete_album'), @album, :confirm => t('.are_you_sure'), :method => :delete
#content_bottom
.back
diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml
index fa4098c18..2e680c110 100644
--- a/app/views/albums/index.html.haml
+++ b/app/views/albums/index.html.haml
@@ -2,7 +2,6 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
- content_for :head do
:javascript
$(document).ready(function(){
@@ -10,7 +9,7 @@
});
= content_for :page_title do
- = link_to "◂ Home", aspects_path, :aspect => params[:aspect]
+ = link_to "◂ #{t('.home')}", aspects_path, :aspect => params[:aspect]
- content_for :left_pane do
= render "shared/aspect_friends"
@@ -19,7 +18,7 @@
%h1
Albums
.right
- = link_to 'New Album', '#new_album_pane', {:class => "button", :id => "add_album_button"}
+ = link_to t('.new_album'), '#new_album_pane', {:class => "button", :id => "add_album_button"}
.yo{:style => "display:none;" }
#new_album_pane
@@ -34,4 +33,4 @@
#content_bottom
.back
- = link_to "⇧ home", root_path
+ = link_to "⇧ #{t('.home')}", root_path
diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml
index 843523223..4c9ba19b8 100644
--- a/app/views/albums/show.html.haml
+++ b/app/views/albums/show.html.haml
@@ -2,7 +2,6 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
:javascript
$(document).ready(function(){
$(".image_thumb img").load( function() {
@@ -11,33 +10,30 @@
});
= content_for :page_title do
- = link_to "◂ Albums", albums_path(:aspect => @aspect)
+ = link_to "◂ #{t('.albums')}", albums_path(:aspect => @aspect)
- content_for :left_pane do
= render "shared/aspect_friends"
- content_for :publish do
+ -if current_user.owns? @album
+ .right
+ =render 'photos/new_photo'
+ = link_to t('.edit_album'), edit_album_path(@album), :class => 'button'
%h1
= @album.name
- ="updated #{how_long_ago(@album)}"
-
+ ="#{t('.updated')} #{how_long_ago(@album)}"
.album_id{:id => @album.id, :style => "display:hidden;"}
-unless current_user.owns? @album
- %h4= "by #{@album.person.real_name}"
+ %h4= "#{t('.by')} #{@album.person.real_name}"
#thumbnails
- for photo in @album_photos
.image_thumb
= link_to (image_tag photo.url(:thumb_medium)), object_path(photo)
- -if current_user.owns? @album
- =render 'photos/new_photo'
#content_bottom
.back
- = link_to "⇧ albums", albums_path
-
- -if current_user.owns? @album
- .right
- = link_to 'Edit Album', edit_album_path(@album), :class => 'button'
+ = link_to "⇧ #{t('.albums')}", albums_path
diff --git a/app/views/aspects/_new_aspect.haml b/app/views/aspects/_new_aspect.haml
index b5bc7ace3..548abd0d1 100644
--- a/app/views/aspects/_new_aspect.haml
+++ b/app/views/aspects/_new_aspect.haml
@@ -2,11 +2,10 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-%h1 Add a new aspect
+%h1=t('.add_a_new_aspect')
= form_for Aspect.new do |f|
= f.error_messages
%p
= f.label :name
= f.text_field :name
- = f.submit 'create', :class => 'button'
+ = f.submit t('.create'), :class => 'button'
diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml
index 5ea9cadb3..ae24e8e3b 100644
--- a/app/views/aspects/index.html.haml
+++ b/app/views/aspects/index.html.haml
@@ -2,10 +2,8 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
- content_for :page_title do
- = link_to "photos", albums_path(:aspect => @aspect)
-
+ = link_to t('.photos'), albums_path(:aspect => @aspect)
- content_for :left_pane do
= render "shared/aspect_friends"
diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml
index 667196b85..e08f6dabd 100644
--- a/app/views/aspects/manage.html.haml
+++ b/app/views/aspects/manage.html.haml
@@ -2,47 +2,48 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-- content_for :head do
+- content_for :head do
= javascript_include_tag 'jquery-ui-1.8.4.custom.min.js'
= javascript_include_tag 'aspect-edit.js'
- content_for :left_pane do
- %h1
- Requests
+ %h1=t('.requests')
.requests
%ul.dropzone
- - for request in @remote_requests
- %li.requested_person{:id => request.person.id, :request_id => request.id}
- = person_image_tag(request.person)
- .name
- = request.person.real_name
- %h1
- Ignore/Remove
+ - if @remote_requests.size < 1
+ %li.grey No new requests
+ - else
+ - for request in @remote_requests
+ %li.requested_person{:id => request.person.id, :request_id => request.id}
+ = person_image_tag(request.person)
+ .name
+ = request.person.real_name
+ %h1=t('.ignore_remove')
%li.remove
%ul.dropzone
+ %li.grey Drag to ignore/remove
- content_for :publish do
- = link_to("add a new aspect", "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => "Add a new aspect")
-
-
+ = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect'))
%ul#aspect_list
- for aspect in @aspects
%li.aspect
-
+
.aspect_name
- %h1{:contenteditable => true}= aspect.name
+ %span.edit_name_field
+ %h1{:contenteditable => true}= aspect.name
+ %span.tip click to edit
%ul.tools
- %li= link_to "add a new friend", "#add_request_pane_#{aspect.id}", :class => 'add_request_button'
- %li= link_to "show", aspect_path(aspect)
+ %li= link_to t('.add_a_new_friend'), "#add_request_pane_#{aspect.id}", :class => 'add_request_button'
+ %li= link_to t('.show'), aspect_path(aspect)
%li!= remove_link(aspect)
-
+
%ul.dropzone{:id => aspect.id}
-
+
-if aspect.people.size < 1
%li.grey Drag to add people
@@ -52,13 +53,9 @@
%li.person{:id => person.id, :from_aspect_id => aspect.id}
= person_image_tag(person)
.name
- = person.real_name
+ = link_to person.real_name, person
.yo{:style => 'display:none'}
%div{:id => "add_request_pane_#{aspect.id}"}
= render "requests/new_request", :aspect => aspect
-%p
- %br
- = link_to 'Update Aspects', '#', :class => 'button', :id => "move_friends_link"
-
#content_bottom
diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml
new file mode 100644
index 000000000..e85cae276
--- /dev/null
+++ b/app/views/aspects/public.html.haml
@@ -0,0 +1,24 @@
+-# Copyright (c) 2010, Diaspora Inc. This file is
+-# licensed under the Affero General Public License version 3. See
+-# the COPYRIGHT file.
+
+
+- content_for :page_title do
+ = link_to "photos", albums_path(:aspect => @aspect)
+
+- content_for :left_pane do
+ = render "shared/aspect_friends"
+
+- content_for :publish do
+ - if @logged_in
+ = render "shared/publisher", :aspect_ids => :public
+ - else
+ = render "shared/publisher", :aspect_ids => :all
+
+%ul#stream
+ - for post in @posts
+ = render type_partial(post), :post => post unless post.class == Album
+
+#pagination
+ = will_paginate @posts
+
diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml
index f10ccee74..ae24e8e3b 100644
--- a/app/views/aspects/show.html.haml
+++ b/app/views/aspects/show.html.haml
@@ -2,9 +2,8 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
- content_for :page_title do
- = link_to "photos", albums_path(:aspect => @aspect)
+ = link_to t('.photos'), albums_path(:aspect => @aspect)
- content_for :left_pane do
= render "shared/aspect_friends"
diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml
index 56252c83d..03a2fcf61 100644
--- a/app/views/comments/_comment.html.haml
+++ b/app/views/comments/_comment.html.haml
@@ -2,11 +2,10 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-%li.comment{:id => post.id}
+%li.comment{:id => post.id}
= person_image_tag(post.person)
%span.from
= link_to post.person.real_name, post.person
- = auto_link sanitize post.text
+ = post.text
%div.time
- = "#{time_ago_in_words(post.updated_at)} ago"
+ = "#{time_ago_in_words(post.updated_at)} #{t('.ago')}"
diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml
index fc5c64da7..aecfb4bf1 100644
--- a/app/views/comments/_comments.html.haml
+++ b/app/views/comments/_comments.html.haml
@@ -2,11 +2,10 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
%div.comments
%ul.comment_set{:id => post.id}
- for comment in post.comments
= render 'comments/comment', :post => comment
%li.comment.show
= render 'comments/new_comment', :post => post
-
+
diff --git a/app/views/comments/_new_comment.html.haml b/app/views/comments/_new_comment.html.haml
index e998d98b7..99c03f898 100644
--- a/app/views/comments/_new_comment.html.haml
+++ b/app/views/comments/_new_comment.html.haml
@@ -2,11 +2,10 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
= form_for Comment.new, :remote => true do |f|
%p
%label{:for => "comment_text_on_#{post.id}"} Comment
= f.text_area :text, :rows => 1, :id => "comment_text_on_#{post.id}", :class => "comment_box"
= f.hidden_field :post_id, :value => post.id
%p{:style => "text-align:right;"}
- = f.submit "Comment", :class => "comment_submit button"
+ = f.submit t('.comment'), :class => "comment_submit button"
diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml
index 1840d7acc..5803415b4 100644
--- a/app/views/devise/sessions/new.html.haml
+++ b/app/views/devise/sessions/new.html.haml
@@ -1,10 +1,16 @@
+%h1
+ This is a technology preview, do not provide any private information.
+%h3
+ your account may be deleted until we move into a more stable development period.
+%h3
+ USE AT YOUR OWN RISK!!
= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
#user
%p.username
= f.label :username
= f.text_field :username
%p.user_network
- ="@#{request.host}"
+ ="@#{APP_CONFIG[:terse_pod_url]}"
%p
= f.label :password
@@ -14,6 +20,7 @@
/ = f.check_box :remember_me
/ = f.label :remember_me
= f.submit "Sign in"
+ = link_to "Have a problem? Find an answer here", 'http://diaspora.shapado.com/'
%p
= render :partial => "devise/shared/links"
diff --git a/app/views/js/_websocket_js.haml b/app/views/js/_websocket_js.haml
index 33af68cce..4677f6ce6 100644
--- a/app/views/js/_websocket_js.haml
+++ b/app/views/js/_websocket_js.haml
@@ -2,7 +2,6 @@
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
= javascript_include_tag 'FABridge', 'swfobject', 'web_socket'
:javascript
WebSocket.__swfLocation = "/javascripts/WebSocketMain.swf";
@@ -19,25 +18,23 @@
if (obj['class']=="retractions"){
processRetraction(obj['post_id']);
-
+
}else if (obj['class']=="comments"){
- processComment(obj['post_id'], obj['html'])
-
+ processComment(obj['post_id'], obj['html'])
+
}else if (obj['class']=='photos' && onPageForClass('albums')){
processPhotoInAlbum(obj['photo_hash'])
}else{
processPost(obj['class'], obj['html'], obj['aspect_ids'])
}
-
- };
+ };
ws.onclose = function() { debug("socket closed"); };
ws.onopen = function() {
ws.send(location.pathname);
debug("connected...");
};
-
});
function processRetraction(post_id){
$('#' + post_id ).fadeOut(500, function(){
@@ -66,7 +63,7 @@
$(html).fadeIn("fast", function(){
$("#stream label:first").inFieldLabels();
})
- );
+ );
}
}
@@ -77,13 +74,13 @@
html = "
diff --git a/spec/fixtures/host_xrd b/spec/fixtures/host_xrd
index dcb67d767..8118fa94a 100644
--- a/spec/fixtures/host_xrd
+++ b/spec/fixtures/host_xrd
@@ -1,6 +1,6 @@
-
Resource Descriptor
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 4b89c7b31..459563cff 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -2,18 +2,14 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
+require 'spec_helper'
-
-require File.dirname(__FILE__) + '/../spec_helper'
-
-include ApplicationHelper
describe ApplicationHelper do
before do
@user = Factory.create(:user)
@person = Factory.create(:person)
end
-
it "should provide a correct show path for a given person" do
person_url(@person).should == "/people/#{@person.id}"
end
diff --git a/spec/helpers/publics_helper_spec.rb b/spec/helpers/publics_helper_spec.rb
index 70e9d4606..bc6a5021b 100644
--- a/spec/helpers/publics_helper_spec.rb
+++ b/spec/helpers/publics_helper_spec.rb
@@ -2,11 +2,8 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
+require 'spec_helper'
-
-require File.dirname(__FILE__) + '/../spec_helper'
-
-include PublicsHelper
describe PublicsHelper do
before do
@user = Factory.create(:user)
diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb
index 2d2be1acb..bf99f89d1 100644
--- a/spec/helpers/requests_helper_spec.rb
+++ b/spec/helpers/requests_helper_spec.rb
@@ -2,16 +2,11 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
-
-include RequestsHelper
+require 'spec_helper'
describe RequestsHelper do
before do
-
stub_success("tom@tom.joindiaspora.com")
stub_success("evan@status.net")
@tom = Redfinger.finger('tom@tom.joindiaspora.com')
@@ -24,4 +19,16 @@ describe RequestsHelper do
subscription_mode(@evan).should == :none
end
end
+
+ describe "#relationship_flow" do
+ let(:tom){ Factory(:user, :email => 'tom@tom.joindiaspora.com') }
+
+ before do
+ stub!(:current_user).and_return(tom)
+ end
+
+ it 'should return the correct tag and url for a given address' do
+ relationship_flow('tom@tom.joindiaspora.com')[:friend].receive_url.should include("receive/user")
+ end
+ end
end
diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb
index cdd1063ab..d5722fd65 100644
--- a/spec/lib/diaspora_parser_spec.rb
+++ b/spec/lib/diaspora_parser_spec.rb
@@ -2,20 +2,15 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
-
-include ApplicationHelper
-include Diaspora::Parser
-
-
+require 'spec_helper'
describe Diaspora::Parser do
before do
@user = Factory.create(:user, :email => "bob@aol.com")
@aspect = @user.aspect(:name => 'spies')
- @person = Factory.create(:person_with_private_key, :diaspora_handle => "bill@gates.com")
+
+ @user3 = Factory.create :user
+ @person = @user3.person
@user2 = Factory.create(:user)
end
@@ -71,12 +66,13 @@ describe Diaspora::Parser do
original_person_id = @person.id
xml = request.to_diaspora_xml
+ @user3.destroy
@person.destroy
Person.all.count.should == person_count -1
@user.receive xml
Person.all.count.should == person_count
- Person.first(:_id => original_person_id).serialized_key.include?("PUBLIC").should be true
+ Person.first(:_id => original_person_id).serialized_public_key.include?("PUBLIC").should be true
url = "http://" + request.callback_url.split("/")[2] + "/"
Person.where(:url => url).first.id.should == original_person_id
end
@@ -88,14 +84,13 @@ describe Diaspora::Parser do
original_person_id = @user2.person.id
xml = request.to_diaspora_xml
-
Person.all.count.should be person_count
@user.receive xml
Person.all.count.should be person_count
@user2.reload
@user2.person.reload
- @user2.person.serialized_key.include?("PRIVATE").should be true
+ @user2.serialized_private_key.include?("PRIVATE").should be true
url = "http://" + request.callback_url.split("/")[2] + "/"
Person.where(:url => url).first.id.should == original_person_id
@@ -103,7 +98,7 @@ describe Diaspora::Parser do
it "should activate the Person if I initiated a request to that url" do
request = @user.send_friend_request_to( @user2.person, @aspect)
-
+ @user.reload
request.reverse_for @user2
xml = request.to_diaspora_xml
@@ -121,10 +116,10 @@ describe Diaspora::Parser do
@user.friends.include?(new_person).should be true
end
-
it 'should process retraction for a person' do
person_count = Person.all.count
request = @user.send_friend_request_to( @user2.person, @aspect)
+ @user.reload
request.reverse_for @user2
xml = request.to_diaspora_xml
@@ -139,7 +134,6 @@ describe Diaspora::Parser do
aspect_people_count = @aspect.people.size
#They are now friends
-
Person.count.should == person_count
@user.receive retraction_xml
diff --git a/spec/lib/hcard_spec.rb b/spec/lib/hcard_spec.rb
index 89ad49924..45d7157b9 100644
--- a/spec/lib/hcard_spec.rb
+++ b/spec/lib/hcard_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
require File.dirname(__FILE__) + '/../../lib/hcard'
describe HCard do
diff --git a/spec/lib/message_handler_spec.rb b/spec/lib/message_handler_spec.rb
index 00db2a1b8..ddc822334 100644
--- a/spec/lib/message_handler_spec.rb
+++ b/spec/lib/message_handler_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe MessageHandler do
before do
@@ -41,8 +39,7 @@ describe MessageHandler do
}
end
-
- it 'should only retry a bad request three times ' do
+ it 'should only retry a bad request the correct number of times' do
request = FakeHttpRequest.new(:failure)
request.should_receive(:get).exactly(MessageHandler::NUM_TRIES).times.and_return(request)
EventMachine::HttpRequest.stub!(:new).and_return(request)
@@ -61,7 +58,6 @@ describe MessageHandler do
describe 'POST messages' do
-
it 'should be able to add a post message to the queue' do
EventMachine.run {
@handler.size.should ==0
@@ -98,6 +94,26 @@ describe MessageHandler do
end
end
+ describe "Hub publish" do
+ it 'should correctly queue up a pubsubhubbub publish request' do
+ destination = "http://identi.ca/hub/"
+ feed_location = "http://google.com/"
+
+ EventMachine.run {
+ @handler.add_hub_notification(destination, feed_location)
+ q = @handler.instance_variable_get(:@queue)
+
+ message = ""
+ q.pop{|m| message = m}
+
+ message.destination.should == destination
+ message.body.should == feed_location
+
+ EventMachine.stop
+ }
+ end
+ end
+
describe "Mixed Queries" do
it 'should process both POST and GET requests in the same queue' do
@@ -123,7 +139,6 @@ describe MessageHandler do
request = FakeHttpRequest.new(:success)
request.should_receive(:get).exactly(1).times.and_return(request)
request.should_receive(:post).exactly(1).times.and_return(request)
- @handler.should_receive(:send_to_seed).once
EventMachine::HttpRequest.stub!(:new).and_return(request)
diff --git a/spec/lib/ostatus_builder_spec.rb b/spec/lib/ostatus_builder_spec.rb
new file mode 100644
index 000000000..042bf202b
--- /dev/null
+++ b/spec/lib/ostatus_builder_spec.rb
@@ -0,0 +1,25 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3. See
+# the COPYRIGHT file.
+
+require 'spec_helper'
+require File.dirname(__FILE__) + '/../../lib/diaspora/ostatus_builder'
+
+describe Diaspora::OstatusBuilder do
+
+ let!(:user) { Factory(:user) }
+ let(:aspect) { user.aspect(:name => "Public People") }
+ let!(:status_message1) { user.post(:status_message, :message => "One", :public => true, :to => aspect.id) }
+ let!(:status_message2) { user.post(:status_message, :message => "Two", :public => true, :to => aspect.id) }
+ let!(:status_message3) { user.post(:status_message, :message => "Three", :public => false, :to => aspect.id) }
+
+ let!(:atom) { director = Diaspora::Director.new; director.build(Diaspora::OstatusBuilder.new(user)) }
+
+ it 'should include a users posts' do
+ atom.should include status_message1.message
+ atom.should include status_message2.message
+ atom.should_not include status_message3.message
+ end
+
+end
+
diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb
index a14ef8f77..40f928c18 100644
--- a/spec/lib/salmon_salmon_spec.rb
+++ b/spec/lib/salmon_salmon_spec.rb
@@ -2,58 +2,100 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Salmon do
- before do
+ let(:user){Factory.create :user}
+ let(:user2) {Factory.create :user}
+ let(:user3) {Factory.create :user}
+ let(:post){ user.post :status_message, :message => "hi", :to => user.aspect(:name => "sdg").id }
- @user = Factory.create :user
- @post = @user.post :status_message, :message => "hi", :to => @user.aspect(:name => "sdg").id
- @sent_salmon = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml)
- @parsed_salmon = Salmon::SalmonSlap.parse @sent_salmon.to_xml
- stub_success("tom@tom.joindiaspora.com")
+ let!(:created_salmon) {Salmon::SalmonSlap.create(user, post.to_diaspora_xml)}
+
+ describe '#create' do
+
+ it 'has data in the magic envelope' do
+ created_salmon.magic_sig.data.should_not be nil
+ end
+
+ it 'has no parsed_data' do
+ created_salmon.parsed_data.should be nil
+ end
+
+ it 'sets aes and iv key' do
+ created_salmon.aes_key.should_not be nil
+ created_salmon.iv.should_not be nil
+ end
+
+ it 'makes the data in the signature encrypted with that key' do
+ key_hash = {'key' => created_salmon.aes_key, 'iv' => created_salmon.iv}
+ decoded_string = Salmon::SalmonSlap.decode64url(created_salmon.magic_sig.data)
+ user.aes_decrypt(decoded_string, key_hash).should == post.to_diaspora_xml
+ end
end
- it 'should verify the signature on a roundtrip' do
+ describe '#xml_for' do
+ let(:xml) {created_salmon.xml_for user2.person}
- @sent_salmon.magic_sig.data.should == @parsed_salmon.magic_sig.data
+ it 'has a encrypted header field' do
+ xml.include?("encrypted_header").should be true
+ end
- @sent_salmon.magic_sig.sig.should == @parsed_salmon.magic_sig.sig
- @sent_salmon.magic_sig.signable_string.should == @parsed_salmon.magic_sig.signable_string
-
-
- @parsed_salmon.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
- @sent_salmon.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
+ it 'the encrypted_header field should contain the aes key' do
+ doc = Nokogiri::XML(xml)
+ decrypted_header = user2.decrypt(doc.search('encrypted_header').text)
+ decrypted_header.include?(created_salmon.aes_key).should be true
+ end
end
- it 'should return the data so it can be "received"' do
+ context 'marshaling' do
+ let(:xml) {created_salmon.xml_for user2.person}
+ let(:parsed_salmon) { Salmon::SalmonSlap.parse(xml, user2)}
- xml = @post.to_diaspora_xml
+ it 'should parse out the aes key' do
+ parsed_salmon.aes_key.should == created_salmon.aes_key
+ end
- @parsed_salmon.data.should == xml
- end
+ it 'should parse out the iv' do
+ parsed_salmon.iv.should == created_salmon.iv
+ end
+ it 'should parse out the authors diaspora_handle' do
+ parsed_salmon.author_email.should == user.person.diaspora_handle
- it 'should parse out the authors diaspora_handle' do
- @parsed_salmon.author_email.should == @user.person.diaspora_handle
+ end
+
+ describe '#author' do
+ before do
+ stub_success("tom@tom.joindiaspora.com")
+ end
+
+ it 'should reference a local author' do
+ parsed_salmon.author.should == user.person
+ end
+
+ it 'should reference a remote author' do
+ parsed_salmon.author_email = 'tom@tom.joindiaspora.com'
+ parsed_salmon.author.public_key.should_not be_nil
+ end
+
+ it 'should fail to reference a nonexistent remote author' do
+ parsed_salmon.author_email = 'idsfug@difgubhpsduh.rgd'
+ proc {
+ Redfinger.stub(:finger).and_return(nil) #Redfinger returns nil when there is no profile
+ parsed_salmon.author.real_name}.should raise_error /No webfinger profile found/
+ end
+ end
+
+ it 'verifies the signature for the sender' do
+ parsed_salmon.verified_for_key?(user.public_key).should be true
+ end
+
+ it 'contains the original data' do
+ parsed_salmon.parsed_data.should == post.to_diaspora_xml
+ end
end
- it 'should reference a local author' do
- @parsed_salmon.author.should == @user.person
- end
- it 'should reference a remote author' do
- @parsed_salmon.author_email = 'tom@tom.joindiaspora.com'
- @parsed_salmon.author.public_key.should_not be_nil
- end
-
- it 'should fail to reference a nonexistent remote author' do
- @parsed_salmon.author_email = 'idsfug@difgubhpsduh.rgd'
- proc {
- Redfinger.stub(:finger).and_return(nil) #Redfinger returns nil when there is no profile
- @parsed_salmon.author.real_name}.should raise_error /No webfinger profile found/
- end
end
diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb
index d3486f1b5..e316817d4 100644
--- a/spec/lib/web_hooks_spec.rb
+++ b/spec/lib/web_hooks_spec.rb
@@ -2,32 +2,25 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
+require 'spec_helper'
+describe Diaspora::Webhooks do
+ before do
+ @user = Factory.create(:user)
+ @aspect = @user.aspect(:name => "losers")
+ @user2 = Factory.create(:user)
+ @aspect2 = @user2.aspect(:name => "losers")
+ friend_users(@user, @aspect, @user2, @aspect2)
+ end
-require File.dirname(__FILE__) + '/../spec_helper'
-
-include Diaspora
-
-describe Diaspora do
-
- describe Webhooks do
+ describe "body" do
before do
- @user = Factory.create(:user)
- @aspect = @user.aspect(:name => "losers")
- @user2 = Factory.create(:user)
- @aspect2 = @user2.aspect(:name => "losers")
- friend_users(@user, @aspect, @user2, @aspect2)
+ @post = Factory.build(:status_message, :person => @user.person)
end
- describe "body" do
- before do
- @post = Factory.build(:status_message, :person => @user.person)
- end
-
- it "should add the following methods to Post on inclusion" do
- @post.respond_to?(:to_diaspora_xml).should be true
- end
-
+ it "should add the following methods to Post on inclusion" do
+ @post.respond_to?(:to_diaspora_xml).should be true
end
+
end
end
diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb
index 018f5020d..0b76e0f52 100644
--- a/spec/lib/websocket_spec.rb
+++ b/spec/lib/websocket_spec.rb
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Diaspora::WebSocket do
before do
@@ -19,18 +19,18 @@ describe Diaspora::WebSocket do
describe 'queuing and dequeuing ' do
before do
- @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
@channel = Magent::GenericChannel.new('websocket')
+ @messages = @channel.message_count
+ @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
end
it 'should send the queued job to Magent' do
- @channel.message_count.should == 1
+ @channel.message_count.should == @messages + 1
end
it 'should dequeue the job successfully' do
- messages = @channel.message_count
@channel.dequeue
- @channel.message_count.should == messages -1
+ @channel.message_count.should == @messages
end
end
diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb
index 14f1d4c3e..c4b2cc67c 100644
--- a/spec/misc_spec.rb
+++ b/spec/misc_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/spec_helper'
+require 'spec_helper'
describe 'making sure the spec runner works' do
@@ -34,4 +32,25 @@ describe 'making sure the spec runner works' do
end
end
+ describe '#friend_users' do
+ before do
+ @user1 = Factory.create(:user)
+ @aspect1 = @user1.aspect(:name => "losers")
+ @user2 = Factory.create(:user)
+ @aspect2 = @user2.aspect(:name => "bruisers")
+ friend_users(@user1, @aspect1, @user2, @aspect2)
+ @user1.reload
+ @aspect1.reload
+ @user2.reload
+ @aspect2.reload
+ end
+
+ it 'makes the first user friends with the second' do
+ @aspect1.people.include?(@user2.person).should be_true
+ end
+
+ it 'makes the second user friends with the first' do
+ @aspect2.people.include?(@user1.person).should be_true
+ end
+ end
end
diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb
index 5931970cf..23453eee9 100644
--- a/spec/models/aspect_spec.rb
+++ b/spec/models/aspect_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Aspect do
before do
@@ -20,7 +18,7 @@ describe Aspect do
aspect.name.should == "losers"
end
- it 'should be able to have people' do
+ it 'should be creatable with people' do
aspect = @user.aspect(:name => 'losers', :people => [@friend, @friend_2])
aspect.people.size.should == 2
end
@@ -156,16 +154,16 @@ describe Aspect do
@user.receive message.to_diaspora_xml
@aspect.reload
- @aspect.posts.count.should be 1
- @aspect3.posts.count.should be 0
+ @aspect.posts.count.should == 1
+ @aspect3.posts.count.should == 0
@user.reload
@user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect3.id)
@aspect.reload
@aspect3.reload
- @aspect3.posts.count.should be 1
- @aspect.posts.count.should be 0
+ @aspect3.posts.count.should == 1
+ @aspect.posts.count.should == 0
end
diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb
index 1c20354cf..732c4349b 100644
--- a/spec/models/comments_spec.rb
+++ b/spec/models/comments_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Comment do
describe "user" do
diff --git a/spec/models/fb_status_spec.rb b/spec/models/fb_status_spec.rb
new file mode 100644
index 000000000..2ab232fce
--- /dev/null
+++ b/spec/models/fb_status_spec.rb
@@ -0,0 +1,43 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3. See
+# the COPYRIGHT file.
+
+
+
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe FbStatus do
+
+ let(:fb_status) { Factory.create :fb_status }
+
+ it 'is valid' do
+ fb_status.should be_valid
+ end
+
+ describe '#from_api' do
+ let!(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read}
+ let!(:json_object) { JSON.parse(json_string) }
+ let!(:status_from_json) {FbStatus.from_api(json_object)}
+
+ it 'has graph_id' do
+ status_from_json.graph_id.should == json_object['id']
+ end
+
+ it 'has author_id' do
+ status_from_json.author_id.should == json_object['from']['id']
+ end
+
+ it 'has author_name' do
+ status_from_json.author_name.should == json_object['from']['name']
+ end
+
+ it 'has message' do
+ status_from_json.message.should == json_object['message']
+ end
+
+ it 'has author_name' do
+ status_from_json.updated_time.should == Time.parse(json_object['updated_time'])
+ end
+ end
+
+end
diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb
index bffe37f85..6df3ddc1c 100644
--- a/spec/models/person_spec.rb
+++ b/spec/models/person_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Person do
before do
@@ -15,6 +13,20 @@ describe Person do
@aspect2 = @user2.aspect(:name => "Abscence of Babes")
end
+ describe '#diaspora_handle' do
+ context 'local people' do
+ it 'uses the pod config url to set the diaspora_handle' do
+ @user.person.diaspora_handle.should == @user.username + "@" + APP_CONFIG[:terse_pod_url]
+ end
+ end
+
+ context 'remote people' do
+ it 'stores the diaspora_handle in the database' do
+ @person.diaspora_handle.include?(APP_CONFIG[:terse_pod_url]).should be false
+ end
+ end
+ end
+
it 'should not allow two people with the same diaspora_handle' do
person_two = Factory.build(:person, :url => @person.diaspora_handle)
person_two.valid?.should == false
@@ -134,13 +146,13 @@ describe Person do
people.include?(@friend_three).should == false
people.include?(@friend_four).should == false
- people = Person.search("Wei")
+ people = Person.search("wEi")
people.include?(@friend_two).should == true
people.include?(@friend_one).should == false
people.include?(@friend_three).should == false
people.include?(@friend_four).should == false
- people = Person.search("Gri")
+ people = Person.search("gri")
people.include?(@friend_one).should == true
people.include?(@friend_four).should == true
people.include?(@friend_two).should == false
@@ -148,13 +160,11 @@ describe Person do
end
it 'should search by diaspora_handle exactly' do
-
stub_success("tom@tom.joindiaspora.com")
Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one
end
it 'should create a stub for a remote user' do
-
stub_success("tom@tom.joindiaspora.com")
tom = Person.by_webfinger('tom@tom.joindiaspora.com')
tom.real_name.include?("Hamiltom").should be true
diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb
index 516c16df8..f3f77f3db 100644
--- a/spec/models/photo_spec.rb
+++ b/spec/models/photo_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Photo do
before do
@@ -16,7 +14,6 @@ describe Photo do
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
-
@photo = Photo.new(:person => @user.person, :album => @album)
end
@@ -31,8 +28,13 @@ describe Photo do
it 'should save a photo' do
@photo.image.store! File.open(@fixture_name)
@photo.save.should == true
- binary = @photo.image.read
- fixture_binary = File.open(@fixture_name).read
+ begin
+ binary = @photo.image.read.force_encoding('BINARY')
+ fixture_binary = File.open(@fixture_name).read.force_encoding('BINARY')
+ rescue NoMethodError # Ruby 1.8 doesn't have force_encoding
+ binary = @photo.image.read
+ fixture_binary = File.open(@fixture_name).read
+ end
binary.should == fixture_binary
end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index dc9d4a9b8..b0ed59b7d 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Post do
before do
diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb
index b5bd8f9a5..2e38c20ae 100644
--- a/spec/models/profile_spec.rb
+++ b/spec/models/profile_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Profile do
before do
@@ -29,4 +27,3 @@ describe Profile do
end
end
-
diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb
index 5899cb7fb..c8fb8af05 100644
--- a/spec/models/request_spec.rb
+++ b/spec/models/request_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Request do
before do
@@ -19,7 +17,7 @@ describe Request do
person_request.valid?.should be true
end
- it 'should generate xml for the User as a Person' do
+ it 'should generate xml for the User as a Person' do
request = @user.send_friend_request_to Factory.create(:person), @aspect
xml = request.to_xml.to_s
diff --git a/spec/models/retraction_spec.rb b/spec/models/retraction_spec.rb
index 9aa2b8a76..777855234 100644
--- a/spec/models/retraction_spec.rb
+++ b/spec/models/retraction_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Retraction do
before do
diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb
index 005038bf1..d7dbf19e4 100644
--- a/spec/models/status_message_spec.rb
+++ b/spec/models/status_message_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe StatusMessage do
before do
@@ -37,6 +35,5 @@ describe StatusMessage do
end
end
-
end
diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb
index b1f6f71a8..518c03d2d 100644
--- a/spec/models/user/posting_spec.rb
+++ b/spec/models/user/posting_spec.rb
@@ -2,66 +2,90 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+require 'spec_helper'
describe User do
- before do
- @user = Factory.create :user
- @aspect = @user.aspect(:name => 'heroes')
- @aspect1 = @user.aspect(:name => 'heroes')
- @user2 = Factory.create(:user)
- @aspect2 = @user2.aspect(:name => 'losers')
+ let!(:user) { Factory(:user) }
+ let!(:aspect) { user.aspect(:name => 'heroes') }
+ let!(:aspect1) { user.aspect(:name => 'other') }
- @user3 = Factory.create(:user)
- @aspect3 = @user3.aspect(:name => 'heroes')
+ let!(:user2) { Factory(:user) }
+ let!(:aspect2) { user2.aspect(:name => 'losers') }
- @user4 = Factory.create(:user)
- @aspect4 = @user4.aspect(:name => 'heroes')
+ describe '#validate_aspect_permissions' do
+ it 'requires an aspect' do
+ proc {
+ user.validate_aspect_permissions([])
+ }.should raise_error /You must post to someone/
+ end
- friend_users(@user, @aspect, @user2, @aspect2)
- friend_users(@user, @aspect, @user3, @aspect3)
- friend_users(@user, @aspect1, @user4, @aspect4)
- end
+ it "won't let you post to someone else's aspect" do
+ proc {
+ user.validate_aspect_permissions(aspect2.id)
+ }.should raise_error /Cannot post to an aspect you do not own./
+ end
- it 'should not be able to post without a aspect' do
- proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
+ it "lets you post to your own aspects" do
+ user.validate_aspect_permissions(aspect.id).should be_true
+ user.validate_aspect_permissions(aspect1.id).should be_true
+ end
end
- it 'should put the post in the aspect post array' do
- post = @user.post(:status_message, :message => "hey", :to => @aspect.id)
- @aspect.reload
- @aspect.post_ids.include?(post.id).should be true
+ describe '#post' do
+ it 'should put the post in the aspect post array' do
+ post = user.post(:status_message, :message => "hey", :to => aspect.id)
+ aspect.reload
+ aspect.posts.should include post
+ end
+
+ it 'should put an album in the aspect post array' do
+ album = user.post :album, :name => "Georges", :to => aspect.id
+ aspect.reload
+ aspect.posts.should include album
+ end
end
- it 'should put an album in the aspect post array' do
- album = @user.post :album, :name => "Georges", :to => @aspect.id
- @aspect.reload
- @aspect.post_ids.include?(album.id).should be true
- @aspect.posts.include?(album).should be true
+ describe '#update_post' do
+ it 'should update fields' do
+ album = user.post(:album, :name => "Profile Photos", :to => aspect.id)
+ update_hash = {:name => "Other Photos"}
+ user.update_post(album, update_hash)
+ album.name.should == "Other Photos"
+ end
end
- describe 'dispatching' do
+ context 'dispatching' do
+ let!(:user3) { Factory(:user) }
+ let!(:aspect3) { user3.aspect(:name => 'heroes') }
+ let!(:user4) { Factory(:user) }
+ let!(:aspect4) { user4.aspect(:name => 'heroes') }
+
+ let!(:post) { user.build_post :status_message, :message => "hey" }
+
before do
- @post = @user.build_post :status_message, :message => "hey"
- end
- it 'should push a post to a aspect' do
- @user.should_receive(:salmon).twice
- @user.push_to_aspects(@post, @aspect.id)
+ friend_users(user, aspect, user2, aspect2)
+ friend_users(user, aspect, user3, aspect3)
+ friend_users(user, aspect1, user4, aspect4)
end
- it 'should push a post to all aspects' do
- @user.should_receive(:salmon).exactly(3).times
- @user.push_to_aspects(@post, :all)
+ describe '#push_to_aspects' do
+ it 'should push a post to a aspect' do
+ user.should_receive(:push_to_person).twice
+ user.push_to_aspects(post, aspect.id)
+ end
+
+ it 'should push a post to all aspects' do
+ user.should_receive(:push_to_person).exactly(3).times
+ user.push_to_aspects(post, :all)
+ end
end
- it 'should push to people' do
- @user.should_receive(:salmon).twice
- @user.push_to_people(@post, [@user2.person, @user3.person])
+ describe '#push_to_people' do
+ it 'should push to people' do
+ user.should_receive(:push_to_person).twice
+ user.push_to_people(post, [user2.person, user3.person])
+ end
end
-
-
end
end
diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb
index 37648a98c..fce699cf6 100644
--- a/spec/models/user/receive_spec.rb
+++ b/spec/models/user/receive_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+require 'spec_helper'
describe User do
@@ -175,11 +173,11 @@ describe User do
describe 'salmon' do
before do
@post = @user.post :status_message, :message => "hello", :to => @aspect.id
- @salmon = @user.salmon( @post, :to => @user2.person )
+ @salmon = @user.salmon( @post )
end
it 'should receive a salmon for a post' do
- @user2.receive_salmon( @user2.person.encrypt(@salmon.to_xml) )
+ @user2.receive_salmon( @salmon.xml_for @user2.person )
@user2.visible_post_ids.include?(@post.id).should be true
end
end
diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb
index bef8fa416..4ea51ad19 100644
--- a/spec/models/user/user_friending_spec.rb
+++ b/spec/models/user/user_friending_spec.rb
@@ -2,9 +2,7 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+require 'spec_helper'
describe User do
before do
@@ -24,7 +22,6 @@ describe User do
aspect.requests.size.should == 1
end
-
it "should be able to accept a pending friend request" do
friend = Factory.create(:person)
r = Request.instantiate(:to => @user.receive_url, :from => friend)
@@ -53,12 +50,9 @@ describe User do
@user.friends << friend
@user.save
-
proc {@user.send_friend_request_to( friend, @aspect)}.should raise_error
end
-
-
describe 'multiple users accepting/rejecting the same person' do
before do
@person_one = Factory.create :person
@@ -144,7 +138,6 @@ describe User do
Person.all.count.should be 3
end
-
end
describe 'a user accepting rejecting multiple people' do
@@ -189,16 +182,14 @@ describe User do
@user2 = Factory.create :user
@aspect2 = @user2.aspect(:name => "Gross people")
- request = @user.send_friend_request_to( @user2, @aspect)
- request.reverse_for @user2
- @user2.activate_friend(@user.person, @aspect2)
- @user.receive request.to_diaspora_xml
+ friend_users(@user, @aspect, @user2, @aspect2)
+ @user.reload
+ @user2.reload
+ @aspect.reload
+ @aspect2.reload
end
it 'should unfriend the other user on the same seed' do
- @user.reload
- @user2.reload
-
@user.friends.count.should == 1
@user2.friends.count.should == 1
@@ -212,8 +203,26 @@ describe User do
@aspect.people.count.should == 0
@aspect2.people.count.should == 0
end
+ context 'with a post' do
+ before do
+ @message = @user.post(:status_message, :message => "hi", :to => @aspect.id)
+ @user2.receive @message.to_diaspora_xml.to_s
+ @user2.unfriend @user.person
+ @user.unfriended_by @user2.person
+ @aspect.reload
+ @aspect2.reload
+ @user.reload
+ @user2.reload
+ end
+ it "deletes the unfriended user's posts from visible_posts" do
+ @user.raw_visible_posts.include?(@message.id).should be_false
+ end
+ it "deletes the unfriended user's posts from the aspect's posts" do
+ pending "We need to implement this"
+ @aspect2.posts.include?(@message).should be_false
+ end
+ end
end
-
end
end
diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb
index ffb220531..040fcd1bc 100644
--- a/spec/models/user/visible_posts_spec.rb
+++ b/spec/models/user/visible_posts_spec.rb
@@ -2,75 +2,91 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../../spec_helper'
+require 'spec_helper'
describe User do
- before do
- @user = Factory.create(:user)
- @aspect = @user.aspect(:name => 'heroes')
- @aspect2 = @user.aspect(:name => 'losers')
+ let!(:user) { Factory(:user_with_aspect) }
+ let!(:first_aspect) { user.aspects.first }
+ let!(:second_aspect) { user.aspect(:name => 'losers') }
- @user2 = Factory.create :user
- @user2_aspect = @user2.aspect(:name => 'dudes')
+ let!(:user2) { Factory(:user_with_aspect) }
- friend_users(@user, @aspect, @user2, @user2_aspect)
+ let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id }
+ let!(:status_message2) { user2.post :status_message, :message => "hey", :public => true , :to => user2.aspects.first.id }
+ let!(:status_message3) { user2.post :status_message, :message => "va", :to => user2.aspects.first.id }
+ let!(:status_message4) { user2.post :status_message, :message => "da", :public => true , :to => user2.aspects.first.id }
- @user3 = Factory.create :user
- @user3_aspect = @user3.aspect(:name => 'dudes')
- friend_users(@user, @aspect2, @user3, @user3_aspect)
- @user4 = Factory.create :user
- @user4_aspect = @user4.aspect(:name => 'dudes')
- friend_users(@user, @aspect2, @user4, @user4_aspect)
- end
+ before do
+ friend_users(user, first_aspect, user2, user2.aspects.first)
+ end
- it 'should generate a valid stream for a aspect of people' do
- status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id
- status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id
- status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id
-
- @user.receive status_message1.to_diaspora_xml
- @user.receive status_message2.to_diaspora_xml
- @user.receive status_message3.to_diaspora_xml
- @user.reload
-
- @user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true
- @user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false
- @user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false
-
- @user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false
- @user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true
- @user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true
+ describe "#visible_posts" do
+ it "queries by person id" do
+ user2.visible_posts(:person_id => user2.person.id).include?(status_message1).should == true
+ user2.visible_posts(:person_id => user2.person.id).include?(status_message2).should == true
+ user2.visible_posts(:person_id => user2.person.id).include?(status_message3).should == true
+ user2.visible_posts(:person_id => user2.person.id).include?(status_message4).should == true
end
- describe 'albums' do
- before do
- @album = @user.post :album, :name => "Georges", :to => @aspect.id
- @aspect.reload
- @aspect2.reload
- @user.reload
+ it "selects public posts" do
+ user2.visible_posts(:public => true).include?(status_message2).should == true
+ user2.visible_posts(:public => true).include?(status_message4).should == true
+ end
- @album2 = @user.post :album, :name => "Borges", :to => @aspect.id
- @aspect.reload
- @aspect2.reload
- @user.reload
+ it "selects non public posts" do
+ user2.visible_posts(:public => false).include?(status_message1).should == true
+ user2.visible_posts(:public => false).include?(status_message3).should == true
+ end
- @user.post :album, :name => "Luises", :to => @aspect2.id
- @aspect.reload
- @aspect2.reload
- @user.reload
- end
+ it "selects by message contents" do
+ user2.visible_posts(:message => "hi").include?(status_message1).should == true
+ end
- it 'should find all albums if passed :all' do
- @user.albums_by_aspect(:all).size.should == 3
- end
+ it "queries by aspect" do
+ user3 = Factory(:user_with_aspect)
+ status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id
+ user4 = Factory(:user_with_aspect)
+ status_message3 = user4.post :status_message, :message => "yooo", :to => user4.aspects.first.id
- it 'should return the right number of albums' do
- @user.albums_by_aspect(@aspect).size.should == 2
- @user.albums_by_aspect(@aspect2).size.should == 1
+ friend_users(user, second_aspect, user3, user3.aspects.first)
+ friend_users(user, second_aspect, user4, user4.aspects.first)
+
+ user.receive status_message1.to_diaspora_xml
+ user.receive status_message2.to_diaspora_xml
+ user.receive status_message3.to_diaspora_xml
+
+ user.visible_posts(:by_members_of => first_aspect).should =~ [status_message1]
+ user.visible_posts(:by_members_of => second_aspect).should =~ [status_message2, status_message3]
+ end
+ end
+
+ context 'querying' do
+ describe '#find_visible_post_by_id' do
+ it 'should query' do
+ user2.find_visible_post_by_id(status_message1.id).should == status_message1
+ user.find_visible_post_by_id(status_message1.id).should == nil
end
end
+ end
+
+ context 'albums' do
+
+ before do
+ user.post :album, :name => "Georges", :to => first_aspect.id
+ user.post :album, :name => "Borges", :to => first_aspect.id
+ user.post :album, :name => "Luises", :to => second_aspect.id
+ user.reload
+ end
+
+ it 'should find all albums if passed :all' do
+ user.albums_by_aspect(:all).should have(3).albums
+ end
+
+ it 'should return the right number of albums' do
+ user.albums_by_aspect(first_aspect.reload).should have(2).albums
+ user.albums_by_aspect(second_aspect.reload).should have(1).album
+ end
+ end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 223881671..d21b1d57c 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2,60 +2,57 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe User do
- before do
- @user = Factory.create(:user)
- @aspect = @user.aspect(:name => 'heroes')
- end
-
- it 'should create with pivotal or allowed emails' do
- user1 = Factory.create(:user, :email => "kimfuh@yahoo.com")
- user2 = Factory.create(:user, :email => "awesome@sofaer.net")
- user3 = Factory.create(:user, :email => "steveellis@pivotallabs.com")
- user1.created_at.nil?.should be false
- user2.created_at.nil?.should be false
- user3.created_at.nil?.should be false
- end
+ let(:user) { Factory(:user) }
- describe 'profiles' do
- it 'should be able to update their profile and send it to their friends' do
- Factory.create(:person)
+ describe "validations" do
+ it "downcases the username" do
+ user = Factory.build(:user, :username => "ALLUPPERCASE")
+ user.valid?
+ user.username.should == "alluppercase"
- updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
-
- @user.update_profile(updated_profile).should == true
- @user.profile.image_url.should == "http://clown.com"
+ user = Factory.build(:user, :username => "someUPPERCASE")
+ user.valid?
+ user.username.should == "someuppercase"
end
end
- describe 'aspects' do
- it 'should delete an empty aspect' do
- @user.aspects.include?(@aspect).should == true
- @user.drop_aspect(@aspect)
- @user.reload
+ describe '#diaspora_handle' do
+ it 'uses the pod config url to set the diaspora_handle' do
+ user.diaspora_handle.should == user.username + "@" + APP_CONFIG[:terse_pod_url]
+ end
+ end
- @user.aspects.include?(@aspect).should == false
+ context 'profiles' do
+ it 'should be able to update their profile and send it to their friends' do
+ updated_profile = { :profile => {
+ :first_name => 'bob',
+ :last_name => 'billytown',
+ :image_url => "http://clown.com"} }
+
+ user.update_profile(updated_profile).should be true
+ user.profile.image_url.should == "http://clown.com"
+ end
+ end
+
+ context 'aspects' do
+ let(:aspect) { user.aspect(:name => 'heroes') }
+ let(:user2) { Factory(:user) }
+ let(:aspect2) { user2.aspect(:name => 'stuff') }
+
+ it 'should delete an empty aspect' do
+ user.drop_aspect(aspect)
+ user.aspects.include?(aspect).should == false
end
it 'should not delete an aspect with friends' do
- user2 = Factory.create(:user)
- aspect2 = user2.aspect(:name => 'stuff')
- user2.reload
- aspect2.reload
-
- friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id))
- @aspect.reload
-
- @user.aspects.include?(@aspect).should == true
-
- proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/
-
- @user.reload
- @user.aspects.include?(@aspect).should == true
+ friend_users(user, Aspect.find_by_id(aspect.id), user2, Aspect.find_by_id(aspect2.id))
+ aspect.reload
+ proc{user.drop_aspect(aspect)}.should raise_error /Aspect not empty/
+ user.aspects.include?(aspect).should == true
end
end
+
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 3fdac9810..4149200d8 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,8 +2,6 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
@@ -16,8 +14,6 @@ require 'webmock/rspec'
include Devise::TestHelpers
include WebMock
-
-
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
@@ -45,6 +41,9 @@ RSpec.configure do |config|
DatabaseCleaner.clean
end
end
+
+ImageUploader.enable_processing = false
+
def stub_sockets
Diaspora::WebSocket.stub!(:queue_to_user).and_return(true)
Diaspora::WebSocket.stub!(:subscribe).and_return(true)
@@ -82,7 +81,12 @@ end
def friend_users(user1, aspect1, user2, aspect2)
request = user1.send_friend_request_to(user2.person, aspect1)
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
+ user1.reload
user1.receive reversed_request.to_diaspora_xml
+ user1.reload
+ aspect1.reload
+ user2.reload
+ aspect2.reload
end
def stub_success(address = 'abc@example.com')
diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb
index 33b86d52c..a7fd8c548 100644
--- a/spec/user_encryption_spec.rb
+++ b/spec/user_encryption_spec.rb
@@ -2,27 +2,16 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
-
-
-require File.dirname(__FILE__) + '/spec_helper'
-include ApplicationHelper
-include Diaspora::Parser
+require 'spec_helper'
describe 'user encryption' do
before do
unstub_mocha_stubs
@user = Factory.create(:user)
@aspect = @user.aspect(:name => 'dudes')
- @person = Factory.create(:person_with_private_key,
- :profile => Profile.new(:first_name => 'Remote',
- :last_name => 'Friend'),
- :diaspora_handle => 'somewhere@else.com',
- :url => 'http://distant-example.com/')
- @person2 = Factory.create(:person_with_private_key,
- :profile => Profile.new(:first_name => 'Second',
- :last_name => 'Friend'),
- :diaspora_handle => 'elsewhere@else.com',
- :url => 'http://distanter-example.com/')
+
+ @user2 = Factory.create(:user)
+ @aspect2 = @user2.aspect(:name => 'dudes')
end
after do
@@ -78,7 +67,10 @@ describe 'user encryption' do
describe 'comments' do
before do
- @remote_message = Factory.create(:status_message, :person => @person)
+ friend_users(@user, @aspect, @user2, @aspect2)
+ @remote_message = @user2.post :status_message, :message => "hello", :to => @aspect2.id
+
+
@message = @user.post :status_message, :message => "hi", :to => @aspect.id
end
it 'should attach the creator signature if the user is commenting' do
@@ -94,24 +86,24 @@ describe 'user encryption' do
end
it 'should verify a comment made on a remote post by a different friend' do
- comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message)
- comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key)
+ comment = Comment.new(:person => @user2.person, :text => "cats", :post => @remote_message)
+ comment.creator_signature = comment.send(:sign_with_key,@user2.encryption_key)
comment.signature_valid?.should be true
comment.verify_post_creator_signature.should be false
- comment.post_creator_signature = comment.send(:sign_with_key,@person.encryption_key)
+ comment.post_creator_signature = comment.send(:sign_with_key,@user.encryption_key)
comment.verify_post_creator_signature.should be true
end
it 'should reject comments on a remote post with only a creator sig' do
- comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message)
- comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key)
+ comment = Comment.new(:person => @user2.person, :text => "cats", :post => @remote_message)
+ comment.creator_signature = comment.send(:sign_with_key,@user2.encryption_key)
comment.signature_valid?.should be true
comment.verify_post_creator_signature.should be false
end
it 'should receive remote comments on a user post with a creator sig' do
- comment = Comment.new(:person => @person2, :text => "balls", :post => @message)
- comment.creator_signature = comment.send(:sign_with_key,@person2.encryption_key)
+ comment = Comment.new(:person => @user2.person, :text => "cats", :post => @message)
+ comment.creator_signature = comment.send(:sign_with_key,@user2.encryption_key)
comment.signature_valid?.should be true
comment.verify_post_creator_signature.should be false
end
diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb
deleted file mode 100644
index 74e8c9421..000000000
--- a/test/performance/browsing_test.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-
-
-require 'test_helper'
-require 'rails/performance_test_help'
-
-# Profiling results for each test method are written to tmp/performance.
-class BrowsingTest < ActionDispatch::PerformanceTest
- def test_homepage
- get '/'
- end
-end
diff --git a/test/selenium/selenium_suite.rb b/test/selenium/selenium_suite.rb
deleted file mode 100644
index d5362b1d7..000000000
--- a/test/selenium/selenium_suite.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-
-
-require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
-require 'test/unit/ui/console/testrunner'
-require 'webrat'
-require 'saucelabs_adapter'
-
-Webrat.configure do |config|
- config.mode = :selenium
- config.application_framework = :rack
-end
-
-require File.join(File.dirname(__FILE__), 'sample_webrat_test')
diff --git a/test/test_helper.rb b/test/test_helper.rb
deleted file mode 100644
index d9742c116..000000000
--- a/test/test_helper.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
-
-
-
-ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- #fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash
deleted file mode 100644
index 67b602abe..000000000
--- a/ubuntu-setup.bash
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/bin/bash
-# Author : hemanth.hm@gmail.com
-# Site : www.h3manth.com
-# This script helps to setup diaspora.
-#
-
-# Set extented globbing
-shopt -s extglob
-
-# Check if the user has sudo privileges.
-[[ $( id -u) ]] && echo "$(whoami) has no sudo permissions on this machine" && exit 1
-
-# Install build tools
-echo "Installing build tools.."
-sudo apt-get -y --no-install-recommends install build-essential libxslt1.1 libxslt1-dev libxml2
-echo "..Done installing build tools"
-
-# Install Ruby 1.8.7
-echo "Installing ruby-full Ruby 1.8.7.."
-sudo apt-get -y --no-install-recommends install ruby-full
-echo "..Done installing Ruby"
-
-# Install Rake
-echo "Installing rake.."
-sudo apt-get -y --no-install-recommends install rake
-echo "..Done installing rake"
-
-# Get the current release and install mongodb
-lsb=$(lsb_release -rs)
-ver=${lsb//.+(0)/.}
-repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen"
-echo "Setting up MongoDB.."
-echo "."
-echo ${repo} | sudo tee -a /etc/apt/sources.list
-echo "."
-echo "Fetching keys.."
-sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
-echo "."
-sudo apt-get update
-echo "."
-sudo apt-get -y --no-install-recommends install mongodb-stable
-echo "Done installing monngodb-stable.."
-
-# Install imagemagick
-echo "Installing imagemagick.."
-sudo apt-get -y --no-install-recommends install imagemagick libmagick9-dev
-echo "Installed imagemagick.."
-
-# Install git-core
-echo "Installing git-core.."
-sudo apt-get -y --no-install-recommends install git-core
-echo "Installed git-core.."
-
-# Setting up ruby gems
-echo "Fetching and installing ruby gems.."
-(
- echo "."
- cd /tmp
- wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
- echo "."
- tar -xf rubygems-1.3.7.tgz
- echo "."
- cd rubygems-1.3.7
- echo "."
- sudo ruby setup.rb
- echo "."
- sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
- echo "."
-)
-echo "Done installing the gems.."
-
-# Install blunder
-echo "Installing blunder.."
-sudo gem install bundler
-echo "Installed blunder.."
-
-# Take a clone of Diaspora
-(
-echo "Clone diaspora source.."
-git clone http://github.com/diaspora/diaspora.git
-echo "Cloned the source.."
-# Install extra gems
-cd diaspora
-echo "Installing more gems.."
-sudo bundle install
-echo "Installed."
-
-# Install DB setup
-echo "Seting up DB.."
-rake db:seed:tom
-echo "DB ready. Login -> tom and password -> evankorth. More details ./diaspora/db/seeds/tom.rb."
-
-# Run appserver
-echo "Starting server"
-bundle exec thin start
-)