graphql_controller_spec: create all types de champs only when required
Creating a procedure with all available types de champ is slow. We can create a simpler procedure in the default case, and only create all types de champs when the example requires it. Speeds up this spec from 1m 55s to 0m 57s.
This commit is contained in:
parent
e02251c0e5
commit
f0e045ad25
1 changed files with 56 additions and 48 deletions
|
@ -1,10 +1,11 @@
|
|||
describe API::V2::GraphqlController do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:token) { admin.renew_api_token }
|
||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
|
||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, administrateurs: [admin]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_individual, procedure: procedure) }
|
||||
let(:dossier1) { create(:dossier, :en_construction, :with_individual, procedure: procedure, en_construction_at: 1.day.ago) }
|
||||
let(:dossier2) { create(:dossier, :en_construction, :with_individual, :archived, procedure: procedure, en_construction_at: 3.days.ago) }
|
||||
#let(:dossiers) { [dossier2, dossier1, dossier] }
|
||||
let(:dossiers) { [dossier2, dossier1, dossier] }
|
||||
let(:instructeur) { create(:instructeur, followed_dossiers: dossiers) }
|
||||
|
||||
|
@ -107,7 +108,10 @@ describe API::V2::GraphqlController do
|
|||
end
|
||||
|
||||
describe "demarche" do
|
||||
it "should be returned" do
|
||||
describe "query a demarche" do
|
||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
|
||||
|
||||
it "returns the demarche" do
|
||||
expect(gql_errors).to eq(nil)
|
||||
expect(gql_data).to eq(demarche: {
|
||||
id: procedure.to_typed_id,
|
||||
|
@ -155,6 +159,7 @@ describe API::V2::GraphqlController do
|
|||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
describe "filter dossiers" do
|
||||
let(:query) do
|
||||
|
@ -300,7 +305,8 @@ describe API::V2::GraphqlController do
|
|||
dossier
|
||||
end
|
||||
|
||||
context "with individual" do
|
||||
context "for individual" do
|
||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, :with_all_annotations, administrateurs: [admin]) }
|
||||
let(:query) do
|
||||
"{
|
||||
dossier(number: #{dossier.id}) {
|
||||
|
@ -452,7 +458,7 @@ describe API::V2::GraphqlController do
|
|||
end
|
||||
end
|
||||
|
||||
context "with entreprise" do
|
||||
context "for entreprise" do
|
||||
let(:procedure_for_entreprise) { create(:procedure, :published, administrateurs: [admin]) }
|
||||
let(:dossier) { create(:dossier, :en_construction, :with_entreprise, procedure: procedure_for_entreprise) }
|
||||
|
||||
|
@ -725,7 +731,7 @@ describe API::V2::GraphqlController do
|
|||
}
|
||||
end
|
||||
|
||||
context "when file is really big" do
|
||||
context "when the file is really big" do
|
||||
before do
|
||||
champ.piece_justificative_file.blob.update(byte_size: byte_size)
|
||||
end
|
||||
|
@ -1325,6 +1331,8 @@ describe API::V2::GraphqlController do
|
|||
end
|
||||
|
||||
describe 'dossierModifierAnnotation' do
|
||||
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_annotations, administrateurs: [admin]) }
|
||||
|
||||
describe 'text' do
|
||||
let(:query) do
|
||||
"mutation {
|
||||
|
|
Loading…
Reference in a new issue