1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/test/system/body_trackers_test.rb
cryptogopher 1b7f2f0abd 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
2020-08-29 01:26:36 +02:00

32 lines
1.0 KiB
Ruby

require File.expand_path('../../application_system_test_case', __FILE__)
require 'rake'
class BodyTrackersTest < BodyTrackingSystemTestCase
def setup
super
@project1 = projects(:projects_001)
log_user 'jsmith', 'jsmith'
end
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)
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
end
end