Skip to content

Commit

Permalink
Merge pull request mmangino#59 from utahstreetlabs/master
Browse files Browse the repository at this point in the history
Rename creation query parameter, document creation params
  • Loading branch information
mmangino committed Jul 13, 2011
2 parents 4ecc191 + 9c27b11 commit dae1268
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
28 changes: 23 additions & 5 deletions lib/mogli/test_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,34 @@ module Mogli
class TestUser < User
define_properties :access_token, :login_url, :password

def self.create(query, app_client)
app_client.post("accounts/test-users", self, query)
# test_user_params can include:
#
# installed: This is a Boolean parameter to specify whether your
# app should be installed for the test user at the time of
# creation. It is true by default.
#
# name: this is an optional string parameter. You can specify a
# name for the test user you create. The specified name will also
# be used in the email address assigned to the test user.
#
# permissions: This is a comma-separated list of {extended permissions}[http://developers.facebook.com/docs/reference/api/permissions/].
# Your app is granted these permissions for the new test user if
# installed is true.
#
# Example usage:
#
# Mogli::TestUser.create({:installed => false, :name => 'Zark Muckerberg', :permissions => 'user_events,create_event'}, client)
def self.create(test_user_params, app_client)
app_client.post("accounts/test-users", self, test_user_params)
end

def self.all(query, app_client)
app_client.get_and_map("accounts/test-users", self, query)
def self.all(app_client)
app_client.get_and_map("accounts/test-users", self, {})
end

def to_s
id
# name is nil by default, so use id
id.to_s
end
end
end
7 changes: 4 additions & 3 deletions spec/test_user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
describe "#create" do
it "POSTs to the test user creation url" do
Mogli::Client.should_receive(:post).with("https://graph.facebook.com/#{app_id}/accounts/test-users",
:body => {:access_token => access_token}).and_return({:id=>1, :login_url => 'http://example.com/hamsocks' })
user = Mogli::TestUser.create({}, Mogli::AppClient.new(access_token, app_id))
:body => {:access_token => access_token, :installed => false, :name => 'The Sock Hammer'}).
and_return({:id=>1, :login_url => 'http://example.com/hamsocks' })
user = Mogli::TestUser.create({:installed => false, :name => 'The Sock Hammer'}, Mogli::AppClient.new(access_token, app_id))
user.login_url.should == 'http://example.com/hamsocks'
end
end
Expand All @@ -17,7 +18,7 @@
it "GETs the test user url" do
Mogli::Client.should_receive(:get).with("https://graph.facebook.com/#{app_id}/accounts/test-users",
:query => {:access_token => access_token}).and_return([{:id=>1, :login_url => 'http://example.com/hamsocks'}])
users = Mogli::TestUser.all({}, Mogli::AppClient.new(access_token, app_id))
users = Mogli::TestUser.all(Mogli::AppClient.new(access_token, app_id))
users.first.login_url.should == 'http://example.com/hamsocks'
end
end
Expand Down

0 comments on commit dae1268

Please sign in to comment.