faster jeton_particulier_controller_spec
This commit is contained in:
parent
2e1bed8748
commit
c87f3f7fb6
1 changed files with 25 additions and 17 deletions
|
@ -9,14 +9,14 @@ describe NewAdministrateur::JetonParticulierController, type: :controller do
|
|||
end
|
||||
|
||||
describe "GET #api_particulier" do
|
||||
let(:procedure) { create :procedure, :with_service, administrateur: admin }
|
||||
|
||||
render_views
|
||||
|
||||
subject { get :api_particulier, params: { procedure_id: procedure.id } }
|
||||
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
it { expect(subject.body).to have_content('Jeton API particulier') }
|
||||
it do
|
||||
is_expected.to have_http_status(:success)
|
||||
expect(subject.body).to have_content('Jeton API particulier')
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
|
@ -41,26 +41,32 @@ describe NewAdministrateur::JetonParticulierController, type: :controller do
|
|||
context "and the api response is a success" do
|
||||
let(:cassette) { "api_particulier/success/introspect" }
|
||||
|
||||
it { expect(flash.alert).to be_nil }
|
||||
it { expect(flash.notice).to eq("Le jeton a bien été mis à jour") }
|
||||
it { expect(procedure.reload.api_particulier_token).to eql(token) }
|
||||
it { expect(procedure.reload.api_particulier_scopes).to contain_exactly("dgfip_avis_imposition", "dgfip_adresse", "cnaf_allocataires", "cnaf_enfants", "cnaf_adresse", "cnaf_quotient_familial", "mesri_statut_etudiant") }
|
||||
it 'saves the jeton' do
|
||||
expect(flash.alert).to be_nil
|
||||
expect(flash.notice).to eq("Le jeton a bien été mis à jour")
|
||||
expect(procedure.reload.api_particulier_token).to eql(token)
|
||||
expect(procedure.reload.api_particulier_scopes).to contain_exactly("dgfip_avis_imposition", "dgfip_adresse", "cnaf_allocataires", "cnaf_enfants", "cnaf_adresse", "cnaf_quotient_familial", "mesri_statut_etudiant")
|
||||
end
|
||||
end
|
||||
|
||||
context "and the api response is a success but with an empty scopes" do
|
||||
let(:cassette) { "api_particulier/success/introspect_empty_scopes" }
|
||||
|
||||
it { expect(flash.alert).to include("le jeton n'a pas acces aux données") }
|
||||
it { expect(flash.notice).to be_nil }
|
||||
it { expect(procedure.reload.api_particulier_token).not_to eql(token) }
|
||||
it 'rejects the jeton' do
|
||||
expect(flash.alert).to include("le jeton n'a pas acces aux données")
|
||||
expect(flash.notice).to be_nil
|
||||
expect(procedure.reload.api_particulier_token).not_to eql(token)
|
||||
end
|
||||
end
|
||||
|
||||
context "and the api response is not unauthorized" do
|
||||
let(:cassette) { "api_particulier/unauthorized/introspect" }
|
||||
|
||||
it { expect(flash.alert).to include("Mise à jour impossible : le jeton n'a pas été trouvé ou n'est pas actif") }
|
||||
it { expect(flash.notice).to be_nil }
|
||||
it { expect(procedure.reload.api_particulier_token).not_to eql(token) }
|
||||
it 'rejects the jeton' do
|
||||
expect(flash.alert).to include("Mise à jour impossible : le jeton n'a pas été trouvé ou n'est pas actif")
|
||||
expect(flash.notice).to be_nil
|
||||
expect(procedure.reload.api_particulier_token).not_to eql(token)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -69,9 +75,11 @@ describe NewAdministrateur::JetonParticulierController, type: :controller do
|
|||
|
||||
before { subject }
|
||||
|
||||
it { expect(flash.alert.first).to include("pas le bon format") }
|
||||
it { expect(flash.notice).to be_nil }
|
||||
it { expect(procedure.reload.api_particulier_token).not_to eql(token) }
|
||||
it 'rejects the jeton' do
|
||||
expect(flash.alert.first).to include("pas le bon format")
|
||||
expect(flash.notice).to be_nil
|
||||
expect(procedure.reload.api_particulier_token).not_to eql(token)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue