From 60e29f6572120384e821fc3fd409b47c9b12a469 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 19 Sep 2010 16:37:34 -0700 Subject: [PATCH] Magent should use the same settings as mongomapper, app config should load first, websocket spec is a little better. --- config/app_config.yml | 6 ++++++ .../{load_app_config.rb => _load_app_config.rb} | 0 config/initializers/_mongo.rb | 3 ++- spec/lib/websocket_spec.rb | 8 ++++---- 4 files changed, 12 insertions(+), 5 deletions(-) rename config/initializers/{load_app_config.rb => _load_app_config.rb} (100%) diff --git a/config/app_config.yml b/config/app_config.yml index 354dc75b2..b4fd6f0ab 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -11,6 +11,8 @@ development: socket_port: 8080 socket_collection_name: 'websocket' pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 test: debug: false @@ -18,6 +20,8 @@ test: socket_host: 0.0.0.0 socket_port: 8081 pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 production: debug: false @@ -25,3 +29,5 @@ production: socket_host: 0.0.0.0 socket_port: 8080 pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 diff --git a/config/initializers/load_app_config.rb b/config/initializers/_load_app_config.rb similarity index 100% rename from config/initializers/load_app_config.rb rename to config/initializers/_load_app_config.rb diff --git a/config/initializers/_mongo.rb b/config/initializers/_mongo.rb index 0409d6d71..8948a0c59 100644 --- a/config/initializers/_mongo.rb +++ b/config/initializers/_mongo.rb @@ -5,7 +5,7 @@ if ENV['MONGOHQ_URL'] MongoMapper.config = {RAILS_ENV => {'uri' => ENV['MONGOHQ_URL']}} else - MongoMapper.connection = Mongo::Connection.new('localhost', 27017) + MongoMapper.connection = Mongo::Connection.new(APP_CONFIG['mongo_host'], APP_CONFIG['mongo_port']) end MongoMapper.database = "diaspora-#{Rails.env}" @@ -16,3 +16,4 @@ if defined?(PhusionPassenger) end end +Magent.connection = Mongo::Connection.new(APP_CONFIG['mongo_host'], APP_CONFIG['mongo_port']) diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb index 018f5020d..edac7051a 100644 --- a/spec/lib/websocket_spec.rb +++ b/spec/lib/websocket_spec.rb @@ -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