Accept custom AR relation for `UploadRecovery`.
This commit is contained in:
parent
6c65718301
commit
0a06b3d977
|
@ -3,8 +3,8 @@ class UploadRecovery
|
||||||
@dry_run = dry_run
|
@dry_run = dry_run
|
||||||
end
|
end
|
||||||
|
|
||||||
def recover
|
def recover(posts = Post)
|
||||||
Post.where("raw LIKE '%upload:\/\/%'").find_each do |post|
|
posts.where("raw LIKE '%upload:\/\/%'").find_each do |post|
|
||||||
begin
|
begin
|
||||||
analyzer = PostAnalyzer.new(post.raw, post.topic_id)
|
analyzer = PostAnalyzer.new(post.raw, post.topic_id)
|
||||||
cooked_stripped = analyzer.send(:cooked_stripped)
|
cooked_stripped = analyzer.send(:cooked_stripped)
|
||||||
|
|
|
@ -46,6 +46,14 @@ RSpec.describe UploadRecovery do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'accepts a custom ActiveRecord relation' do
|
||||||
|
post.update!(updated_at: 2.days.ago)
|
||||||
|
upload.destroy!
|
||||||
|
|
||||||
|
upload_recovery.expects(:recover_from_local).never
|
||||||
|
upload_recovery.recover(Post.where("updated_at >= ?", 1.day.ago))
|
||||||
|
end
|
||||||
|
|
||||||
it 'should recover the upload' do
|
it 'should recover the upload' do
|
||||||
stub_request(:get, "http://test.localhost#{upload.url}")
|
stub_request(:get, "http://test.localhost#{upload.url}")
|
||||||
.to_return(status: 200)
|
.to_return(status: 200)
|
||||||
|
|
Loading…
Reference in New Issue