Don't stub methods in spec/system/show_subscription_spec.rb
Problem
We have to stub the whole managed_by_reseller?
subscription method in spec/system/show_subscription_spec.rb
(test 'shows reseller alert on individual subscription'). This is considered a sub-optimal practice in feature specs.
allow_next_instance_of(Subscription) do |subscription|
allow(subscription).to receive(:managed_by_reseller?).and_return(true)
end
Possible solution
We could try to leverage a proper mock for the subscription
subscription = build(:subscription, z_subscription: build(:z_subscription, invoice_owner_id: 'reseller_id'))
There are certain problems with this approach and we should check why simply adding this line is not working
Extra context
The following discussion from !7629 should be addressed:
-
@cwiesner started a discussion: (+1 comment) thought/suggestion: Personally, I try to consider feature specs as actual specs that don't stub any methods. We can avoid this stubbing if we follow-up on the suggestion in this comment which sets the
invoice_owner_id
for the created subscription to something likereseller_id
.