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:
Jonne Haß 2016-06-27 12:07:11 +02:00
parent 54026f4a63
commit 09908a45fb
No known key found for this signature in database
GPG key ID: F347E0EB47AC70D6
2 changed files with 4 additions and 1 deletions

View file

@ -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)

View file

@ -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