diff --git a/lib/fb_graph2/post.rb b/lib/fb_graph2/post.rb index 905ddd4..c00c7f2 100644 --- a/lib/fb_graph2/post.rb +++ b/lib/fb_graph2/post.rb @@ -24,9 +24,11 @@ module FbGraph2 def initialize(id, attributes = {}) super if attributes.include? :message_tags - self.message_tags = attributes[:message_tags].collect do |message_tag| - TaggedProfile.new message_tag[:id], message_tag - end + self.message_tags = attributes[:message_tags].values.collect do |message_tags| + message_tags.collect do |tag| + TaggedProfile.new tag[:id], tag + end + end.flatten end if attributes.include? :privacy self.privacy = Struct::Privacy.new attributes[:privacy] diff --git a/spec/fb_graph2/edge/posts_spec.rb b/spec/fb_graph2/edge/posts_spec.rb index 6a8b122..83fa69b 100644 --- a/spec/fb_graph2/edge/posts_spec.rb +++ b/spec/fb_graph2/edge/posts_spec.rb @@ -12,6 +12,7 @@ describe FbGraph2::Edge::Posts do posts.should_not be_blank posts.each do |post| post.should be_instance_of FbGraph2::Post + post.message_tags.count.should == 2 end end end diff --git a/spec/mock_json/user/posts.json b/spec/mock_json/user/posts.json index c995fe4..33042df 100644 --- a/spec/mock_json/user/posts.json +++ b/spec/mock_json/user/posts.json @@ -12,13 +12,26 @@ }] }, "message": "Nov Matake test", - "message_tags": [{ - "id": "579612276", - "name": "Nov Matake", - "type": "user", - "offset": 0, - "length": 10 - }], + "message_tags": { + "0": [ + { + "id": "579612276", + "name": "Nov Matake", + "type": "user", + "offset": 0, + "length": 10 + } + ], + "11": [ + { + "id": "10153177366617368", + "name": "Bryan Brunetti", + "type": "user", + "offset": 11, + "length": 14 + } + ] + }, "actions": [{ "name": "Comment", "link": "https://www.facebook.com/579612276/posts/10152483324277277"