2014-12-16 05:57:57 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe JamTracksCleaner do
|
|
|
|
|
include UsesTempFiles
|
|
|
|
|
include CarrierWave::Test::Matchers
|
|
|
|
|
RIGHT_NAME = 'abc.jkz'
|
|
|
|
|
in_directory_with_file(RIGHT_NAME)
|
|
|
|
|
|
|
|
|
|
before (:all) do
|
|
|
|
|
@user = FactoryGirl.create(:user)
|
|
|
|
|
@jam_track = FactoryGirl.create(:jam_track)
|
|
|
|
|
original_storage = JamTrackRightUploader.storage = :fog
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
after(:all) do
|
|
|
|
|
JamTrackRightUploader.storage = @original_storage
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
|
content_for_file('abc')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "should clean" do
|
2015-05-11 21:52:58 +00:00
|
|
|
pending "re-enable cleaner after manual testing"
|
2014-12-16 05:57:57 +00:00
|
|
|
jam_track_right = JamTrackRight.create(:user=>@user, :jam_track=>@jam_track)
|
2015-05-01 17:09:18 +00:00
|
|
|
jam_track_right.signed_48=true
|
2014-12-16 05:57:57 +00:00
|
|
|
jam_track_right
|
|
|
|
|
|
2015-02-25 23:19:03 +00:00
|
|
|
jam_track_right.url_48.store!(File.open(RIGHT_NAME))
|
2014-12-16 05:57:57 +00:00
|
|
|
jam_track_right.downloaded_since_sign=true
|
|
|
|
|
jam_track_right.save!
|
|
|
|
|
|
2015-05-01 17:09:18 +00:00
|
|
|
jam_track_right[:url_48].should == jam_track_right.store_dir + '/' + jam_track_right.filename(:url_48)
|
2014-12-16 05:57:57 +00:00
|
|
|
jam_track_right.reload
|
|
|
|
|
|
|
|
|
|
# Should exist after uploading:
|
2015-02-25 23:19:03 +00:00
|
|
|
url = jam_track_right[:url_48]
|
2014-12-16 05:57:57 +00:00
|
|
|
s3 = S3Manager.new(APP_CONFIG.aws_bucket, APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
|
|
|
|
|
|
|
|
|
|
url.should_not be_nil
|
|
|
|
|
s3 = S3Manager.new(APP_CONFIG.aws_bucket, APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
|
2015-02-25 23:19:03 +00:00
|
|
|
s3.exists?(jam_track_right[:url_48]).should be_true
|
2014-12-16 05:57:57 +00:00
|
|
|
|
|
|
|
|
JamRuby::JamTracksCleaner.perform
|
|
|
|
|
s3.exists?(url).should be_true
|
|
|
|
|
s3 = S3Manager.new(APP_CONFIG.aws_bucket, APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
|
|
|
|
|
jam_track_right.update_attribute("updated_at", 6.minutes.ago)
|
|
|
|
|
|
|
|
|
|
# But not after running cleaner job:
|
|
|
|
|
JamRuby::JamTracksCleaner.perform
|
2015-05-11 21:52:58 +00:00
|
|
|
s3.exists?(url).should be_false
|
2014-12-16 05:57:57 +00:00
|
|
|
end
|
|
|
|
|
end
|