-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
achydra-950: monthly cron to delete stale pending works
- Loading branch information
1 parent
15a6e53
commit a0ee424
Showing
7 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
uid { 'tu123' } | ||
first_name { 'Test' } | ||
last_name { 'User' } | ||
email { '[email protected]' } | ||
sequence(:email) { |n| "tu123#{n}@columbia.edu" } | ||
end | ||
|
||
factory :admin, class: User do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,7 @@ | |
it 'sends student reminder email' do | ||
email = ActionMailer::Base.deliveries.pop | ||
expect(email.subject).to eql 'Department approval may be needed' | ||
expect(email.to).to include '[email protected]' | ||
expect(email.to).to include User.first.email | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
describe 'rake ac:delete_stale_pending_works', type: :task do | ||
context 'when a deposit with no hyacinth identifier' do | ||
let!(:deposit_fresh) { FactoryBot.create(:deposit, :with_user) } | ||
let!(:deposit_stale) do | ||
FactoryBot.create(:deposit, :with_user, created_at: 7.months.ago) | ||
end | ||
|
||
describe 'that is less than 6 months old' do | ||
it 'does not delete the deposit' do | ||
task.execute | ||
expect(Deposit.exists?(deposit_fresh.id)).to be true | ||
end | ||
end | ||
|
||
describe 'that is over 6 months old' do | ||
it 'deletes the deposit' do | ||
task.execute | ||
expect { deposit_stale.reload }.to raise_error(ActiveRecord::RecordNotFound) | ||
end | ||
end | ||
end | ||
|
||
context 'when a deposit with an identifier that is unindexed' do | ||
let(:empty_response) { wrap_solr_response_data('response' => { 'docs' => [] }) } | ||
let!(:deposit_fresh) do | ||
FactoryBot.create(:deposit, :with_user, hyacinth_identifier: 'unindexed') | ||
end | ||
let!(:deposit_stale) do | ||
FactoryBot.create(:deposit, :with_user, created_at: 7.months.ago, hyacinth_identifier: 'unindexed') | ||
end | ||
|
||
before do | ||
allow(AcademicCommons).to receive(:search).and_return(empty_response) | ||
end | ||
|
||
describe 'and is less than 6 months old' do | ||
it 'does not delete the deposit' do | ||
task.execute | ||
expect(Deposit.exists?(deposit_fresh.id)).to be true | ||
end | ||
end | ||
|
||
describe 'and is over 6 months old' do | ||
it 'deletes the deposit' do | ||
task.execute | ||
expect { deposit_stale.reload }.to raise_error(ActiveRecord::RecordNotFound) | ||
end | ||
end | ||
end | ||
|
||
context 'when a deposit with an identifier that is indexed' do | ||
let(:solr_response) do | ||
wrap_solr_response_data( | ||
'response' => { | ||
'docs' => [ | ||
{ 'id' => '10.7916/TESTDOC10', 'title_ssi' => 'First Test Document', 'object_state_ssi' => 'A', | ||
'cul_doi_ssi' => '10.7916/TESTDOC10', 'fedora3_pid_ssi' => 'actest:10', 'genre_ssim' => '', | ||
'publisher_doi_ssi' => '', 'free_to_read_start_date_ssi' => Date.current.tomorrow.strftime('%Y-%m-%d') } | ||
] | ||
} | ||
) | ||
end | ||
let!(:deposit_fresh) do | ||
FactoryBot.create(:deposit, :with_user, hyacinth_identifier: 'actest:10') | ||
end | ||
let!(:deposit_stale) do | ||
FactoryBot.create(:deposit, :with_user, created_at: 7.months.ago, hyacinth_identifier: 'actest:10') | ||
end | ||
|
||
before do | ||
allow(AcademicCommons).to receive(:search).and_return(solr_response) | ||
end | ||
|
||
describe 'and is less than 6 months old' do | ||
it 'does not delete the deposit' do | ||
task.execute | ||
expect(Deposit.exists?(deposit_fresh.id)).to be true | ||
end | ||
end | ||
|
||
describe 'and is over 6 months old' do | ||
it 'does not delete the deposit' do | ||
task.execute | ||
expect(Deposit.exists?(deposit_stale.id)).to be true | ||
end | ||
end | ||
end | ||
end |