37 lines
914 B
Ruby
37 lines
914 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe RemoteStorageExpireAuthorizationJob, type: :job do
|
|
before do
|
|
@user = create :user, cn: "ronald", ou: "kosmos.org"
|
|
@rs_authorization = create :remote_storage_authorization, user: @user, expire_at: 1.day.ago
|
|
end
|
|
|
|
after do
|
|
clear_enqueued_jobs
|
|
clear_performed_jobs
|
|
end
|
|
|
|
subject(:job) {
|
|
described_class.perform_later(@rs_authorization.id)
|
|
}
|
|
|
|
let(:redis) {
|
|
@redis ||= Redis.new(url: Setting.rs_redis_url)
|
|
}
|
|
|
|
it "removes the RS authorization from redis" do
|
|
redis_key = "rs:authorizations:#{@user.address}:#{@rs_authorization.token}"
|
|
expect(redis.keys(redis_key)).to_not be_empty
|
|
|
|
perform_enqueued_jobs { job }
|
|
|
|
expect(redis.keys(redis_key)).to be_empty
|
|
end
|
|
|
|
it "deletes the RS authorization object" do
|
|
expect {
|
|
perform_enqueued_jobs { job }
|
|
}.to change(RemoteStorageAuthorization, :count).by(-1)
|
|
end
|
|
end
|