Merge branch 'master' into follow

Conflicts:
	features/step_definitions/user_steps.rb
This commit is contained in:
danielgrippi 2011-05-17 11:33:35 -07:00
commit 775e7b6b2b
21 changed files with 173 additions and 57 deletions

View file

@ -8,10 +8,10 @@ gem 'bundler', '>= 1.0.0'
gem 'chef', '0.9.12', :require => false
gem 'ohai', '0.5.8', :require => false #Chef dependency
gem 'nokogiri', '1.4.3.1'
gem 'nokogiri'
#Security
gem 'devise', '1.3.1'
gem 'devise', '~> 1.3.1'
gem 'devise_invitable', '0.5.0'
#Authentication
@ -61,7 +61,7 @@ gem 'SystemTimer', '1.2.1' unless RUBY_VERSION.include? '1.9' || RUBY_PLATFORM =
group :development do
gem 'capistrano', '2.5.19', :require => false
gem 'capistrano-ext', '1.2.1', :require => false
gem 'sod', :git => "git://github.com/MikeSofaer/sod.git"
gem 'sod', :git => "git://github.com/MikeSofaer/sod.git", :require => false
end
group :test, :development do
@ -80,7 +80,7 @@ group :test do
gem 'cucumber-rails', '0.3.2'
gem 'rspec', '>= 2.0.0'
gem 'rspec-rails', '>= 2.0.0'
gem 'rcov'
gem 'rcov', :require => false
gem 'database_cleaner', '0.6.0'
gem 'webmock', :require => false
gem 'jasmine', :path => 'vendor/gems/jasmine', :require => false

View file

@ -156,9 +156,9 @@ GEM
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.15)
daemons (1.1.2)
daemons (1.1.3)
database_cleaner (0.6.0)
devise (1.3.1)
devise (1.3.4)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
@ -185,7 +185,7 @@ GEM
fastthread (1.0.7)
ffi (0.6.3)
rake (>= 0.8.7)
fixture_builder (0.2.0)
fixture_builder (0.2.2)
fog (0.3.25)
builder
excon (>= 0.2.4)
@ -202,12 +202,12 @@ GEM
rspec (~> 2.0)
rspec-instafail (~> 0.1.4)
gem_plugin (0.2.3)
gherkin (2.3.6)
gherkin (2.3.8)
json (>= 1.4.6)
haml (3.0.25)
hashie (0.4.0)
highline (1.6.1)
http_connection (1.4.0)
highline (1.6.2)
http_connection (1.4.1)
i18n (0.5.0)
i18n-inflector (2.5.1)
i18n (>= 0.4.1)
@ -224,7 +224,7 @@ GEM
configuration (>= 0.0.5)
rake (>= 0.8.1)
linecache (0.43)
mail (2.2.15)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@ -245,7 +245,7 @@ GEM
gem_plugin (>= 0.2.3)
multi_json (0.0.5)
multi_xml (0.2.2)
multipart-post (1.1.0)
multipart-post (1.1.1)
mysql2 (0.2.6)
net-ldap (0.1.1)
net-scp (1.0.4)
@ -253,7 +253,7 @@ GEM
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.0.24)
net-ssh-gateway (1.0.1)
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.4.3.1)
oa-basic (0.1.6)
@ -366,8 +366,8 @@ GEM
ffi (~> 0.6.3)
json_pure
rubyzip
simple_oauth (0.1.4)
sinatra (1.2.3)
simple_oauth (0.1.5)
sinatra (1.2.6)
rack (~> 1.1)
tilt (< 2.0, >= 1.2.2)
subexec (0.0.4)
@ -378,7 +378,7 @@ GEM
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.2.2)
tilt (1.3)
treetop (1.4.9)
polyglot (>= 0.3.1)
typhoeus (0.2.4)
@ -415,7 +415,7 @@ DEPENDENCIES
cloudfiles (= 1.4.10)
cucumber-rails (= 0.3.2)
database_cleaner (= 0.6.0)
devise (= 1.3.1)
devise (~> 1.3.1)
devise_invitable (= 0.5.0)
em-websocket!
excon (= 0.2.4)
@ -435,7 +435,7 @@ DEPENDENCIES
mini_magick (= 3.2)
mongrel
mysql2 (= 0.2.6)
nokogiri (= 1.4.3.1)
nokogiri
ohai (= 0.5.8)
omniauth (= 0.1.6)
rails (= 3.0.3)

View file

@ -42,10 +42,10 @@ See [here](http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.
for when to rebase.
We need you to fill out a
[contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq)
[contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/spreadsheet/viewform?formkey=dFdRTnY0TGtfaklKQXZNUndsMlJ2eGc6MQ)
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).
[here](https://spreadsheets.google.com/a/joindiaspora.com/spreadsheet/viewform?formkey=dFdRTnY0TGtfaklKQXZNUndsMlJ2eGc6MQ).
We're currently working on revising it more details on what we're going for can be found [here](http://blog.joindiaspora.com/licensing.html).
## Resources
@ -73,4 +73,4 @@ 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), [corresponding public key (keyID: 77485064)](http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0xCC6CAED977485064).
[exploits@joindiaspora.com](mailto:exploits@joindiaspora.com), [corresponding public key (keyID: 77485064)](http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0xCC6CAED977485064).

View file

@ -103,4 +103,8 @@ class ApplicationController < ActionController::Base
def grammatical_gender
@grammatical_gender || nil
end
def after_sign_in_path_for(resource)
stored_location_for(:user) || aspects_path(:a_ids => current_user.aspects.where(:open => true).select(:id).all.map{|a| a.id})
end
end

View file

@ -2,9 +2,13 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
:javascript
WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}";
$(document).ready(function(){
WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/");
});
-if AppConfig[:single_process_mode]
:javascript
var websocket_enabled = false
- else
:javascript
var websocket_enabled = true
WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}";
$(document).ready(function(){
WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/");
});

View file

@ -96,6 +96,9 @@ default:
# It is false by default in development and test.
enable_splunk_logging: true
# Process jobs in process?
single_process_mode: true
development:
enable_splunk_logging: false
@ -105,3 +108,4 @@ test:
enable_splunk_logging: false
production:
single_process_mode: false

View file

@ -1,5 +1,20 @@
require File.join(Rails.root, 'app', 'models', 'jobs', 'base')
Dir[File.join(Rails.root, 'app', 'models', 'jobs', '*.rb')].each { |file| require file }
#config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))
#Resque.redis = Redis.new(:host => config['host'], :port => config['port'])
require 'resque'
begin
if AppConfig[:single_process_mode]
if Rails.env == 'production'
puts "WARNING: You are running Diaspora in production without Resque workers turned on. Please don't do this."
end
module Resque
def enqueue(klass, *args)
klass.send(:perform, *args)
end
end
end
rescue
nil
end

View file

@ -2,7 +2,6 @@
# Included by script/server
#
THIN_PORT=3000
SOCKET_PORT=8080
# Choose one mode by uncommenting
export RAILS_ENV='development'

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110514182918) do
ActiveRecord::Schema.define(:version => 20110517180148) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false

View file

@ -14,3 +14,16 @@ Feature: Change password
Then I should be on the new user session page
When I sign in with password "newsecret"
Then I should be on the aspects page
Scenario: Reset my password
Given a user with email "forgetful@users.net"
Given I am on the new user password page
And I fill in "Email" with "forgetful@users.net"
And I press "Send me reset password instructions"
Then I should see "You will receive an email with instructions"
And I follow the "Change my password" link from the Devise.mailer
Then I should see "Change your password"
And I fill in "Password" with "supersecret"
And I fill in "Password confirmation" with "supersecret"
And I press "Change my password"
Then I should see "Your password was changed successfully"

View file

@ -187,3 +187,11 @@ When /^I add the person to a new aspect called "([^\"]*)"$/ do |aspect_name|
And I press the first ".toggle.button"
}
end
And /^I follow the "([^\"]*)" link from the Devise.mailer$/ do |link_text|
doc = Nokogiri(Devise.mailer.deliveries.first.body.to_s)
links = doc.css('a')
link = links.detect{ |link| link.text == link_text }
path = link.attributes["href"].value
visit URI::parse(path).request_uri
end

View file

@ -48,6 +48,7 @@ include HelperMethods
Before do
DatabaseCleaner.clean
Devise.mailer.deliveries = []
end
silence_warnings do

View file

@ -1,4 +1,4 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
@ -14,6 +14,10 @@ class AppConfig
config_vars[key] = value
end
def self.has_key?(key)
config_vars.has_key?(key)
end
def self.configure_for_environment(env)
load_config_for_environment(env)
generate_pod_uri

View file

@ -60,11 +60,19 @@ module Diaspora
module Socketable
def socket_to_user(user_or_id, opts={})
SocketsController.new.outgoing(user_or_id, self, opts)
begin
SocketsController.new.outgoing(user_or_id, self, opts)
rescue
nil
end
end
def unsocket_from_user(user_or_id, opts={})
SocketsController.new.outgoing(user_or_id, Retraction.for(self), opts)
begin
SocketsController.new.outgoing(user_or_id, Retraction.for(self), opts)
rescue
nil
end
end
end
end

View file

@ -6,14 +6,16 @@ var WebSocketReceiver = {
//Attach onmessage to websocket
ws.onmessage = WSR.onMessage;
ws.onclose = function() {
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification">' +
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>',
incrementCount: false
});
if (websocket_enabled) {
Diaspora.widgets.notifications.showNotification({
html: '<div class="notification">' +
Diaspora.widgets.i18n.t("web_sockets.disconnected") +
'</div>',
incrementCount: false
});
WSR.debug("socket closed");
WSR.debug("socket closed");
}
};
ws.onopen = function() {
ws.send(location.pathname);

42
script/get_config.rb Executable file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env ruby
# Copyright (c) 2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'rubygems'
require 'yaml'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext/hash/keys'
class Rails
def self.root
File.join(File.dirname(__FILE__), "..")
end
def self.env
env = 'development'
env = ENV['RAILS_ENV'] if ENV.has_key?('RAILS_ENV')
env = ARGV[1] if ARGV.length == 2
env.downcase
end
end
require File.join(Rails.root, 'lib', 'app_config')
if ARGV.length >= 1
key = ARGV[0].to_sym
AppConfig.configure_for_environment(Rails.env)
if AppConfig.has_key?(key)
print AppConfig[key]
else
puts "Invalid option #{ARGV[0]}"
exit 2
end
else
puts "Usage: ./script/get_config.rb option [environment]"
puts ""
puts "envrionment defaults to development"
exit 1
end

View file

@ -10,6 +10,7 @@ OS=`uname -s`
[ -e config/server.sh ] && source config/server.sh
export SOCKET_PORT=$(./script/get_config.rb socket_port $RAILS_ENV)
function init_public
# Create all dynamically generated files in public/ folder
@ -121,10 +122,6 @@ if [ -n "$services" ]; then
exit 64
fi
redis_config
# Force AGPL
if [ -w public -a ! -e public/source.tar.gz ]; then
branch=$( git branch | awk '/^[*]/ {print $2}')
@ -169,7 +166,12 @@ if [ ! -e 'public/assets/default.css' ]; then
fi
mkdir -p -v log/thin/
bundle exec ruby ./script/websocket_server.rb&
redis-server config/redis.conf &>log/redis-console.log &
QUEUE=* bundle exec rake resque:work&
if [ "$(./script/get_config.rb single_process_mode $RAILS_ENV)" = "false" ]; then
redis_config
redis-server config/redis.conf &>log/redis-console.log &
QUEUE=* bundle exec rake resque:work&
bundle exec ruby ./script/websocket_server.rb&
fi
bundle exec thin start $args

View file

@ -69,7 +69,7 @@ begin
debug_pp cookie
user_id = cookie["warden.user.user.key"].last
user_id = cookie["warden.user.user.key"][1].first
debug_pp "In WSS, suscribing user: #{User.find(user_id).name} with id: #{user_id}"
sid = Diaspora::WebSocket.subscribe(user_id, ws)

View file

@ -63,9 +63,10 @@ describe RegistrationsController do
flash[:notice].should_not be_empty
end
it "redirects to the root path" do
it "redirects to the home path" do
get :create, @valid_params
response.should redirect_to root_path
response.should be_redirect
response.location.should match /^#{aspects_url}\??$/
end
end
@ -99,4 +100,4 @@ describe RegistrationsController do
end
end
end
end
end

View file

@ -24,15 +24,17 @@ describe SessionsController do
end
describe "#create" do
it "redirects to / for a non-mobile user" do
it "redirects to /aspects for a non-mobile user" do
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.should redirect_to root_path
response.should be_redirect
response.location.should match /^#{aspects_url}\??$/
end
it "redirects to / for a mobile user" do
it "redirects to /aspects for a mobile user" do
@request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7'
post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}}
response.should redirect_to root_path
response.should be_redirect
response.location.should match /^#{aspects_url}\??$/
end
it 'queues up an update job' do
@ -59,4 +61,4 @@ describe SessionsController do
response.should redirect_to root_path
end
end
end
end

View file

@ -63,4 +63,11 @@ describe Diaspora::Socketable do
Diaspora::WebSocket.should_receive(:queue_to_user)
@post.socket_to_user(@user, :aspect_ids => @aspect.id)
end
it 'no-ops if redis isnt present' do
Diaspora::WebSocket.stub(:redis).and_return(nil)
lambda {
@post.socket_to_user(@user, :aspect_ids => @aspect.id)
}.should_not raise_error
end
end