diff --git a/Gemfile b/Gemfile index 0db9350fa..2bc47e6ce 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,8 @@ gem 'eventmachine' gem 'amqp' gem 'tire' gem 'will_paginate' +gem 'actionmailer' +gem 'sendgrid' group :test do gem 'jam_db', :path=> "#{workspace}/jam-db/target/ruby_package" diff --git a/lib/jam_ruby.rb b/lib/jam_ruby.rb index c930bbac8..dfbb727ff 100644 --- a/lib/jam_ruby.rb +++ b/lib/jam_ruby.rb @@ -6,13 +6,19 @@ require "logging" require "tire" require "will_paginate" require "will_paginate/active_record" +require "action_mailer" +require "sendgrid" require "jam_ruby/errors/permission_error" require "jam_ruby/errors/state_error" require "jam_ruby/errors/jam_argument_error" require "jam_ruby/mq_router" +require "jam_ruby/base_manager" +require "jam_ruby/user_manager" require "jam_ruby/connection_manager" require "jam_ruby/version" require "jam_ruby/environment" +require "jam_ruby/init" +require "jam_ruby/app/mailers/user_mailer" require "jam_ruby/tire_tasks" require "jam_ruby/message_factory" require "jam_ruby/models/genre" diff --git a/lib/jam_ruby/connection_manager.rb b/lib/jam_ruby/connection_manager.rb index d3adb12a6..0ba6111e3 100644 --- a/lib/jam_ruby/connection_manager.rb +++ b/lib/jam_ruby/connection_manager.rb @@ -1,5 +1,5 @@ module JamRuby -# All writes should occur through the ConnectionManager +# All writes should occur through the ConnectionManager for the connection table # Reads can occur freely elsewhere, though # Because connections are tied to the websocket-connection and we bookkeep them in the database purely # for 'SQL convenience', this is a obvious place we can go away from a database @@ -11,19 +11,15 @@ module JamRuby # This may make sense in the short term if we are still managing connections in the database, but # we move to the node-js in the websocket gateway (because the websocket gateway needs to call some of these methods). # Or of course we could just port the relevant methods to node-js - class ConnectionManager + class ConnectionManager < BaseManager - attr_accessor :mq_router, :pg_conn + attr_accessor :mq_router def initialize(options={}) + super(options) @log = Logging.logger[self] @mq_router = MQRouter.new - @pg_conn = options[:conn] @message_factory = MessageFactory.new - - unless PG.threadsafe? - raise Exception, "a non-threadsafe build of libpq is present." - end end def update_staleness() @@ -248,20 +244,6 @@ module JamRuby return friend_ids end - # Creates a connection manager, and associates the connection created by active_record with ourselves - def self.active_record_transaction(&block) - connection_manager = ConnectionManager.new - ActiveRecord::Base.connection_pool.with_connection do |connection| - # create a transaction, and pass the current connection to ConnectionManager. - # this lets the entire operation work with the same transaction, - # across Rails ActiveRecord and the pg-gem based code in ConnectionManager. - connection_manager.pg_conn = connection.instance_variable_get("@connection") - - connection.transaction do - block.call(connection_manager) - end - end - end end end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bef938bf1..d7084d430 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,6 +19,9 @@ require 'factories' include JamRuby +# put ActionMailer into test mode +ActionMailer::Base.delivery_method = :test + #uncomment the following line to use spork with the debugger #require 'spork/ext/ruby-debug'