1
0

Target system tests started to run

This commit is contained in:
cryptogopher 2020-08-16 15:27:07 +02:00
parent 66a364d017
commit 955125b843
10 changed files with 41 additions and 6 deletions

View File

@ -6,6 +6,7 @@ class Goal < ActiveRecord::Base
class_name: 'Exposure', extend: BodyTracking::TogglableExposures
has_many :quantities, -> { order "lft" }, through: :target_exposures
validates :target_exposures, presence: true
validates :name, presence: true, uniqueness: {scope: :project_id}
def is_binding?

View File

@ -1,7 +1,7 @@
(Rails::VERSION::MAJOR < 5 ? ActionDispatch : ActiveSupport)::Reloader.to_prepare do
Project.include BodyTracking::ProjectPatch
CollectiveIdea.include BodyTracking::AwesomeNestedSetPatch
ActionController::TestCase.include BodyTracking::PluginFixturesLoader if Rails.env == 'test'
ActiveSupport::TestCase.include BodyTracking::PluginFixturesLoader if Rails.env == 'test'
end
Redmine::Plugin.register :body_tracking do

View File

@ -2,8 +2,8 @@ module BodyTracking::PluginFixturesLoader
def self.included(base)
base.class_eval do
def self.plugin_fixtures(*symbols)
fixtures_dir = File.expand_path('../../test/fixtures/', __FILE__)
ActiveRecord::Fixtures.create_fixtures(fixtures_dir, symbols)
fixtures_dir = File.expand_path('../../../test/fixtures/', __FILE__)
ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, symbols)
end
end
end

View File

@ -21,9 +21,7 @@ class BodyTrackingSystemTestCase < ApplicationSystemTestCase
end
fixtures :projects
# fixtures :users, :email_addresses, :trackers, :projects,
# :roles, :members, :member_roles, :enabled_modules
plugin_fixtures :targets
plugin_fixtures :quantities, :units, :exposures, :targets, :quantity_values
include AbstractController::Translation

4
test/fixtures/exposures.yml vendored Normal file
View File

@ -0,0 +1,4 @@
exposures_01:
view_type: Goal
view_id: <%= Project.find(1).goals.binding.id %>
quantity: quantities_energy

8
test/fixtures/quantities.yml vendored Normal file
View File

@ -0,0 +1,8 @@
quantities_energy:
project: projects_001
domain: diet
parent: null
lft: 1
rgt: 2
name: Energy
description: Total energy

7
test/fixtures/quantity_values.yml vendored Normal file
View File

@ -0,0 +1,7 @@
quantity_values_001:
type: Threshold
registry_type: Target
registry: targets_01
quantity: quantities_energy
value: 2500
unit: units_kcal

View File

@ -1,2 +1,4 @@
targets_01:
goal_id: <%= Project.find(1).goals.binding.id %>
condition: '=='
effective_from: <%= 1.week.ago.to_s(:db) %>

14
test/fixtures/units.yml vendored Normal file
View File

@ -0,0 +1,14 @@
units_gram:
project: projects_001
name: 'gram'
shortname: 'g'
units_percent:
project: projects_001
name: 'percent'
shortname: '%'
units_kcal:
project: projects_001
name: 'kilocalorie'
shortname: 'kcal'

View File

@ -18,6 +18,7 @@ class TargetsTest < BodyTrackingSystemTestCase
assert_not_equal 0, @project1.targets.count
visit project_targets_path(@project1)
assert_current_path project_targets_path(@project1)
assert_selector 'table#targets tr', count: @project1.targets.count
end
def test_index_without_targets