Randomize quantity in test_index_table_header_close_exposure
Rename: Goal.target_exposures -> Goal.exposures
This commit is contained in:
parent
0eefcb29db
commit
91fa25830d
@ -56,7 +56,7 @@ class TargetsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def toggle_exposure
|
def toggle_exposure
|
||||||
@goal.target_exposures.toggle!(@quantity)
|
@goal.exposures.toggle!(@quantity)
|
||||||
prepare_targets
|
prepare_targets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ class Goal < ActiveRecord::Base
|
|||||||
belongs_to :project, required: true
|
belongs_to :project, required: true
|
||||||
has_many :targets, -> { order effective_from: :desc }, inverse_of: :goal,
|
has_many :targets, -> { order effective_from: :desc }, inverse_of: :goal,
|
||||||
dependent: :destroy, extend: BodyTracking::ItemsWithQuantities
|
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
|
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
|
accepts_nested_attributes_for :targets, allow_destroy: true
|
||||||
validates :is_binding, uniqueness: {scope: :project_id}, if: :is_binding?
|
validates :is_binding, uniqueness: {scope: :project_id}, if: :is_binding?
|
||||||
@ -19,7 +19,7 @@ class Goal < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
quantities << targets.map(&:quantity)[0..5] if target_exposures.empty?
|
quantities << targets.map(&:quantity)[0..5] if exposures.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
before_destroy prepend: true do
|
before_destroy prepend: true do
|
||||||
|
@ -45,11 +45,13 @@ class TargetsTest < BodyTrackingSystemTestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_index_table_header_close_exposure
|
def test_index_table_header_close_exposure
|
||||||
|
quantity = @project.goals.binding.exposures.sample.quantity
|
||||||
|
|
||||||
visit goal_targets_path(@project.goals.binding)
|
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'
|
click_link class: 'icon-close'
|
||||||
end
|
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'
|
assert_selector 'table#targets thead th'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user