diff --git a/config/application.yml.example b/config/application.yml.example index b4a92f3b06a312738c59c350e6b46e65e6e22b37..72083ba19f90aa6182f4c3c0698c04af64ac7801 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 9ed970010250d5e3388c575eb1de5bbc4f009b56..9f7bfa013a86393869b671ee97747efabce129cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/features/oauth.feature b/features/oauth.feature index b4ca72831eaecf1d0d25afac2b228cbd9b52aece..482625236194b09e1333315489a25e234f645be9 100644 --- a/features/oauth.feature +++ b/features/oauth.feature @@ -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" diff --git a/features/step_definitions/oauth_steps.rb b/features/step_definitions/oauth_steps.rb index 9092b1adf8996c33f559a41e751eeabb35fb2503..326b8b14beb9116d61269b811c72af5c1385a48d 100644 --- a/features/step_definitions/oauth_steps.rb +++ b/features/step_definitions/oauth_steps.rb @@ -1,12 +1,9 @@ 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}") diff --git a/spec/support/chubbies/Gemfile b/spec/chubbies/Gemfile similarity index 77% rename from spec/support/chubbies/Gemfile rename to spec/chubbies/Gemfile index b0a9d933cd2c45885bedcc1c4f5773a8a71b5c4f..dded43bc26b619e6dcd0be596ea41afda418a4ca 100644 --- a/spec/support/chubbies/Gemfile +++ b/spec/chubbies/Gemfile @@ -7,4 +7,4 @@ gem 'httparty' gem 'json' gem 'shotgun' gem 'sqlite3' -gem 'activerecord' +gem 'activerecord', '3.0.3' diff --git a/spec/support/chubbies/Gemfile.lock b/spec/chubbies/Gemfile.lock similarity index 69% rename from spec/support/chubbies/Gemfile.lock rename to spec/chubbies/Gemfile.lock index cbe76139acdb98dc9ae98776196344d9eb062149..43ab98117d1a1d857a811b088a3e22d4931cd33e 100644 --- a/spec/support/chubbies/Gemfile.lock +++ b/spec/chubbies/Gemfile.lock @@ -1,23 +1,23 @@ 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 diff --git a/spec/support/chubbies/README b/spec/chubbies/README similarity index 100% rename from spec/support/chubbies/README rename to spec/chubbies/README diff --git a/spec/support/chubbies/app.rb b/spec/chubbies/app.rb similarity index 87% rename from spec/support/chubbies/app.rb rename to spec/chubbies/app.rb index 8d55f86d9b1daccdf92e659436db1b9bb77127c4..cf1bb1cf9bbf7d1606e19b07cd87f45da1a78a3a 100644 --- a/spec/support/chubbies/app.rb +++ b/spec/chubbies/app.rb @@ -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 # diff --git a/spec/support/chubbies/config.ru b/spec/chubbies/config.ru similarity index 100% rename from spec/support/chubbies/config.ru rename to spec/chubbies/config.ru diff --git a/spec/support/chubbies/public/chubbies.jpeg b/spec/chubbies/public/chubbies.jpeg similarity index 100% rename from spec/support/chubbies/public/chubbies.jpeg rename to spec/chubbies/public/chubbies.jpeg diff --git a/spec/support/chubbies/views/home.haml b/spec/chubbies/views/home.haml similarity index 100% rename from spec/support/chubbies/views/home.haml rename to spec/chubbies/views/home.haml diff --git a/spec/support/chubbies/views/response.haml b/spec/chubbies/views/response.haml similarity index 100% rename from spec/support/chubbies/views/response.haml rename to spec/chubbies/views/response.haml