Added RSpec support file to initialize database into clean state before running suite.

This commit is contained in:
Thorsten Eckel 2018-09-28 17:05:39 +02:00
parent 50162cc250
commit e006684c83
4 changed files with 15 additions and 1 deletions

View file

@ -173,6 +173,10 @@ group :development, :test do
# record and replay TCP/HTTP transactions # record and replay TCP/HTTP transactions
gem 'tcr' gem 'tcr'
gem 'vcr' gem 'vcr'
# database cleanup when transactions are not possible
# and DB initialization before running RSpec suite
gem 'database_cleaner'
end end
# Want to extend Zammad with additional gems? # Want to extend Zammad with additional gems?

View file

@ -113,6 +113,7 @@ GEM
crass (1.0.4) crass (1.0.4)
daemons (1.2.5) daemons (1.2.5)
dalli (2.7.6) dalli (2.7.6)
database_cleaner (1.7.0)
debug_inspector (0.0.3) debug_inspector (0.0.3)
delayed_job (4.1.3) delayed_job (4.1.3)
activesupport (>= 3.0, < 5.2) activesupport (>= 3.0, < 5.2)
@ -511,6 +512,7 @@ DEPENDENCIES
coveralls coveralls
daemons daemons
dalli dalli
database_cleaner
delayed_job_active_record delayed_job_active_record
diffy diffy
doorkeeper doorkeeper

View file

@ -2694,7 +2694,7 @@ Setting.create_if_not_exists(
area: 'Models::Base', area: 'Models::Base',
description: 'Defines the searchable models.', description: 'Defines the searchable models.',
options: {}, options: {},
state: [], state: Models.searchable.map(&:to_s),
preferences: { preferences: {
authentication: true, authentication: true,
}, },

View file

@ -0,0 +1,8 @@
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
Rails.application.load_seed
Cache.clear
Setting.reload
end
end