passing the right things to the partial
This commit is contained in:
parent
c7757a302c
commit
e414558f79
4 changed files with 14 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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" )
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue