Skip to content

Commit

Permalink
Inline account creation should not happen within the req cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
mjgiarlo committed Apr 26, 2017
1 parent 3ccd8e1 commit 0699162
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
8 changes: 8 additions & 0 deletions app/jobs/create_account_inline_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateAccountInlineJob < ActiveJob::Base
def perform(account)
CreateSolrCollectionJob.perform_now(account)
CreateFcrepoEndpointJob.perform_now(account)
CreateRedisNamespaceJob.perform_now(account)
CreateDefaultAdminSetJob.perform_now
end
end
5 changes: 1 addition & 4 deletions app/services/create_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def create_tenant
# specifically Solr and Fedora, and creation of the default Admin
# Set.
def create_account_inline
CreateSolrCollectionJob.perform_now(account)
CreateFcrepoEndpointJob.perform_now(account)
CreateRedisNamespaceJob.perform_now(account)
CreateDefaultAdminSetJob.perform_now
CreateAccountInlineJob.perform_later(account)
end

def create_solr_collection
Expand Down
13 changes: 13 additions & 0 deletions spec/jobs/create_account_inline_job_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
RSpec.describe CreateAccountInlineJob do
let(:account) { FactoryGirl.create(:account) }

describe '#perform' do
it 'calls four other jobs synchronously' do
expect(CreateSolrCollectionJob).to receive(:perform_now).with(account)
expect(CreateFcrepoEndpointJob).to receive(:perform_now).with(account)
expect(CreateRedisNamespaceJob).to receive(:perform_now).with(account)
expect(CreateDefaultAdminSetJob).to receive(:perform_now)
described_class.perform_now(account)
end
end
end
7 changes: 2 additions & 5 deletions spec/services/create_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@
end

describe '#create_account_inline' do
it 'calls four jobs inline' do
expect(CreateSolrCollectionJob).to receive(:perform_now).with(account)
expect(CreateFcrepoEndpointJob).to receive(:perform_now).with(account)
expect(CreateRedisNamespaceJob).to receive(:perform_now).with(account)
expect(CreateDefaultAdminSetJob).to receive(:perform_now)
it 'queues a background job' do
expect(CreateAccountInlineJob).to receive(:perform_later).with(account)
subject.create_account_inline
end
end
Expand Down

0 comments on commit 0699162

Please sign in to comment.