Merge pull request #90 from sgmap/remove_sqlite_flag_for_tests
Remove sqlite flag for tests
This commit is contained in:
commit
33d033d680
5 changed files with 135 additions and 145 deletions
|
@ -24,7 +24,7 @@ describe API::V1::DossiersController do
|
|||
|
||||
context 'when procedure is found and belongs to admin' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:date_creation) { Time.local(2008, 9, 1, 10, 5, 0) }
|
||||
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
|
||||
|
@ -52,9 +52,7 @@ describe API::V1::DossiersController do
|
|||
describe 'dossier' do
|
||||
subject { super().first }
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
if ENV['PG'] == 'true'
|
||||
it { expect(subject[:updated_at]).to eq("2008-09-01T08:05:00.000Z") }
|
||||
end
|
||||
it { expect(subject[:updated_at]).to eq("2008-09-01T10:05:00.000Z") }
|
||||
it { expect(subject.keys.size).to eq(2) }
|
||||
end
|
||||
end
|
||||
|
@ -113,7 +111,7 @@ describe API::V1::DossiersController do
|
|||
|
||||
context 'when dossier exists and belongs to procedure' do
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:date_creation) { Time.local(2008, 9, 1, 10, 5, 0) }
|
||||
let(:date_creation) { Time.utc(2008, 9, 1, 10, 5, 0) }
|
||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||
|
@ -126,10 +124,8 @@ describe API::V1::DossiersController do
|
|||
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
it { expect(subject[:state]).to eq(dossier.state) }
|
||||
if ENV['PG'] == 'true'
|
||||
it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') }
|
||||
it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') }
|
||||
end
|
||||
it { expect(subject[:created_at]).to eq('2008-09-01T10:05:00.000Z') }
|
||||
it { expect(subject[:updated_at]).to eq('2008-09-01T10:05:00.000Z') }
|
||||
it { expect(subject[:archived]).to eq(dossier.archived) }
|
||||
it { expect(subject[:mandataire_social]).to eq(dossier.mandataire_social) }
|
||||
|
||||
|
|
|
@ -169,41 +169,39 @@ describe Backoffice::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
|
||||
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
|
||||
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 }
|
||||
end
|
||||
|
||||
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
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
|
||||
context 'when I do not own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier2_id }
|
||||
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 http success' do
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
context 'when I do not own the dossier' do
|
||||
before :each do
|
||||
post :search, params: { q: dossier2_id }
|
||||
end
|
||||
|
||||
it 'returns nothing' do
|
||||
expect(assigns(:dossiers).count).to eq(0)
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe CommentaireDecorator do
|
||||
let(:commentaire) { Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 0)) {create :commentaire} }
|
||||
let(:commentaire) { Timecop.freeze(Time.utc(2008, 9, 1, 10, 5, 0)) {create :commentaire} }
|
||||
let(:decorator) { commentaire.decorate }
|
||||
|
||||
describe 'created_at_fr' do
|
||||
|
|
|
@ -1,52 +1,50 @@
|
|||
require 'spec_helper'
|
||||
|
||||
if ENV['PG'] == 'true'
|
||||
feature 'search file on gestionnaire backoffice' do
|
||||
let(:administrateur) { create(:administrateur) }
|
||||
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
||||
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
|
||||
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)
|
||||
end
|
||||
|
||||
it { expect(page).to have_css('#backoffice_search') }
|
||||
|
||||
context 'when terms input is empty' do
|
||||
context 'when terms input does not return result' do
|
||||
it { expect(page).to have_content('Aucun dossier') }
|
||||
end
|
||||
|
||||
context 'when terms input is informed' do
|
||||
let(:terms) { 'test' }
|
||||
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') }
|
||||
|
||||
it 'terms stay in input after search' do
|
||||
expect(page.find_by_id('q').value).to eq(terms)
|
||||
end
|
||||
let(:terms) { 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
|
||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,81 +1,79 @@
|
|||
require 'spec_helper'
|
||||
|
||||
if ENV['PG'] == 'true'
|
||||
describe Search do
|
||||
describe '.results' do
|
||||
subject { liste_dossiers }
|
||||
describe Search do
|
||||
describe '.results' do
|
||||
subject { liste_dossiers }
|
||||
|
||||
let(:liste_dossiers) do
|
||||
described_class.new(gestionnaire: gestionnaire_1, query: terms).results
|
||||
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(: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
|
||||
|
||||
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!(: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) { '' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search draft file' do
|
||||
let(:terms) { 'brouillon' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search on contact email' do
|
||||
let(:terms) { 'clap' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search on SIRET' do
|
||||
context 'when is part of SIRET' do
|
||||
let(:terms) { '4181' }
|
||||
|
||||
it { expect(subject.size).to eq(1) }
|
||||
end
|
||||
|
||||
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]) }
|
||||
|
||||
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!(: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') }
|
||||
|
||||
describe 'search is empty' do
|
||||
let(:terms) { '' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search draft file' do
|
||||
let(:terms) { 'brouillon' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
describe 'search on contact email' do
|
||||
let(:terms) { 'clap' }
|
||||
|
||||
it { expect(subject.size).to eq(0) }
|
||||
end
|
||||
|
||||
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' }
|
||||
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