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_id, String
|
||||||
key :author_name, String
|
key :author_name, String
|
||||||
key :message, String
|
key :message, String
|
||||||
key :updated_time, DateTime
|
key :updated_time, Time
|
||||||
|
|
||||||
timestamps!
|
timestamps!
|
||||||
|
|
||||||
validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time
|
validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time
|
||||||
|
|
||||||
def self.from_api(json)
|
def self.from_api(hash)
|
||||||
hash = JSON.parse(json)
|
|
||||||
#just keeping them in memory for now
|
#just keeping them in memory for now
|
||||||
self.new(
|
self.new(
|
||||||
:graph_id => hash['id'],
|
:graph_id => hash['id'],
|
||||||
:author_id => hash['from']['id']
|
:author_id => hash['from']['id'],
|
||||||
:author_name => hash['from']['name'],
|
:author_name => hash['from']['name'],
|
||||||
:message => hash['message']
|
:message => hash['message'],
|
||||||
:updated_time => Time.parse(hash['updated_time']
|
:updated_time => Time.parse(hash['updated_time'])
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
= render type_partial(post), :post => post unless post.class == Album
|
= render type_partial(post), :post => post unless post.class == Album
|
||||||
- if @logged_in
|
- if @logged_in
|
||||||
- MiniFB.get(@access_token, 'me', :type => "feed").each do |item|
|
- MiniFB.get(@access_token, 'me', :type => "feed")[:data].each do |item|
|
||||||
- if item['type'] == 'status'
|
- if item[:type] == 'status'
|
||||||
= render "fb_status", :post => FbStatus.from_api(item)
|
= render "fb_status/fb_status", :post => FbStatus.from_api(item)
|
||||||
|
|
||||||
#pagination
|
#pagination
|
||||||
= will_paginate @posts
|
= will_paginate @posts
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
-# the COPYRIGHT file.
|
-# 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" )
|
= image_tag( "http://graph.facebook.com/#{post.author_id}/picture" )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
require 'json'
|
|
||||||
|
|
||||||
describe FbStatus do
|
describe FbStatus do
|
||||||
|
|
||||||
|
|
@ -16,20 +15,20 @@ describe FbStatus do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#from_api' do
|
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!(: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
|
it 'has graph_id' do
|
||||||
status_from_json.graph_id.should == json_object['id']
|
status_from_json.graph_id.should == json_object['id']
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has author_id' do
|
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
|
end
|
||||||
|
|
||||||
it 'has author_name' do
|
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
|
end
|
||||||
|
|
||||||
it 'has message' do
|
it 'has message' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue