Merge pull request #62 from sgmap/test-db

Use Postgresql for the test db
This commit is contained in:
gregoirenovel 2017-04-10 16:22:21 +02:00 committed by GitHub
commit 8402f62793
12 changed files with 26 additions and 21 deletions

View file

@ -93,6 +93,8 @@ gem 'simple_form'
gem 'newrelic_rpm'
gem 'scenic'
# Sidekiq
gem 'sidekiq'
gem 'sidekiq-cron', '~> 0.4.4'
@ -145,6 +147,3 @@ group :production, :staging do
gem 'sentry-raven'
end
group :production, :staging, :development do
gem 'scenic'
end

View file

@ -29,6 +29,7 @@ Les informations nécessaire à l'initialisation de la base doivent être pré-c
su - postgres
psql
> create user tps with password 'lol' superuser;
> create user tps_test with password 'tps_test' superuser;
> \q

View file

@ -1,6 +1,5 @@
class Notification < ActiveRecord::Base
belongs_to :dossier
serialize :liste if Rails.env.test?
# after_save :broadcast_notification

View file

@ -1,6 +1,7 @@
database:
override:
- bundle exec rake db:drop db:create db:migrate RAILS_ENV=test
- cp config/database.yml.ci config/database.yml
- bundle exec rake db:create db:schema:load db:migrate RAILS_ENV=test
deployment:
staging:

View file

@ -9,7 +9,10 @@ development:
test:
adapter: sqlite3
adapter: postgresql
encoding: unicode
database: tps_test
host: localhost
pool: 5
timeout: 5000
database: db/test.sqlite3
username: tps_test
password: tps_test

6
config/database.yml.ci Normal file
View file

@ -0,0 +1,6 @@
test:
adapter: postgresql
database: app_test
pool: 5
username:
password:

View file

@ -1,10 +1,6 @@
class ChangeDateCreationTypeToEntreprise < ActiveRecord::Migration
def up
if Rails.env.test?
change_column :entreprises, :date_creation, "timestamp"
else
change_column :entreprises, :date_creation, "timestamp USING to_timestamp(date_creation) at time zone 'UTC-2'"
end
change_column :entreprises, :date_creation, "timestamp USING to_timestamp(date_creation) at time zone 'UTC-2'"
end
def down

View file

@ -9,7 +9,7 @@ class CreateSearches < ActiveRecord::Migration
add_index :individuals, :dossier_id
add_index :pieces_justificatives, :dossier_id
add_index :rna_informations, :entreprise_id
create_view :searches unless Rails.env.test? #, materialized: true
create_view :searches
end
def down
@ -22,6 +22,6 @@ class CreateSearches < ActiveRecord::Migration
remove_index :individuals, :dossier_id
remove_index :pieces_justificatives, :dossier_id
remove_index :rna_informations, :entreprise_id
drop_view :searches unless Rails.env.test? #, materialized: true
drop_view :searches
end
end

View file

@ -1,9 +1,9 @@
class UpdateSearchesToVersion2 < ActiveRecord::Migration
def up
replace_view :searches, version: 2 unless Rails.env.test?
replace_view :searches, version: 2
end
def down
replace_view :searches, version: 1 unless Rails.env.test?
replace_view :searches, version: 1
end
end

View file

@ -164,7 +164,7 @@ shared_examples 'carte_controller_spec' do
subject { Cadastre.last }
it { expect(subject.surface_intersection).to eq('0.0006') }
it { expect(subject.surface_parcelle).to eq(11252.692583090324) }
it { expect(subject.surface_parcelle).to eq(11252.6925830903) }
it { expect(subject.numero).to eq('0013') }
it { expect(subject.feuille).to eq(1) }
it { expect(subject.section).to eq('CD') }

View file

@ -8,8 +8,8 @@ describe MailTemplateConcern do
it 'works' do
initiated_mail.object = '[TPS] --numero_dossier-- --libelle_procedure-- --lien_dossier--'
expected =
"[TPS] 1 Demande de subvention " +
"<a target=\"_blank\" href=\"http://localhost:3000/users/dossiers/1/recapitulatif\">http://localhost:3000/users/dossiers/1/recapitulatif</a>"
"[TPS] #{dossier.id} Demande de subvention " +
"<a target=\"_blank\" href=\"http://localhost:3000/users/dossiers/#{dossier.id}/recapitulatif\">http://localhost:3000/users/dossiers/#{dossier.id}/recapitulatif</a>"
expect(initiated_mail.object_for_dossier(dossier)).to eq(expected)
end

View file

@ -55,7 +55,7 @@ VCR.configure do |c|
c.configure_rspec_metadata!
end
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.strategy = :transaction
SIADETOKEN = :valid_token unless defined? SIADETOKEN
BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)')