clean(spec): procedure_filters_spec.rb, less tdc by default
This commit is contained in:
parent
750842f742
commit
575c4cbdff
1 changed files with 31 additions and 21 deletions
|
@ -1,6 +1,7 @@
|
||||||
describe "procedure filters" do
|
describe "procedure filters" do
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :text }, { type: :departements }, { type: :regions }, { type: :drop_down_list }], instructeurs: [instructeur]) }
|
let(:procedure) { create(:procedure, :published, types_de_champ_public:, instructeurs: [instructeur]) }
|
||||||
|
let(:types_de_champ_public) { [{ type: :text }] }
|
||||||
let!(:type_de_champ) { procedure.active_revision.types_de_champ_public.first }
|
let!(:type_de_champ) { procedure.active_revision.types_de_champ_public.first }
|
||||||
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
||||||
let!(:champ) { Champ.find_by(stable_id: type_de_champ.stable_id, dossier_id: new_unfollow_dossier.id) }
|
let!(:champ) { Champ.find_by(stable_id: type_de_champ.stable_id, dossier_id: new_unfollow_dossier.id) }
|
||||||
|
@ -91,36 +92,45 @@ describe "procedure filters" do
|
||||||
expect(page).to have_link(new_unfollow_dossier_2.user.email)
|
expect(page).to have_link(new_unfollow_dossier_2.user.email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
describe 'with dropdown' do
|
||||||
|
let(:types_de_champ_public) { [{ type: :drop_down_list }] }
|
||||||
|
|
||||||
scenario "should be able to user custom fiters", js: true do
|
scenario "should be able to user custom fiters", js: true do
|
||||||
# use date filter
|
# use date filter
|
||||||
add_filter("En construction le", "10/10/2010", type: :date)
|
add_filter("En construction le", "10/10/2010", type: :date)
|
||||||
|
|
||||||
# use statut dropdown filter
|
# use statut dropdown filter
|
||||||
add_filter('Statut', 'En construction', type: :enum)
|
add_filter('Statut', 'En construction', type: :enum)
|
||||||
|
|
||||||
# use choice dropdown filter
|
# use choice dropdown filter
|
||||||
add_filter('Choix unique', 'val1', type: :enum)
|
add_filter('Choix unique', 'val1', type: :enum)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with a vcr cached cassette' do
|
describe 'with a vcr cached cassette' do
|
||||||
scenario "should be able to find by departements with custom enum lookup", js: true do
|
describe 'departements' do
|
||||||
departement_champ = new_unfollow_dossier.champs.find(&:departement?)
|
let(:types_de_champ_public) { [{ type: :departements }] }
|
||||||
departement_champ.update!(value: 'Oise', external_id: '60')
|
scenario "should be able to find by departements with custom enum lookup", js: true do
|
||||||
departement_champ.reload
|
departement_champ = new_unfollow_dossier.champs.find(&:departement?)
|
||||||
champ_select_value = "#{departement_champ.external_id} – #{departement_champ.value}"
|
departement_champ.update!(value: 'Oise', external_id: '60')
|
||||||
|
departement_champ.reload
|
||||||
|
champ_select_value = "#{departement_champ.external_id} – #{departement_champ.value}"
|
||||||
|
|
||||||
add_filter(departement_champ.libelle, champ_select_value, type: :enum)
|
add_filter(departement_champ.libelle, champ_select_value, type: :enum)
|
||||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "should be able to find by region with custom enum lookup", js: true do
|
describe 'region' do
|
||||||
region_champ = new_unfollow_dossier.champs.find(&:region?)
|
let(:types_de_champ_public) { [{ type: :regions }] }
|
||||||
region_champ.update!(value: 'Bretagne', external_id: '53')
|
scenario "should be able to find by region with custom enum lookup", js: true do
|
||||||
region_champ.reload
|
region_champ = new_unfollow_dossier.champs.find(&:region?)
|
||||||
|
region_champ.update!(value: 'Bretagne', external_id: '53')
|
||||||
|
region_champ.reload
|
||||||
|
|
||||||
add_filter(region_champ.libelle, region_champ.value, type: :enum)
|
add_filter(region_champ.libelle, region_champ.value, type: :enum)
|
||||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue