[#10799] Move test in right file
This commit is contained in:
parent
c897893e8a
commit
4266a76db6
2 changed files with 51 additions and 51 deletions
|
@ -30,4 +30,55 @@ describe APIEntrepriseTokenConcern do
|
|||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#set_api_entreprise_token_expires_at (before_save)' do
|
||||
let(:procedure) { create(:procedure, api_entreprise_token: initial_api_entreprise_token) }
|
||||
|
||||
before do
|
||||
procedure.api_entreprise_token = api_entreprise_token
|
||||
end
|
||||
|
||||
subject { procedure.save }
|
||||
|
||||
context "when procedure had no api_entreprise_token" do
|
||||
let(:initial_api_entreprise_token) { nil }
|
||||
|
||||
context 'when the api_entreprise_token is nil' do
|
||||
let(:api_entreprise_token) { nil }
|
||||
|
||||
it 'does not set the api_entreprise_token_expires_at' do
|
||||
expect { subject }.not_to change { procedure.api_entreprise_token_expires_at }.from(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the api_entreprise_token is not valid' do
|
||||
let(:api_entreprise_token) { "not a token" }
|
||||
|
||||
it do
|
||||
expect { subject }.not_to change { procedure.api_entreprise_token_expires_at }.from(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the api_entreprise_token is valid' do
|
||||
let(:expiration_date) { Time.zone.now.beginning_of_minute }
|
||||
let(:api_entreprise_token) { JWT.encode({ exp: expiration_date.to_i }, nil, 'none') }
|
||||
|
||||
it do
|
||||
expect { subject }.to change { procedure.api_entreprise_token_expires_at }.from(nil).to(expiration_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when procedure had an api_entreprise_token" do
|
||||
let(:initial_api_entreprise_token) { JWT.encode({ exp: 2.months.from_now.to_i }, nil, "none") }
|
||||
|
||||
context 'when the api_entreprise_token is set to nil' do
|
||||
let(:api_entreprise_token) { nil }
|
||||
|
||||
it do
|
||||
expect { subject }.to change { procedure.api_entreprise_token_expires_at }.to(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1835,57 +1835,6 @@ describe Procedure do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#set_api_entreprise_token_expires_at (before_save)' do
|
||||
let(:procedure) { create(:procedure, api_entreprise_token: initial_api_entreprise_token) }
|
||||
|
||||
before do
|
||||
procedure.api_entreprise_token = api_entreprise_token
|
||||
end
|
||||
|
||||
subject { procedure.save }
|
||||
|
||||
context "when procedure had no api_entreprise_token" do
|
||||
let(:initial_api_entreprise_token) { nil }
|
||||
|
||||
context 'when the api_entreprise_token is nil' do
|
||||
let(:api_entreprise_token) { nil }
|
||||
|
||||
it 'does not set the api_entreprise_token_expires_at' do
|
||||
expect { subject }.not_to change { procedure.api_entreprise_token_expires_at }.from(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the api_entreprise_token is not valid' do
|
||||
let(:api_entreprise_token) { "not a token" }
|
||||
|
||||
it do
|
||||
expect { subject }.not_to change { procedure.api_entreprise_token_expires_at }.from(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the api_entreprise_token is valid' do
|
||||
let(:expiration_date) { Time.zone.now.beginning_of_minute }
|
||||
let(:api_entreprise_token) { JWT.encode({ exp: expiration_date.to_i }, nil, 'none') }
|
||||
|
||||
it do
|
||||
expect { subject }.to change { procedure.api_entreprise_token_expires_at }.from(nil).to(expiration_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when procedure had an api_entreprise_token" do
|
||||
let(:initial_api_entreprise_token) { JWT.encode({ exp: 2.months.from_now.to_i }, nil, "none") }
|
||||
|
||||
context 'when the api_entreprise_token is set to nil' do
|
||||
let(:api_entreprise_token) { nil }
|
||||
|
||||
it do
|
||||
expect { subject }.to change { procedure.api_entreprise_token_expires_at }.to(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parsed_latest_zone_labels" do
|
||||
let!(:draft_procedure) { create(:procedure) }
|
||||
let!(:published_procedure) { create(:procedure_with_dossiers, :published, dossiers_count: 2) }
|
||||
|
|
Loading…
Reference in a new issue