Making a will is not mandatory, but it is necessary if you want to designate the heirs without it being the law who names them following an order of kinship. For example, According to the Civil Code, only one third of the inheritance corresponds to the spouse of the deceased, unless the heir is instituted in the testament. In practice, this is a common clause that pIt can be problematic if, after granting a will, the marriage is dissolved.
The law does not establish a solution, although the courts usually apply a precept (the Article 767 of the Civil Code) that considers as unwritten the institution of an heir that obeys a false cause. It is understood that who makes a will in favor of their spouse does so in response to their bond and that, therefore, once divorced, the reason for which it was granted disappears. So, Major jurisprudence considers a clause of this type not to be established if the heir is already a former husband. Or, in other words, if the successor is divorced, he will not receive any property from his ex-wife's estate even though the will has not been modified.
This question, quite common in practice, has recently been resolved by the Supreme Court in a sentence (access the text here) in which, applying the prevailing jurisprudential criterion, it gives the reason to the legal heirs who had requested that the appointment of the ex-husband of his aunt be declared ineffective. She had died without changing the testament she granted in favor of her then husband, at which time her sister starts a battle for the inheritance.
Both the court and the Provincial Court of Madrid rejected the request of the nephews because there was no proof that the will of the deceased had been different from that manifested in the testament. According to the Chamber, it was not possible to interpret that after the divorce it would have wanted to revoke the appointment because, in fact, it did not do it. Therefore, and taking into account the literal nature of the clause, they maintained the institution of the former husband's heir.
On the other hand, the Supreme Court admits the appeal of the legal heirs and annuls the testament for obeying a false cause. As explained by the court, the deceased declared her ex-husband a successor using the term "husband", since he was already identified by name and surname. The use of this terminology presupposes, according to the Chamber, that he is appointed heir only because he is her husband. And, since there is no interpretive rule on the hypothetical will of the testator, it is considered that the testament in favor of the spouse it subsists only as long as the marriage continues. That is, in case of divorce it is assumed that the reason for which a will was granted in favor of the other person disappears and is null and void.