maintains responsible name when user is erased

This commit is contained in:
rgarcia
2015-11-23 18:05:29 +01:00
committed by Juanjo Bazán
parent e682b2f23c
commit 3f68c6726a
2 changed files with 12 additions and 1 deletions

View File

@@ -134,7 +134,7 @@ class Proposal < ActiveRecord::Base
protected
def set_responsible_name
if author && author.level_two_or_three_verified?
if author && author.document_number?
self.responsible_name = author.document_number
end
end

View File

@@ -97,6 +97,17 @@ describe Proposal do
expect(proposal).to be_valid
proposal.responsible_name = "12345678Z"
end
it "should not be updated when the author is deleted" do
author = create(:user, :level_three, document_number: "12345678Z")
proposal.author = author
proposal.save
proposal.author.erase
proposal.save
expect(proposal.responsible_name).to eq "12345678Z"
end
end
describe "tag_list" do