test/test_old.rb in rest-graph-1.4.6 vs test/test_old.rb in rest-graph-1.5.0
- old
+ new
@@ -68,6 +68,39 @@
RestGraph.new(:app_id => 'id',
:secret => 'di').
exchange_sessions(:sessions => 'bad bed').
first['access_token'].should == 'bogus'
end
+
+ it 'returns broken json' do
+ stub_request(:get,
+ 'https://api.facebook.com/method/admin.getAppProperties?' \
+ 'access_token=123%7Cs&format=json&properties=app_id'
+ ).to_return(:body => '"{\"app_id\":\"123\"}"')
+
+ RestGraph.new(:app_id => '123', :secret => 's').
+ secret_old_rest('admin.getAppProperties', :properties => 'app_id').
+ should == {'app_id' => '123'}
+ end
+
+ it 'uses an secret access_token' do
+ stub_request(:get,
+ 'https://api.facebook.com/method/admin.getAppProperties?' \
+ 'access_token=123%7Cs&format=json&properties=app_id'
+ ).to_return(:body => '{"app_id":"123"}')
+
+ RestGraph.new(:app_id => '123', :secret => 's').
+ secret_old_rest('admin.getAppProperties', :properties => 'app_id').
+ should == {'app_id' => '123'}
+ end
+
+ it 'would not parse twice in strict mode' do
+ stub_request(:get,
+ 'https://api.facebook.com/method/admin.getAppProperties?' \
+ 'access_token=123%7Cs&format=json&properties=app_id'
+ ).to_return(:body => '"{\"app_id\":\"123\"}"')
+
+ RestGraph.new(:app_id => '123', :secret => 's', :strict => true).
+ secret_old_rest('admin.getAppProperties', :properties => 'app_id').
+ should == '{"app_id":"123"}'
+ end
end