Skip to content

Commit

Permalink
sidekiq for endow funds report
Browse files Browse the repository at this point in the history
  • Loading branch information
tallenaz committed Dec 2, 2016
1 parent 2d7005f commit eef7b74
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ bundler_args: --without production
script:
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
services:
- redis-server
1 change: 1 addition & 0 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/passenger'
require 'capistrano/sidekiq'
require 'dlss/capistrano'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ gem 'faraday'
gem 'config'
# Use okcomputer to set up checks to monitor
gem 'okcomputer'
# Use sidekiq for background jobs
gem 'sidekiq'

group :production do
gem 'activerecord-oracle_enhanced-adapter'
Expand All @@ -47,6 +49,7 @@ group :deployment do
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-passenger'
gem 'capistrano-sidekiq'
gem 'dlss-capistrano'
end

Expand Down
16 changes: 15 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ GEM
capistrano-bundler (~> 1.1)
capistrano-releaseboard (0.0.1)
faraday
capistrano-sidekiq (0.10.0)
capistrano
sidekiq (>= 3.4)
capybara (2.8.0)
addressable
mime-types (>= 1.16)
Expand All @@ -91,6 +94,7 @@ GEM
config (1.3.0)
activesupport (>= 3.0)
deep_merge (~> 1.1.1)
connection_pool (2.2.1)
coveralls (0.8.15)
json (>= 1.8, < 3)
simplecov (~> 0.12.0)
Expand Down Expand Up @@ -150,6 +154,8 @@ GEM
pkg-config (1.1.7)
powerpack (0.1.1)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.7.1)
Expand Down Expand Up @@ -180,6 +186,7 @@ GEM
rake (11.2.2)
rdoc (4.2.2)
json (~> 1.4)
redis (3.3.2)
ref (2.0.0)
rspec-core (3.5.2)
rspec-support (~> 3.5.0)
Expand Down Expand Up @@ -219,6 +226,11 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sidekiq (4.2.7)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (~> 3.2, >= 3.2.1)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
Expand Down Expand Up @@ -270,6 +282,7 @@ DEPENDENCIES
capistrano-bundler
capistrano-passenger
capistrano-rails
capistrano-sidekiq
capybara
composite_primary_keys (= 8.1.4)
config
Expand All @@ -287,10 +300,11 @@ DEPENDENCIES
sass-rails (~> 5.0)
scss_lint
sdoc (~> 0.4.0)
sidekiq
sqlite3
sul_styles
therubyracer
web-console (~> 2.0)

BUNDLED WITH
1.12.5
1.13.6
2 changes: 1 addition & 1 deletion app/controllers/concerns/endow_funds_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def submit_endow_funds(batch_params)
email(batch_params, report_params)
fund_str(batch_params, report_params)
date_range(batch_params, report_params)
request_conn('endow_rpt.cgi', report_params)
EndowFundsJob.perform_later('endow_rpt.cgi', report_params)
end

private
Expand Down
10 changes: 10 additions & 0 deletions app/jobs/endow_funds_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# asychronous processing for endowed funds symphony call
class EndowFundsJob < ActiveJob::Base
include EndowFundsParams
include SymphonyCgi
queue_as :default

def perform(*args)
request_conn(args[0], args[1])
end
end
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ class Application < Rails::Application
config.active_record.raise_in_transactional_callbacks = true
config.autoload_paths += %W(#{config.root}/lib)
config.sass.load_paths << File.expand_path('../../vendor/assets/stylesheets/')
config.active_job.queue_adapter = :sidekiq
end
end
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Rails.application.routes.draw do

require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq'

get 'home/index'

get 'webauth/login' => 'authentication#login', as: :login
Expand Down
25 changes: 25 additions & 0 deletions spec/jobs/endow_funds_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'rails_helper'

RSpec.describe EndowFundsJob, type: :job do
include ActiveJob::TestHelper

subject(:job) { EndowFundsJob.perform_later('endow_rpt.cgi', email: 'test@stanford.edu') }

it 'queues the job' do
expect { job }.to change(ActiveJob::Base.queue_adapter.enqueued_jobs, :size).by(1)
end

it 'is in the default queue' do
expect(EndowFundsJob.new.queue_name).to eq('default')
end

it 'executes perform' do
# how to test request_conn(args[0], args[1])?
perform_enqueued_jobs { job }
end

after do
clear_enqueued_jobs
clear_performed_jobs
end
end

0 comments on commit eef7b74

Please sign in to comment.