remove a couple more stray files we dont use anymore, and remove rest-client
This commit is contained in:
parent
86c0a62373
commit
af1109dcf7
5 changed files with 6 additions and 175 deletions
1
Gemfile
1
Gemfile
|
|
@ -90,7 +90,6 @@ gem 'resque', '1.20.0'
|
|||
gem 'resque-timeout', '1.0.0'
|
||||
gem 'SystemTimer', '1.2.3', :platforms => :ruby_18
|
||||
|
||||
gem 'rest-client' #why, need to switch to faraday
|
||||
# tags
|
||||
|
||||
gem 'acts-as-taggable-on', '~> 2.2.2'
|
||||
|
|
|
|||
|
|
@ -529,7 +529,6 @@ DEPENDENCIES
|
|||
remotipart (~> 1.0)
|
||||
resque (= 1.20.0)
|
||||
resque-timeout (= 1.0.0)
|
||||
rest-client
|
||||
roxml!
|
||||
rpm_contrib (~> 2.1.7)
|
||||
rspec (>= 2.0.0)
|
||||
|
|
|
|||
|
|
@ -4,20 +4,16 @@
|
|||
|
||||
|
||||
class Pubsubhubbub
|
||||
H = {"User-Agent" => "PubSubHubbub Ruby", "Content-Type" => "application/x-www-form-urlencoded"}
|
||||
|
||||
def initialize(hub, options={})
|
||||
@headers = H.merge(options[:head]) if options[:head]
|
||||
@hub = hub
|
||||
end
|
||||
|
||||
def publish(feed)
|
||||
begin
|
||||
return RestClient.post(@hub, :headers => @headers, 'hub.url' => feed, 'hub.mode' => 'publish')
|
||||
rescue RestClient::BadRequest=> e
|
||||
Rails.logger.warn "Public URL for your users are incorrect. (This is ok if you are in development and localhost is your pod_url) #{e.inspect}"
|
||||
rescue SocketError
|
||||
Rails.logger.warn "Pod not connected to the internet. Cannot post to pubsub hub!"
|
||||
conn = Faraday.new do |c|
|
||||
c.use Faraday::Request::UrlEncoded # encode request params as "www-form-urlencoded"
|
||||
c.use Faraday::Response::Logger # log request & response to STDOUT
|
||||
c.use Faraday::Adapter::NetHttp # perform requests with Net::HTTP
|
||||
end
|
||||
conn.post @hub, {'hub.url' => feed, 'hub.mode' => 'publish'}
|
||||
end
|
||||
end
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
begin
|
||||
namespace :integration do
|
||||
desc "rebuild and prepare test db"
|
||||
task :gogogo => ['db:integration:prepare', :start_servers, :run_specs]
|
||||
|
||||
task :start_servers => :environment do
|
||||
abcs = ActiveRecord::Base.configurations
|
||||
envs = abcs.keys.select{ |k| k.include?("integration") }
|
||||
if servers_active?(envs.map{ |env| abcs[env]["app_server_port"] })
|
||||
puts "Servers are already running, using running integration servers."
|
||||
next
|
||||
end
|
||||
$integration_server_pids = []
|
||||
envs.each do |env|
|
||||
$integration_server_pids << fork do
|
||||
Process.exec "thin start -e #{env} -p #{abcs[env]["app_server_port"]}"
|
||||
end
|
||||
end
|
||||
while(!servers_active?(envs.map{ |env| abcs[env]["app_server_port"] })) do
|
||||
sleep(1)
|
||||
end
|
||||
end
|
||||
|
||||
task :run_servers => :start_servers do
|
||||
while(true) do
|
||||
sleep 1000
|
||||
end
|
||||
end
|
||||
|
||||
require 'rspec/core'
|
||||
require 'rspec/core/rake_task'
|
||||
RSpec::Core::RakeTask.new(:run_specs => :start_servers) do |t|
|
||||
t.pattern = "./spec/multi_server/**/*_spec.rb"
|
||||
end
|
||||
|
||||
def servers_active? ports
|
||||
begin
|
||||
ports.each { |port| RestClient.get("localhost:#{port}/users/sign_in") }
|
||||
true
|
||||
rescue
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
rescue MissingSourceFile
|
||||
end
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
#This class is for running servers in the background during integration testing. This will not run on Windows.
|
||||
class Server
|
||||
def self.start
|
||||
WebMock::Config.instance.allow_localhost = true
|
||||
enable_typhoeus
|
||||
end
|
||||
|
||||
def self.stop
|
||||
disable_typhoeus
|
||||
WebMock::Config.instance.allow_localhost = false
|
||||
end
|
||||
|
||||
def self.truncate_databases
|
||||
all.each{|s| s.truncate_database }
|
||||
end
|
||||
|
||||
def self.[] index
|
||||
self.all[index]
|
||||
end
|
||||
|
||||
def self.all
|
||||
@servers ||= ActiveRecord::Base.configurations.keys.select{
|
||||
|k| k.include?("integration")
|
||||
}.map{ |k| self.new(k) }
|
||||
end
|
||||
|
||||
attr_reader :port, :env
|
||||
def initialize(env)
|
||||
@db_config = ActiveRecord::Base.configurations[env]
|
||||
@app_config = (YAML.load_file AppConfig.source)[env]
|
||||
@port = URI::parse(@app_config["pod_url"]).port
|
||||
@env = env
|
||||
ensure_database_setup
|
||||
end
|
||||
|
||||
def ensure_database_setup
|
||||
@@databases_setup = lambda {
|
||||
`cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:create`
|
||||
tables_exist = self.db do
|
||||
ActiveRecord::Base.connection.tables.include?("users")
|
||||
end
|
||||
if tables_exist
|
||||
truncate_database
|
||||
else
|
||||
`cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec rake db:schema:load`
|
||||
end
|
||||
true}.call
|
||||
end
|
||||
|
||||
def run
|
||||
@pid = fork do
|
||||
Process.exec "cd #{Rails.root} && RAILS_ENV=#{@env} bundle exec #{run_command}"# 2> /dev/null"
|
||||
end
|
||||
end
|
||||
|
||||
def kill
|
||||
puts "I am trying to kill the server"
|
||||
`kill -9 #{get_pid}`
|
||||
end
|
||||
|
||||
def run_command
|
||||
"rails s -p #{@port}"
|
||||
end
|
||||
|
||||
def get_pid
|
||||
@pid = lambda {
|
||||
processes = `ps ax -o pid,command | grep "#{run_command}"`.split("\n")
|
||||
processes = processes.select{|p| !p.include?("grep") }
|
||||
processes.first.split(" ").first
|
||||
}.call
|
||||
end
|
||||
|
||||
def running?
|
||||
begin
|
||||
RestClient.get("localhost:#{@port}/users/sign_in")
|
||||
true
|
||||
rescue Errno::ECONNREFUSED
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def db
|
||||
former_env = Rails.env
|
||||
ActiveRecord::Base.establish_connection(env)
|
||||
begin
|
||||
result = yield
|
||||
ensure
|
||||
ActiveRecord::Base.establish_connection(former_env)
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def truncate_database
|
||||
db do
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
end
|
||||
end
|
||||
|
||||
def in_scope
|
||||
pod_url = "http://localhost:#{@port}/"
|
||||
old_pod_url = AppConfig[:pod_url]
|
||||
AppConfig[:pod_url] = pod_url
|
||||
begin
|
||||
result = db do
|
||||
yield
|
||||
end
|
||||
ensure
|
||||
AppConfig[:pod_url] = old_pod_url
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue