diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb index 367549c1b..fd190c2c7 100644 --- a/app/models/fb_status.rb +++ b/app/models/fb_status.rb @@ -10,21 +10,21 @@ class FbStatus key :author_id, String key :author_name, String key :message, String - key :updated_time, DateTime + key :updated_time, Time timestamps! validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time - def self.from_api(json) - hash = JSON.parse(json) + def self.from_api(hash) #just keeping them in memory for now self.new( :graph_id => hash['id'], - :author_id => hash['from']['id'] + :author_id => hash['from']['id'], :author_name => hash['from']['name'], - :message => hash['message'] - :updated_time => Time.parse(hash['updated_time'] + :message => hash['message'], + :updated_time => Time.parse(hash['updated_time']) + ) end end diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index e6500e648..4399034f7 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -19,9 +19,9 @@ - for post in @posts = render type_partial(post), :post => post unless post.class == Album - if @logged_in - - MiniFB.get(@access_token, 'me', :type => "feed").each do |item| - - if item['type'] == 'status' - = render "fb_status", :post => FbStatus.from_api(item) + - MiniFB.get(@access_token, 'me', :type => "feed")[:data].each do |item| + - if item[:type] == 'status' + = render "fb_status/fb_status", :post => FbStatus.from_api(item) #pagination = will_paginate @posts diff --git a/app/views/fb_status/_fb_status.html.haml b/app/views/fb_status/_fb_status.html.haml index 30ec62652..d5a57bd22 100644 --- a/app/views/fb_status/_fb_status.html.haml +++ b/app/views/fb_status/_fb_status.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. -%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} +%li.message{:id => post.id} = image_tag( "http://graph.facebook.com/#{post.author_id}/picture" ) diff --git a/spec/models/fb_status_spec.rb b/spec/models/fb_status_spec.rb index a74506512..368f8bd16 100644 --- a/spec/models/fb_status_spec.rb +++ b/spec/models/fb_status_spec.rb @@ -5,7 +5,6 @@ require File.dirname(__FILE__) + '/../spec_helper' -require 'json' describe FbStatus do @@ -16,20 +15,20 @@ describe FbStatus do end describe '#from_api' do - let(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} + let!(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} let!(:json_object) { JSON.parse(json_string) } - let!(:status_from_json) {FbStatus.from_api(json_string)} + let!(:status_from_json) {FbStatus.from_api(json_object)} it 'has graph_id' do status_from_json.graph_id.should == json_object['id'] end it 'has author_id' do - status_from_json.graph_id.should == json_object['from']['id'] + status_from_json.author_id.should == json_object['from']['id'] end it 'has author_name' do - status_from_json.graph_id.should == json_object['from']['name'] + status_from_json.author_name.should == json_object['from']['name'] end it 'has message' do