Skip to content
Extraits de code Groupes Projets
Valider 67eaafe3 rédigé par danielgrippi's avatar danielgrippi
Parcourir les fichiers

Chubbies no longer saves diaspora_handle from the browser

parent 7aeb3a36
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -139,7 +139,7 @@ production:
# Do not touch unless you know what you're doing
test:
<<: *defaults
pod_url: "http://example.org"
pod_url: "http://localhost:9887"
socket_port: 8081
enable_splunk_logging: false
......@@ -283,7 +283,6 @@ ActiveRecord::Schema.define(:version => 20110603212633) do
t.string "provider_display_name"
t.string "actor_url"
t.integer "objectId"
t.integer "root_id"
t.string "status_message_guid"
end
......
......@@ -3,7 +3,8 @@ Feature: oauth
Exchanging oauth credentials
Background:
Given Chubbies is running
Given Chubbies has been killed
And Chubbies is running
When I visit "/" on Chubbies
And a user with username "bob" and password "secret"
......
Given /^Chubbies is running$/ do
if Chubbies.running?
puts "Chubbies is already running. Killing it."
Chubbies.kill
end
Chubbies.run
at_exit do
Chubbies.kill
end
Chubbies.run unless Chubbies.running?
end
Given /^Chubbies has been killed$/ do
Chubbies.ensure_killed
end
Given /^Chubbies is registered on my pod$/ do
......@@ -47,8 +44,13 @@ class Chubbies
def self.run
@pid = fork do
Process.exec "cd #{Rails.root}/spec/support/chubbies/ && BUNDLE_GEMFILE=Gemfile DIASPORA_PORT=9887 bundle exec rackup -p #{PORT} 2> /dev/null"
Process.exec "cd #{Rails.root}/spec/chubbies/ && BUNDLE_GEMFILE=Gemfile DIASPORA_PORT=9887 bundle exec rackup -p #{PORT} 2> /dev/null"
end
at_exit do
Chubbies.kill
end
while(!running?) do
sleep(1)
end
......@@ -58,6 +60,13 @@ class Chubbies
`kill -9 #{get_pid}`
end
def self.ensure_killed
if !(@killed) && self.running?
self.kill
@killed = true
end
end
def self.running?
begin
RestClient.get("localhost:#{PORT}")
......
......@@ -7,4 +7,4 @@ gem 'httparty'
gem 'json'
gem 'shotgun'
gem 'sqlite3'
gem 'activerecord'
gem 'activerecord', '3.0.3'
GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.7)
activesupport (= 3.0.7)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activesupport (3.0.7)
activesupport (3.0.3)
arel (2.0.10)
builder (2.1.2)
crack (0.1.8)
haml (3.0.18)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.5.0)
i18n (0.6.0)
json (1.4.6)
rack (1.2.2)
shotgun (0.9)
......@@ -33,7 +33,7 @@ PLATFORMS
ruby
DEPENDENCIES
activerecord
activerecord (= 3.0.3)
haml
httparty
json
......
Fichier déplacé
......@@ -5,9 +5,10 @@ require 'haml'
require 'httparty'
require 'json'
require 'active_record'
require 'pp'
# models ======================================
`rm -f chubbies.sqlite3`
`rm -f #{File.expand_path('../chubbies.sqlite3', __FILE__)}`
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "chubbies.sqlite3"
......@@ -75,9 +76,9 @@ get '/callback' do
:code => params["code"],
:grant_type => 'authorization_code'}
)
user = pod.users.create!(:access_token => response["access_token"], :diaspora_handle => params['diaspora_handle'])
redirect "/account?diaspora_handle=#{user.diaspora_handle}"
user = pod.users.create!(:access_token => response["access_token"] )
redirect "/account?id=#{user.id}"
else
"What is your major malfunction?"
end
......@@ -85,12 +86,14 @@ end
get '/account' do
# have diaspora handle
host = domain_from_handle
unless pod = Pod.where(:host => host).first
pod = register_with_pod
if params[:diaspora_handle]
host = domain_from_handle
unless pod = Pod.where(:host => host).first
pod = register_with_pod
end
end
if user = pod.users.where(:diaspora_handle => params['diaspora_handle']).first
if params['id'] && user = User.where(:id => params['id']).first
@resource_response = get_with_access_token(user, "/api/v0/me")
haml :response
else
......@@ -107,6 +110,11 @@ get '/manifest' do
}.to_json
end
get '/reset' do
User.delete_all
Pod.delete_all
"reset."
end
#=============================
#helpers
#
......
Fichier déplacé
Fichier déplacé
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter