StatusMessage#raw_message returns empty string for NULL values
Previously the federation layer has written the empty string to the database, now it writes nil/no value to it while our code still expects the empty string in some cases. Restore the old assumption by returning the empty string, the real raw value by now is available again in StatusMessage#text for those that need it, such as validations or tests.
This commit is contained in:
parent
54026f4a63
commit
09908a45fb
2 changed files with 4 additions and 1 deletions
|
|
@ -53,7 +53,7 @@ class StatusMessage < Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def raw_message
|
def raw_message
|
||||||
read_attribute(:text)
|
read_attribute(:text) || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def raw_message=(text)
|
def raw_message=(text)
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,9 @@ describe StatusMessage, type: :model do
|
||||||
|
|
||||||
post.photos << photo
|
post.photos << photo
|
||||||
expect(post).to be_valid
|
expect(post).to be_valid
|
||||||
|
expect(post.message.to_s).to be_empty
|
||||||
|
expect(post.raw_message).to eq ""
|
||||||
|
expect(post.nsfw).to be_falsy
|
||||||
expect(post.errors.full_messages).to eq([])
|
expect(post.errors.full_messages).to eq([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue