From 8bccf375e14d3ddefd6419503345a67c6dd1124a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 14 Feb 2017 18:20:40 +0100 Subject: [PATCH] Tests: adapt migration to sqlite Add sqlite Remove scenic from tests --- Gemfile | 4 +++- Gemfile.lock | 4 +++- config/database.yml | 11 +++-------- db/migrate/20150728140340_devise_create_users.rb | 4 ++-- db/migrate/20150731121101_devise_create_pros.rb | 4 ++-- ...20150918163159_devise_create_gestionnaires.rb | 4 ++-- db/migrate/20150922141232_create_users.rb | 4 ++-- ...151023132121_devise_create_administrateurs.rb | 4 ++-- ...37_change_date_creation_type_to_entreprise.rb | 6 +++++- ...160223134354_devise_create_administrations.rb | 4 ++-- ...04_fix_default_type_on_type_de_champ_table.rb | 8 ++++---- db/migrate/20161025150900_create_searches.rb | 4 ++-- ...0161102154835_update_searches_to_version_2.rb | 4 ++-- db/schema.rb | 16 ++++++++-------- 14 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Gemfile b/Gemfile index 7e1ca50c9..080855505 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,6 @@ gem 'fog' gem 'fog-openstack' gem 'pg' -gem 'scenic' gem 'rgeo-geojson' gem 'leaflet-rails' @@ -115,6 +114,7 @@ group :test do gem 'guard-livereload', '~> 2.4', require: false gem 'vcr' gem 'rails-controller-testing' + gem 'sqlite3' end group :development do @@ -122,6 +122,7 @@ group :development do gem 'web-console' gem 'rack-handlers' gem 'xray-rails' + gem 'scenic' end group :development, :test do @@ -152,5 +153,6 @@ group :development, :test do end group :production, :staging do + gem 'scenic' gem 'sentry-raven' end diff --git a/Gemfile.lock b/Gemfile.lock index 3cbdc6776..ffe16811d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -564,6 +564,7 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + sqlite3 (1.3.13) swd (1.0.1) activesupport (>= 3) attr_required (>= 0.0.5) @@ -695,6 +696,7 @@ DEPENDENCIES simplecov smart_listing spreadsheet_architect + sqlite3 therubyracer timecop turbolinks (~> 2.5) @@ -708,4 +710,4 @@ DEPENDENCIES xray-rails BUNDLED WITH - 1.13.7 + 1.14.4 diff --git a/config/database.yml b/config/database.yml index 2dd44b635..00832cfbc 100644 --- a/config/database.yml +++ b/config/database.yml @@ -10,12 +10,7 @@ development: test: - adapter: postgresql - encoding: unicode - database: tps_test<%= ENV['TEST_ENV_NUMBER'] %> - host: localhost + adapter: sqlite3 pool: 5 - username: tps - password: lol - - + timeout: 5000 + database: db/test.sqlite3 diff --git a/db/migrate/20150728140340_devise_create_users.rb b/db/migrate/20150728140340_devise_create_users.rb index 1b9d54677..2188a87ae 100644 --- a/db/migrate/20150728140340_devise_create_users.rb +++ b/db/migrate/20150728140340_devise_create_users.rb @@ -16,8 +16,8 @@ class DeviseCreateUsers < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20150731121101_devise_create_pros.rb b/db/migrate/20150731121101_devise_create_pros.rb index d0af3305e..0b3243ca1 100644 --- a/db/migrate/20150731121101_devise_create_pros.rb +++ b/db/migrate/20150731121101_devise_create_pros.rb @@ -16,8 +16,8 @@ class DeviseCreatePros < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20150918163159_devise_create_gestionnaires.rb b/db/migrate/20150918163159_devise_create_gestionnaires.rb index ef56353bd..e1640f6c4 100644 --- a/db/migrate/20150918163159_devise_create_gestionnaires.rb +++ b/db/migrate/20150918163159_devise_create_gestionnaires.rb @@ -16,8 +16,8 @@ class DeviseCreateGestionnaires < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20150922141232_create_users.rb b/db/migrate/20150922141232_create_users.rb index 372296c3c..1b2d78a3c 100644 --- a/db/migrate/20150922141232_create_users.rb +++ b/db/migrate/20150922141232_create_users.rb @@ -16,8 +16,8 @@ class CreateUsers < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20151023132121_devise_create_administrateurs.rb b/db/migrate/20151023132121_devise_create_administrateurs.rb index 35979387e..bf5bb9167 100644 --- a/db/migrate/20151023132121_devise_create_administrateurs.rb +++ b/db/migrate/20151023132121_devise_create_administrateurs.rb @@ -16,8 +16,8 @@ class DeviseCreateAdministrateurs < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20160127170437_change_date_creation_type_to_entreprise.rb b/db/migrate/20160127170437_change_date_creation_type_to_entreprise.rb index 6451dc0d1..5168938c7 100644 --- a/db/migrate/20160127170437_change_date_creation_type_to_entreprise.rb +++ b/db/migrate/20160127170437_change_date_creation_type_to_entreprise.rb @@ -1,6 +1,10 @@ class ChangeDateCreationTypeToEntreprise < ActiveRecord::Migration def up - change_column :entreprises, :date_creation, "timestamp USING to_timestamp(date_creation) at time zone 'UTC-2'" + 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 end def down diff --git a/db/migrate/20160223134354_devise_create_administrations.rb b/db/migrate/20160223134354_devise_create_administrations.rb index 4d139ee28..8f5460074 100644 --- a/db/migrate/20160223134354_devise_create_administrations.rb +++ b/db/migrate/20160223134354_devise_create_administrations.rb @@ -16,8 +16,8 @@ class DeviseCreateAdministrations < ActiveRecord::Migration t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at - t.inet :current_sign_in_ip - t.inet :last_sign_in_ip + t.string :current_sign_in_ip + t.string :last_sign_in_ip ## Confirmable # t.string :confirmation_token diff --git a/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb b/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb index b5aec3a3a..01636f7c6 100644 --- a/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb +++ b/db/migrate/20160803081304_fix_default_type_on_type_de_champ_table.rb @@ -4,14 +4,14 @@ class FixDefaultTypeOnTypeDeChampTable < ActiveRecord::Migration end def up - TypeDeChamp.where("private = false").update_all("type = 'TypeDeChampPublic'") - TypeDeChamp.where("private = true").update_all("type = 'TypeDeChampPrivate'") + TypeDeChamp.where(private: false).update_all("type = 'TypeDeChampPublic'") + TypeDeChamp.where(private: true).update_all("type = 'TypeDeChampPrivate'") remove_column :types_de_champ, :private end def down add_column :types_de_champ, :private, :boolean, default: true - TypeDeChamp.where("type = 'TypeDeChampPublic'").update_all("private = false") - TypeDeChamp.where("type = 'TypeDeChampPrivate'").update_all("private = true") + TypeDeChamp.where("type = 'TypeDeChampPublic'").update_all(private: false) + TypeDeChamp.where("type = 'TypeDeChampPrivate'").update_all(private: true) end end diff --git a/db/migrate/20161025150900_create_searches.rb b/db/migrate/20161025150900_create_searches.rb index 911948c7d..5252c6006 100644 --- a/db/migrate/20161025150900_create_searches.rb +++ b/db/migrate/20161025150900_create_searches.rb @@ -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 #, materialized: true + create_view :searches unless Rails.env.test? #, materialized: true 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 #, materialized: true + drop_view :searches unless Rails.env.test? #, materialized: true end end diff --git a/db/migrate/20161102154835_update_searches_to_version_2.rb b/db/migrate/20161102154835_update_searches_to_version_2.rb index 55223b4cf..b749a08ea 100644 --- a/db/migrate/20161102154835_update_searches_to_version_2.rb +++ b/db/migrate/20161102154835_update_searches_to_version_2.rb @@ -1,9 +1,9 @@ class UpdateSearchesToVersion2 < ActiveRecord::Migration def up - replace_view :searches, version: 2 + replace_view :searches, version: 2 unless Rails.env.test? end def down - replace_view :searches, version: 1 + replace_view :searches, version: 1 unless Rails.env.test? end end diff --git a/db/schema.rb b/db/schema.rb index 7c4a70927..6e64cefb3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -24,8 +24,8 @@ ActiveRecord::Schema.define(version: 20170223170808) do t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.string "api_token" @@ -50,8 +50,8 @@ ActiveRecord::Schema.define(version: 20170223170808) do t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.index ["email"], name: "index_administrations_on_email", unique: true, using: :btree @@ -207,8 +207,8 @@ ActiveRecord::Schema.define(version: 20170223170808) do t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.integer "procedure_filter" @@ -375,8 +375,8 @@ ActiveRecord::Schema.define(version: 20170223170808) do t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.inet "current_sign_in_ip" - t.inet "last_sign_in_ip" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" t.string "siret"