Skip to content

Commit

Permalink
Add some additional properties from taweili and add tests for propert…
Browse files Browse the repository at this point in the history
…ies that aren't defined
  • Loading branch information
mmangino committed Feb 3, 2011
1 parent 1715c4b commit 7cca6ce
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/mogli/activity.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Mogli
class Activity < Model
define_properties :name, :category, :id
define_properties :name, :category, :id, :created_time
end
end
2 changes: 1 addition & 1 deletion lib/mogli/book.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Mogli
class Book < Model
define_properties :name, :category, :id
define_properties :name, :category, :id, :created_time


end
Expand Down
2 changes: 1 addition & 1 deletion lib/mogli/music.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Mogli
class Music < Model
define_properties :name, :category, :id
define_properties :name, :category, :id, :created_time

end
end
1 change: 1 addition & 0 deletions lib/mogli/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Post < Model
hash_populating_accessor :actions, "Action"
has_association :comments, "Comment"
hash_populating_accessor :from, "User"
hash_populating_accessor :application, "Application"

def likes_create
client.post("#{id}/likes",nil,{})
Expand Down
1 change: 1 addition & 0 deletions lib/mogli/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def self.recognize?(hash)

hash_populating_accessor :location, "Page"
hash_populating_accessor :hometown, "Page"
hash_populating_accessor :languages, "Page"

has_association :activities, "Activity"
has_association :friends, "User"
Expand Down
8 changes: 8 additions & 0 deletions spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@
result = client.post("1/feed","Post",:message=>"message")
result.should == Mogli::Post.new(:id=>123434)
end

it "creates object in a way that ignore invalid properties" do
Mogli::Client.stub!(:post).and_return({:id=>123434,:completely_invalid_property=>1})
client = Mogli::Client.new("1234")
lambda do
result = client.post("1/feed","Post",:message=>"message")
end.should_not raise_error
end

it "raises specific exception if Facebook-imposed posting limit exceeded for feed" do
error_message = "Feed action request limit reached"
Expand Down
6 changes: 6 additions & 0 deletions spec/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class TestModel < Mogli::Model
model.respond_to?(:id).should be_true
model.respond_to?(:other_property).should be_true
end

it "warns when you try to set invalid properties" do
lambda do
TestModel.new(:invalid_property=>1,:id=>2)
end.should_not raise_error
end

it "has a comments attribute which fetches when called" do
mock_client.should_receive(:get_and_map).with("1/comments","Comment", {}).and_return("comments")
Expand Down

0 comments on commit 7cca6ce

Please sign in to comment.