A minitest returns Expected nil to be truthy.
The controller action processes the following statements
@cu = current_user.roleshopusers.where(shop_id: @site.shop_id).first
@cu_role = @cu.try(:role_id)
@cu_buyer = @cu.buyer
Rails.logger.info @cu.inspect
Rails.logger.info @cu.buyer
And the test log returns:
#<Roleshopuser id: 434940726, user_id: 7, shop_id: 31, role_id: 1, buyer: true, special_support: false, special_needs: nil, notes: nil, discount: 0.0, created_at: "2021-06-16 13:56:37.288691000 +0200", updated_at: "2021-06-16 13:56:37.288691000 +0200">
true
but the test, while returning correct values with the same method definition,
puts current_user.id
puts current_user.roleshopusers.where(shop_id: @site.shop_id).first.buyer
puts @cu.inspect
assert @cu_buyer
has no instance variable available to it.
7
true
nil
How should this test be stated, then?