forked from fixin.me/fixin.me
		
	Fix UnitsiTest#test_index
This commit is contained in:
		
							parent
							
								
									40808639cc
								
							
						
					
					
						commit
						f3f0b9dc9e
					
				@ -3,7 +3,7 @@ class Unit < ApplicationRecord
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  belongs_to :user, optional: true
 | 
					  belongs_to :user, optional: true
 | 
				
			||||||
  belongs_to :base, optional: true, class_name: "Unit"
 | 
					  belongs_to :base, optional: true, class_name: "Unit"
 | 
				
			||||||
  has_many :subunits, class_name: "Unit", dependent: :restrict_with_error, inverse_of: :base
 | 
					  has_many :subunits, class_name: "Unit", inverse_of: :base, dependent: :restrict_with_error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  validate if: ->{ base.present? } do
 | 
					  validate if: ->{ base.present? } do
 | 
				
			||||||
    errors.add(:base, :user_mismatch) unless user == base.user
 | 
					    errors.add(:base, :user_mismatch) unless user == base.user
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,8 @@ class UnitsTest < ApplicationSystemTestCase
 | 
				
			|||||||
      assert_selector 'tr', count: @user.units.count
 | 
					      assert_selector 'tr', count: @user.units.count
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Unit.destroy_all
 | 
					    # Cannot #destroy_all due to {dependent: :restrict*} on Unit.subunits association
 | 
				
			||||||
 | 
					    @user.units.delete_all
 | 
				
			||||||
    visit units_path
 | 
					    visit units_path
 | 
				
			||||||
    within 'tbody' do
 | 
					    within 'tbody' do
 | 
				
			||||||
      assert_selector 'tr', count: 1
 | 
					      assert_selector 'tr', count: 1
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user