1
0

Randomize quantity in test_index_table_header_close_exposure

Rename: Goal.target_exposures -> Goal.exposures
This commit is contained in:
cryptogopher 2021-03-22 00:22:33 +01:00
parent 0eefcb29db
commit 91fa25830d
3 changed files with 8 additions and 6 deletions

View File

@ -56,7 +56,7 @@ class TargetsController < ApplicationController
end
def toggle_exposure
@goal.target_exposures.toggle!(@quantity)
@goal.exposures.toggle!(@quantity)
prepare_targets
end

View File

@ -2,9 +2,9 @@ class Goal < ActiveRecord::Base
belongs_to :project, required: true
has_many :targets, -> { order effective_from: :desc }, inverse_of: :goal,
dependent: :destroy, extend: BodyTracking::ItemsWithQuantities
has_many :target_exposures, as: :view, dependent: :destroy,
has_many :exposures, as: :view, dependent: :destroy,
class_name: 'Exposure', extend: BodyTracking::TogglableExposures
has_many :quantities, -> { order "lft" }, through: :target_exposures
has_many :quantities, -> { order "lft" }, through: :exposures
accepts_nested_attributes_for :targets, allow_destroy: true
validates :is_binding, uniqueness: {scope: :project_id}, if: :is_binding?
@ -19,7 +19,7 @@ class Goal < ActiveRecord::Base
end
before_save do
quantities << targets.map(&:quantity)[0..5] if target_exposures.empty?
quantities << targets.map(&:quantity)[0..5] if exposures.empty?
end
before_destroy prepend: true do

View File

@ -45,11 +45,13 @@ class TargetsTest < BodyTrackingSystemTestCase
end
def test_index_table_header_close_exposure
quantity = @project.goals.binding.exposures.sample.quantity
visit goal_targets_path(@project.goals.binding)
within 'table#targets thead th', text: quantities(:quantities_energy).name do
within 'table#targets thead th', text: quantity.name do
click_link class: 'icon-close'
end
assert_no_selector 'table#targets thead th', text: quantities(:quantities_energy).name
assert_no_selector 'table#targets thead th', text: quantity.name
assert_selector 'table#targets thead th'
end