Protect ourselves from problems with youtube title serialization by rescuing type mismatches in the marshaller.
This commit is contained in:
parent
e9d993b8f6
commit
a4e54a7b05
2 changed files with 18 additions and 0 deletions
|
|
@ -131,6 +131,18 @@ class StatusMessage < Post
|
|||
end
|
||||
end
|
||||
|
||||
def unserialize_attribute attr_name
|
||||
if attr_name == "youtube_titles"
|
||||
begin
|
||||
super
|
||||
rescue ActiveRecord::SerializationTypeMismatch
|
||||
{}
|
||||
end
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def message_or_photos_present?
|
||||
|
|
|
|||
|
|
@ -45,6 +45,12 @@ describe YoutubeTitles do
|
|||
StatusMessage.find(@post.id).youtube_titles
|
||||
}.should_not raise_error
|
||||
end
|
||||
it 'can be re-marshalled if it is serializaed incorrectly' do
|
||||
StatusMessage.where(:id => @post.id).update_all(:youtube_titles => "this is not yaml")
|
||||
lambda {
|
||||
StatusMessage.find(@post.id).youtube_titles
|
||||
}.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "YOUTUBE_ID_REGEX" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue