The court shall determine upon the intervention at the same time that the action is decided, and if the claim of the intervenor is not sustained he shall pay all costs of the intervention.