[#10799] Add maintenance task to fill api_entreprise_token_expires_at for previous data
This commit is contained in:
parent
6b326b634e
commit
f26ff30538
2 changed files with 34 additions and 0 deletions
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
class UpdateAPIEntrepriseTokenExpiresAtTask < MaintenanceTasks::Task
|
||||
def collection
|
||||
Procedure.where.not(api_entreprise_token: nil)
|
||||
end
|
||||
|
||||
def process(procedure)
|
||||
procedure.set_api_entreprise_token_expires_at
|
||||
procedure.save!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Maintenance
|
||||
RSpec.describe UpdateAPIEntrepriseTokenExpiresAtTask do
|
||||
describe "#process" do
|
||||
subject(:process) { described_class.process(procedure) }
|
||||
|
||||
let(:expiration) { 1.month.from_now.beginning_of_minute }
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
before do
|
||||
procedure.update_column(:api_entreprise_token, JWT.encode({ exp: expiration.to_i }, nil, "none"))
|
||||
end
|
||||
|
||||
it do
|
||||
expect { process }.to change { procedure.reload.api_entreprise_token_expires_at }.from(nil).to(expiration)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue