Tests: feature flip tests that require postgres
This commit is contained in:
parent
15d27f6a7d
commit
382b614095
3 changed files with 125 additions and 118 deletions
|
@ -174,39 +174,42 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'POST #search' do
|
||||
describe 'by id' do
|
||||
context 'when I am logged as a gestionnaire' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
context 'when I own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier_id }
|
||||
if ENV['PG'] == 'true'
|
||||
describe 'POST #search' do
|
||||
describe 'by id' do
|
||||
context 'when I am logged as a gestionnaire' do
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
context 'when I own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier_id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns the expected dossier' do
|
||||
expect(assigns(:dossiers).count).to eq(1)
|
||||
expect(assigns(:dossiers).first.id).to eq(dossier_id)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns the expected dossier' do
|
||||
expect(assigns(:dossiers).count).to eq(1)
|
||||
expect(assigns(:dossiers).first.id).to eq(dossier_id)
|
||||
end
|
||||
end
|
||||
context 'when I do not own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier2_id }
|
||||
end
|
||||
|
||||
context 'when I do not own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier2_id }
|
||||
end
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
it 'returns nothing' do
|
||||
expect(assigns(:dossiers).count).to eq(0)
|
||||
it 'returns nothing' do
|
||||
expect(assigns(:dossiers).count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,52 +1,54 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'search file on gestionnaire backoffice' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
if ENV['PG'] == 'true'
|
||||
feature 'search file on gestionnaire backoffice' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
end
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
end
|
||||
|
||||
context 'when gestionnaire is logged in' do
|
||||
context 'when he click on search button' do
|
||||
let(:terms) { '' }
|
||||
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||
context 'when gestionnaire is logged in' do
|
||||
context 'when he click on search button' do
|
||||
let(:terms) { '' }
|
||||
let!(:procedure) { create(:procedure, administrateur: administrateur) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
|
||||
visit backoffice_dossiers_url
|
||||
page.find_by_id(:q).set terms
|
||||
page.find_by_id(:search_button).click
|
||||
end
|
||||
|
||||
it { expect(page).to have_css('#backoffice_search') }
|
||||
|
||||
context 'when terms input is empty' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input is informed' do
|
||||
let(:terms) { 'test' }
|
||||
|
||||
it 'terms stay in input after search' do
|
||||
expect(page.find_by_id('q').value).to eq(terms)
|
||||
visit backoffice_dossiers_url
|
||||
page.find_by_id(:q).set terms
|
||||
page.find_by_id(:search_button).click
|
||||
end
|
||||
|
||||
context 'when terms input does not return result' do
|
||||
it { expect(page).to have_css('#backoffice_search') }
|
||||
|
||||
context 'when terms input is empty' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input does return result' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
|
||||
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
|
||||
context 'when terms input is informed' do
|
||||
let(:terms) { 'test' }
|
||||
|
||||
let(:terms) { dossier.entreprise.raison_sociale }
|
||||
it 'terms stay in input after search' do
|
||||
expect(page.find_by_id('q').value).to eq(terms)
|
||||
end
|
||||
|
||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||
context 'when terms input does not return result' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input does return result' do
|
||||
let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') }
|
||||
let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') }
|
||||
|
||||
let(:terms) { dossier.entreprise.raison_sociale }
|
||||
|
||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,79 +1,81 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Search do
|
||||
describe '.results' do
|
||||
subject { liste_dossiers }
|
||||
if ENV['PG'] == 'true'
|
||||
describe Search do
|
||||
describe '.results' do
|
||||
subject { liste_dossiers }
|
||||
|
||||
let(:liste_dossiers) do
|
||||
described_class.new(gestionnaire: gestionnaire_1, query: terms).results
|
||||
end
|
||||
let(:liste_dossiers) do
|
||||
described_class.new(gestionnaire: gestionnaire_1, query: terms).results
|
||||
end
|
||||
|
||||
let(:administrateur_1) { create(:administrateur) }
|
||||
let(:administrateur_2) { create(:administrateur) }
|
||||
let(:administrateur_1) { create(:administrateur) }
|
||||
let(:administrateur_2) { create(:administrateur) }
|
||||
|
||||
let(:gestionnaire_1) { create(:gestionnaire, administrateurs: [administrateur_1]) }
|
||||
let(:gestionnaire_2) { create(:gestionnaire, administrateurs: [administrateur_2]) }
|
||||
let(:gestionnaire_1) { create(:gestionnaire, administrateurs: [administrateur_1]) }
|
||||
let(:gestionnaire_2) { create(:gestionnaire, administrateurs: [administrateur_2]) }
|
||||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire_1, procedure: procedure_1
|
||||
create :assign_to, gestionnaire: gestionnaire_2, procedure: procedure_2
|
||||
end
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire_1, procedure: procedure_1
|
||||
create :assign_to, gestionnaire: gestionnaire_2, procedure: procedure_2
|
||||
end
|
||||
|
||||
let(:procedure_1) { create(:procedure, administrateur: administrateur_1) }
|
||||
let(:procedure_2) { create(:procedure, administrateur: administrateur_2) }
|
||||
let(:procedure_1) { create(:procedure, administrateur: administrateur_1) }
|
||||
let(:procedure_2) { create(:procedure, administrateur: administrateur_2) }
|
||||
|
||||
let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) }
|
||||
let!(:dossier_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) }
|
||||
let!(:dossier_2) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) }
|
||||
let!(:dossier_3) { create(:dossier, state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) }
|
||||
let!(:dossier_archived) { create(:dossier, state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) }
|
||||
let!(:dossier_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) }
|
||||
let!(:dossier_2) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'plop@gmail.com')) }
|
||||
let!(:dossier_3) { create(:dossier, state: 'initiated', procedure: procedure_2, user: create(:user, email: 'peace@clap.fr')) }
|
||||
let!(:dossier_archived) { create(:dossier, state: 'initiated', procedure: procedure_1, archived: true, user: create(:user, email: 'brouillonArchived@clap.fr')) }
|
||||
|
||||
let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') }
|
||||
let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') }
|
||||
let!(:etablissement_3) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Technology', dossier: dossier_3), dossier: dossier_3, siret: '41816609600051') }
|
||||
let!(:etablissement_1) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Academy', dossier: dossier_1), dossier: dossier_1, siret: '41636169600051') }
|
||||
let!(:etablissement_2) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'Plop octo', dossier: dossier_2), dossier: dossier_2, siret: '41816602300012') }
|
||||
let!(:etablissement_3) { create(:etablissement, entreprise: create(:entreprise, raison_sociale: 'OCTO Technology', dossier: dossier_3), dossier: dossier_3, siret: '41816609600051') }
|
||||
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search draft file' do
|
||||
let(:terms) { 'brouillon' }
|
||||
describe 'search draft file' do
|
||||
let(:terms) { 'brouillon' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search on contact email' do
|
||||
let(:terms) { 'clap' }
|
||||
describe 'search on contact email' do
|
||||
let(:terms) { 'clap' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search on SIRET' do
|
||||
context 'when is part of SIRET' do
|
||||
let(:terms) { '4181' }
|
||||
describe 'search on SIRET' do
|
||||
context 'when is part of SIRET' do
|
||||
let(:terms) { '4181' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
context 'when is a complet SIRET' do
|
||||
let(:terms) { '41816602300012' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'search on raison social' do
|
||||
let(:terms) { 'OCTO' }
|
||||
|
||||
it { expect(subject.size).to eq(2) }
|
||||
end
|
||||
|
||||
describe 'search on multiple fields' do
|
||||
let(:terms) { 'octo plop' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
context 'when is a complet SIRET' do
|
||||
let(:terms) { '41816602300012' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'search on raison social' do
|
||||
let(:terms) { 'OCTO' }
|
||||
|
||||
it { expect(subject.size).to eq(2) }
|
||||
end
|
||||
|
||||
describe 'search on multiple fields' do
|
||||
let(:terms) { 'octo plop' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue