1
0

Added test_defaults_seed_and_load_into_empty_project

Added :defaults scopes to models
Added :sources and :formulas fixtures
Loading defaults from seeds.rb using rake task instead of migration
This commit is contained in:
cryptogopher
2020-08-29 01:26:36 +02:00
parent 8f2a455561
commit 1b7f2f0abd
11 changed files with 245 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
require File.expand_path('../../application_system_test_case', __FILE__)
require 'rake'
class BodyTrackersTest < BodyTrackingSystemTestCase
def setup
@@ -7,12 +8,24 @@ class BodyTrackersTest < BodyTrackingSystemTestCase
log_user 'jsmith', 'jsmith'
end
def test_defaults_load
def test_defaults_seed_and_load_into_empty_project
Rails.application.load_tasks
Rake::Task['redmine:body_tracking:seed'].invoke
counts = [Source, Quantity, Formula, Unit].map do |model|
assoc = model.to_s.downcase.pluralize
@project1.send(assoc).delete_all unless assoc == 'formulas'
["@project1.#{assoc}.reload.count", model.defaults.count]
end.to_h
visit project_body_trackers_path(@project1)
accept_alert t('layouts.sidebar.confirm_defaults') do
click_link t('layouts.sidebar.link_defaults')
assert_difference counts do
accept_alert t('layouts.sidebar.confirm_defaults') do
click_link t('layouts.sidebar.link_defaults')
end
# click_link is asynchronuous, need to wait for page reload before
# checking differences
assert_selector 'div#flash_notice'
assert_no_selector 'div#flash_error'
end
assert_selector 'div#flash_notice'
assert_no_selector 'div#flash_error'
end
end