facebook-stub 0.0.1.1 → 0.0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +38 -0
- data/facebook-stub.gemspec +1 -0
- data/facebook-stub.js +159 -57
- data/lib/facebook-stub/version.rb +1 -1
- data/src/facebook.js +159 -57
- metadata +20 -9
data/Readme.md
CHANGED
@@ -54,3 +54,41 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
54
54
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
55
55
|
|
56
56
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
57
|
+
|
58
|
+
# Simulating FB Simple Share
|
59
|
+
|
60
|
+
// App code being tested
|
61
|
+
FB.ui({method:'feed', etc:…}, function(){ … })
|
62
|
+
|
63
|
+
// test pseudo code
|
64
|
+
FBWorld.beingPromptedToShare; //=> false
|
65
|
+
FBWorld.beingPromptedToShareOptions; //=> null
|
66
|
+
FBWorld.beingPromptedToShareCallback; //=> null
|
67
|
+
|
68
|
+
// do whatever causes the above app code to be called
|
69
|
+
FBWorld.beingPromptedToLogin; //=> true
|
70
|
+
FBWorld.beingPromptedToShareOptions; //=> {method:'feed', etc:…}
|
71
|
+
FBWorld.beingPromptedToShareCallback; //=> function(){ … }
|
72
|
+
|
73
|
+
// simulate sharing
|
74
|
+
FBWorld.confirmSharePrompt();
|
75
|
+
// the callback is called here with a response stub containing a post id
|
76
|
+
|
77
|
+
FBWorld.beingPromptedToShare; //=> false
|
78
|
+
FBWorld.beingPromptedToShareOptions; //=> null
|
79
|
+
FBWorld.beingPromptedToShareCallback; //=> null
|
80
|
+
|
81
|
+
// OR
|
82
|
+
|
83
|
+
// do whatever causes the above app code to be called
|
84
|
+
FBWorld.beingPromptedToLogin; //=> true
|
85
|
+
FBWorld.beingPromptedToShareOptions; //=> {method:'feed', etc:…}
|
86
|
+
FBWorld.beingPromptedToShareCallback; //=> function(){ … }
|
87
|
+
|
88
|
+
// simulate sharing
|
89
|
+
FBWorld.cancelSharePrompt();
|
90
|
+
// the callback is called here with a response stub not containing a post id
|
91
|
+
|
92
|
+
FBWorld.beingPromptedToShare; //=> false
|
93
|
+
FBWorld.beingPromptedToShareOptions; //=> null
|
94
|
+
FBWorld.beingPromptedToShareCallback; //=> null
|
data/facebook-stub.gemspec
CHANGED
data/facebook-stub.js
CHANGED
@@ -9,20 +9,110 @@
|
|
9
9
|
state('appId', data.appId);
|
10
10
|
}
|
11
11
|
|
12
|
+
// login
|
12
13
|
function login(callback, options) {
|
13
14
|
if (calledBeforeInit('login')) return;
|
14
15
|
if (FBWorld.state('loggedIn')) {
|
15
16
|
console.log('FB.login() called when user is already connected.');
|
16
17
|
if (FBWorld.state('connected')) {
|
17
18
|
callback(getStatus('standard'));
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
// simulate being prompted to login
|
23
|
+
FBWorld.beingPromptedToLogin = true;
|
24
|
+
FBWorld.beingPromptedToLoginOptions = options;
|
25
|
+
FBWorld.beingPromptedToLoginCallback = callback;
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
// simulates resolving a login prompt in one of three ways
|
30
|
+
function resolveLoginPrompt(successfull, facebook_uid) {
|
31
|
+
if (!FBWorld.beingPromptedToLogin) throw "you are not being prompted to login";
|
32
|
+
var
|
33
|
+
options = FBWorld.beingPromptedToLoginOptions,
|
34
|
+
callback = FBWorld.beingPromptedToLoginCallback;
|
35
|
+
|
36
|
+
// reset the FBWorld state
|
37
|
+
FBWorld.beingPromptedToLogin = false;
|
38
|
+
FBWorld.beingPromptedToLoginOptions = undefined;
|
39
|
+
FBWorld.beingPromptedToLoginCallback = undefined;
|
40
|
+
|
41
|
+
if (successfull){
|
42
|
+
FBWorld.setUid(facebook_uid);
|
43
|
+
FBWorld.loggedIn();
|
44
|
+
|
45
|
+
if (!FBWorld.state('connected')) {
|
46
|
+
promptToConnect(options, callback);
|
18
47
|
} else {
|
19
|
-
|
48
|
+
FBWorld.state('perms', 'standard', options.perms);
|
49
|
+
callback(getStatus('standard'));
|
20
50
|
}
|
51
|
+
|
21
52
|
} else {
|
22
|
-
|
53
|
+
FBWorld.notLoggedIn();
|
54
|
+
callback(getStatus());
|
23
55
|
}
|
56
|
+
};
|
57
|
+
|
58
|
+
function successfullyLogin(facebook_uid){
|
59
|
+
resolveLoginPrompt(true, facebook_uid);
|
60
|
+
}
|
61
|
+
|
62
|
+
function failToLogin(){
|
63
|
+
resolveLoginPrompt(false);
|
64
|
+
}
|
65
|
+
|
66
|
+
function cancelLogin(){
|
67
|
+
resolveLoginPrompt(false);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
// connect to app
|
72
|
+
|
73
|
+
function promptToConnect(options, callback) {
|
74
|
+
FBWorld.beingPromptedToConnect = true;
|
75
|
+
FBWorld.beingPromptedToConnectOptions = options;
|
76
|
+
FBWorld.beingPromptedToConnectCallback = callback;
|
24
77
|
}
|
25
78
|
|
79
|
+
function resolvePromptToConnect(approved) {
|
80
|
+
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
81
|
+
var
|
82
|
+
options = FBWorld.beingPromptedToConnectOptions,
|
83
|
+
callback = FBWorld.beingPromptedToConnectCallback;
|
84
|
+
|
85
|
+
// reset the FBWorld state
|
86
|
+
FBWorld.beingPromptedToConnect = false;
|
87
|
+
FBWorld.beingPromptedToConnectOptions = undefined;
|
88
|
+
FBWorld.beingPromptedToConnectCallback = undefined;
|
89
|
+
|
90
|
+
if (approved){
|
91
|
+
FBWorld.connected();
|
92
|
+
FBWorld.state('perms', 'standard', options.perms);
|
93
|
+
} else {
|
94
|
+
FBWorld.notConnected();
|
95
|
+
}
|
96
|
+
|
97
|
+
callback(getStatus('standard'));
|
98
|
+
}
|
99
|
+
|
100
|
+
function acceptPromptToConnect() {
|
101
|
+
resolvePromptToConnect(true);
|
102
|
+
};
|
103
|
+
|
104
|
+
function denyPromptToConnect() {
|
105
|
+
resolvePromptToConnect(false);
|
106
|
+
};
|
107
|
+
|
108
|
+
function cancelPromptToConnect() {
|
109
|
+
resolvePromptToConnect(false);
|
110
|
+
};
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
26
116
|
function logout(callback) {
|
27
117
|
if (calledBeforeInit('logout')) return;
|
28
118
|
if (!FBWorld.state('loggedIn')) console.log('FB.logout() called without a session.');
|
@@ -127,6 +217,38 @@
|
|
127
217
|
return JSON.parse(FBWorld.Helpers.makeMeACookie('fb_friends') || '[]');
|
128
218
|
}
|
129
219
|
|
220
|
+
|
221
|
+
// sharing
|
222
|
+
|
223
|
+
function ui(options, callback) {
|
224
|
+
if (options.method === 'feed'){
|
225
|
+
FBWorld.beingPromptedToShare = true;
|
226
|
+
FBWorld.beingPromptedToShareOptions = options;
|
227
|
+
FBWorld.beingPromptedToShareCallback = callback;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
// simulate closing the share prompt by either sharing or canceling
|
232
|
+
function resolveSharePrompt(way) {
|
233
|
+
response = {};
|
234
|
+
if (way === 'share') response.post_id = Math.floor(Math.random() * 100000);
|
235
|
+
if (way === 'cancel');
|
236
|
+
|
237
|
+
if (typeof FBWorld.beingPromptedToShareCallback === 'function')
|
238
|
+
FBWorld.beingPromptedToShareCallback(response);
|
239
|
+
FBWorld.beingPromptedToShare = false;
|
240
|
+
FBWorld.beingPromptedToShareOptions = undefined;
|
241
|
+
FBWorld.beingPromptedToShareCallback = undefined;
|
242
|
+
};
|
243
|
+
|
244
|
+
function confirmSharePrompt(){
|
245
|
+
resolveSharePrompt('share');
|
246
|
+
}
|
247
|
+
|
248
|
+
function cancelSharePrompt(){
|
249
|
+
resolveSharePrompt('cancel');
|
250
|
+
}
|
251
|
+
|
130
252
|
var XFBML = {
|
131
253
|
parse: function(element, callback) {
|
132
254
|
callback();
|
@@ -141,11 +263,16 @@
|
|
141
263
|
getSession : getSession,
|
142
264
|
api : api,
|
143
265
|
XFBML : XFBML,
|
144
|
-
getUserID : getUserID
|
266
|
+
getUserID : getUserID,
|
267
|
+
ui : ui
|
145
268
|
};
|
146
269
|
|
147
270
|
FBWorld = { // used to set the state of Facebook
|
271
|
+
|
272
|
+
// the state of the Facebook World
|
148
273
|
state : state,
|
274
|
+
|
275
|
+
// Set the state of the Facebook World
|
149
276
|
loggedIn : loggedIn,
|
150
277
|
notLoggedIn : notLoggedIn,
|
151
278
|
setUid : setUid,
|
@@ -156,22 +283,43 @@
|
|
156
283
|
setExtendedPermissions : setExtendedPermissions,
|
157
284
|
|
158
285
|
initialized : false,
|
159
|
-
beingPromptedToLogIn : false,
|
160
|
-
beingPromptedToLogInCallback : undefined,
|
161
|
-
// this will come later, no need for it now
|
162
|
-
// successfullyLogin: successfullyLogin,
|
163
|
-
// failToLogin: failToLogin,
|
164
286
|
|
287
|
+
// Simulate interactions with Facebook
|
288
|
+
|
289
|
+
// login
|
290
|
+
beingPromptedToLogin : false,
|
291
|
+
beingPromptedToLoginOptions : undefined,
|
292
|
+
beingPromptedToLoginCallback : undefined,
|
293
|
+
successfullyLogin : successfullyLogin,
|
294
|
+
failToLogin : failToLogin,
|
295
|
+
cancelLogin : cancelLogin,
|
296
|
+
|
297
|
+
// connecting
|
165
298
|
beingPromptedToConnect : false,
|
166
|
-
|
167
|
-
|
168
|
-
|
299
|
+
beingPromptedToConnectOptions : undefined,
|
300
|
+
beingPromptedToConnectCallback : undefined,
|
301
|
+
acceptPromptToConnect : acceptPromptToConnect,
|
302
|
+
denyPromptToConnect : denyPromptToConnect,
|
303
|
+
cancelPromptToConnect : cancelPromptToConnect,
|
304
|
+
|
305
|
+
//sharing
|
306
|
+
beingPromptedToShare : false,
|
307
|
+
beingPromptedToShareOptions : undefined,
|
308
|
+
beingPromptedToShareCallback : undefined,
|
309
|
+
confirmSharePrompt : confirmSharePrompt,
|
310
|
+
cancelSharePrompt : cancelSharePrompt,
|
169
311
|
|
170
312
|
//friends
|
171
313
|
addFriend : addFriend,
|
172
314
|
friendList : friendList
|
173
315
|
};
|
174
316
|
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
175
323
|
// PRIVATE FUNCTIONS
|
176
324
|
|
177
325
|
function getStatus(permissions) {
|
@@ -216,52 +364,6 @@
|
|
216
364
|
return true;
|
217
365
|
}
|
218
366
|
|
219
|
-
function simulatePromptToLogin(callback, options) {
|
220
|
-
// simulate being prompted to log in
|
221
|
-
FBWorld.beingPromptedToLogIn = true;
|
222
|
-
FBWorld.beingPromptedToLogInCallback = function(approved) {
|
223
|
-
FBWorld.beingPromptedToLogin = false;
|
224
|
-
FBWorld.beingPromptedToLoginCallback = undefined;
|
225
|
-
if(approved) {
|
226
|
-
FBWorld.loggedIn();
|
227
|
-
if (!FBWorld.state('connected')) {
|
228
|
-
simulatePromptToConnect(callback, options);
|
229
|
-
} else {
|
230
|
-
FBWorld.state('perms', 'standard', options.perms);
|
231
|
-
callback(getStatus('standard'));
|
232
|
-
}
|
233
|
-
} else {
|
234
|
-
FBWorld.notLoggedIn();
|
235
|
-
callback(getStatus());
|
236
|
-
}
|
237
|
-
|
238
|
-
};
|
239
|
-
};
|
240
|
-
|
241
|
-
function simulatePromptToConnect(callback, options) {
|
242
|
-
// simulate being prompted to connect
|
243
|
-
FBWorld.beingPromptedToConnect = true;
|
244
|
-
FBWorld.beingPromptedToConnectCallback = function(approved) {
|
245
|
-
approved ? FBWorld.connected() : FBWorld.notConnected();
|
246
|
-
FBWorld.beingPromptedToConnect = false;
|
247
|
-
FBWorld.beingPromptedToConnectCallback = undefined;
|
248
|
-
if (approved) {
|
249
|
-
FBWorld.state('perms', 'standard', options.perms);
|
250
|
-
}
|
251
|
-
callback(getStatus('standard'));
|
252
|
-
};
|
253
|
-
};
|
254
|
-
|
255
|
-
function allowConnection() {
|
256
|
-
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
257
|
-
FBWorld.beingPromptedToConnectCallback(true);
|
258
|
-
};
|
259
|
-
|
260
|
-
function denyConnection() {
|
261
|
-
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
262
|
-
FBWorld.beingPromptedToConnectCallback(false);
|
263
|
-
};
|
264
|
-
|
265
367
|
var cookieOptions = { path: '/', domain: window.location.hostname.replace(/^www/, '')};
|
266
368
|
|
267
369
|
// cookie looks like this: (with the quotes): "access_token=theToken&base_domain=local-change.org&expires=0&secret=theSecret&session_key=theSessionKeysig=theSig-Hashed&uid=theUID"
|
data/src/facebook.js
CHANGED
@@ -9,20 +9,110 @@
|
|
9
9
|
state('appId', data.appId);
|
10
10
|
}
|
11
11
|
|
12
|
+
// login
|
12
13
|
function login(callback, options) {
|
13
14
|
if (calledBeforeInit('login')) return;
|
14
15
|
if (FBWorld.state('loggedIn')) {
|
15
16
|
console.log('FB.login() called when user is already connected.');
|
16
17
|
if (FBWorld.state('connected')) {
|
17
18
|
callback(getStatus('standard'));
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
// simulate being prompted to login
|
23
|
+
FBWorld.beingPromptedToLogin = true;
|
24
|
+
FBWorld.beingPromptedToLoginOptions = options;
|
25
|
+
FBWorld.beingPromptedToLoginCallback = callback;
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
// simulates resolving a login prompt in one of three ways
|
30
|
+
function resolveLoginPrompt(successfull, facebook_uid) {
|
31
|
+
if (!FBWorld.beingPromptedToLogin) throw "you are not being prompted to login";
|
32
|
+
var
|
33
|
+
options = FBWorld.beingPromptedToLoginOptions,
|
34
|
+
callback = FBWorld.beingPromptedToLoginCallback;
|
35
|
+
|
36
|
+
// reset the FBWorld state
|
37
|
+
FBWorld.beingPromptedToLogin = false;
|
38
|
+
FBWorld.beingPromptedToLoginOptions = undefined;
|
39
|
+
FBWorld.beingPromptedToLoginCallback = undefined;
|
40
|
+
|
41
|
+
if (successfull){
|
42
|
+
FBWorld.setUid(facebook_uid);
|
43
|
+
FBWorld.loggedIn();
|
44
|
+
|
45
|
+
if (!FBWorld.state('connected')) {
|
46
|
+
promptToConnect(options, callback);
|
18
47
|
} else {
|
19
|
-
|
48
|
+
FBWorld.state('perms', 'standard', options.perms);
|
49
|
+
callback(getStatus('standard'));
|
20
50
|
}
|
51
|
+
|
52
|
+
} else {
|
53
|
+
FBWorld.notLoggedIn();
|
54
|
+
callback(getStatus());
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
function successfullyLogin(facebook_uid){
|
59
|
+
resolveLoginPrompt(true, facebook_uid);
|
60
|
+
}
|
61
|
+
|
62
|
+
function failToLogin(){
|
63
|
+
resolveLoginPrompt(false);
|
64
|
+
}
|
65
|
+
|
66
|
+
function cancelLogin(){
|
67
|
+
resolveLoginPrompt(false);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
// connect to app
|
72
|
+
|
73
|
+
function promptToConnect(options, callback) {
|
74
|
+
FBWorld.beingPromptedToConnect = true;
|
75
|
+
FBWorld.beingPromptedToConnectOptions = options;
|
76
|
+
FBWorld.beingPromptedToConnectCallback = callback;
|
77
|
+
}
|
78
|
+
|
79
|
+
function resolvePromptToConnect(approved) {
|
80
|
+
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
81
|
+
var
|
82
|
+
options = FBWorld.beingPromptedToConnectOptions,
|
83
|
+
callback = FBWorld.beingPromptedToConnectCallback;
|
84
|
+
|
85
|
+
// reset the FBWorld state
|
86
|
+
FBWorld.beingPromptedToConnect = false;
|
87
|
+
FBWorld.beingPromptedToConnectOptions = undefined;
|
88
|
+
FBWorld.beingPromptedToConnectCallback = undefined;
|
89
|
+
|
90
|
+
if (approved){
|
91
|
+
FBWorld.connected();
|
92
|
+
FBWorld.state('perms', 'standard', options.perms);
|
21
93
|
} else {
|
22
|
-
|
94
|
+
FBWorld.notConnected();
|
23
95
|
}
|
96
|
+
|
97
|
+
callback(getStatus('standard'));
|
24
98
|
}
|
25
99
|
|
100
|
+
function acceptPromptToConnect() {
|
101
|
+
resolvePromptToConnect(true);
|
102
|
+
};
|
103
|
+
|
104
|
+
function denyPromptToConnect() {
|
105
|
+
resolvePromptToConnect(false);
|
106
|
+
};
|
107
|
+
|
108
|
+
function cancelPromptToConnect() {
|
109
|
+
resolvePromptToConnect(false);
|
110
|
+
};
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
26
116
|
function logout(callback) {
|
27
117
|
if (calledBeforeInit('logout')) return;
|
28
118
|
if (!FBWorld.state('loggedIn')) console.log('FB.logout() called without a session.');
|
@@ -127,6 +217,38 @@
|
|
127
217
|
return JSON.parse(FBWorld.Helpers.makeMeACookie('fb_friends') || '[]');
|
128
218
|
}
|
129
219
|
|
220
|
+
|
221
|
+
// sharing
|
222
|
+
|
223
|
+
function ui(options, callback) {
|
224
|
+
if (options.method === 'feed'){
|
225
|
+
FBWorld.beingPromptedToShare = true;
|
226
|
+
FBWorld.beingPromptedToShareOptions = options;
|
227
|
+
FBWorld.beingPromptedToShareCallback = callback;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
// simulate closing the share prompt by either sharing or canceling
|
232
|
+
function resolveSharePrompt(way) {
|
233
|
+
response = {};
|
234
|
+
if (way === 'share') response.post_id = Math.floor(Math.random() * 100000);
|
235
|
+
if (way === 'cancel');
|
236
|
+
|
237
|
+
if (typeof FBWorld.beingPromptedToShareCallback === 'function')
|
238
|
+
FBWorld.beingPromptedToShareCallback(response);
|
239
|
+
FBWorld.beingPromptedToShare = false;
|
240
|
+
FBWorld.beingPromptedToShareOptions = undefined;
|
241
|
+
FBWorld.beingPromptedToShareCallback = undefined;
|
242
|
+
};
|
243
|
+
|
244
|
+
function confirmSharePrompt(){
|
245
|
+
resolveSharePrompt('share');
|
246
|
+
}
|
247
|
+
|
248
|
+
function cancelSharePrompt(){
|
249
|
+
resolveSharePrompt('cancel');
|
250
|
+
}
|
251
|
+
|
130
252
|
var XFBML = {
|
131
253
|
parse: function(element, callback) {
|
132
254
|
callback();
|
@@ -141,11 +263,16 @@
|
|
141
263
|
getSession : getSession,
|
142
264
|
api : api,
|
143
265
|
XFBML : XFBML,
|
144
|
-
getUserID : getUserID
|
266
|
+
getUserID : getUserID,
|
267
|
+
ui : ui
|
145
268
|
};
|
146
269
|
|
147
270
|
FBWorld = { // used to set the state of Facebook
|
271
|
+
|
272
|
+
// the state of the Facebook World
|
148
273
|
state : state,
|
274
|
+
|
275
|
+
// Set the state of the Facebook World
|
149
276
|
loggedIn : loggedIn,
|
150
277
|
notLoggedIn : notLoggedIn,
|
151
278
|
setUid : setUid,
|
@@ -156,22 +283,43 @@
|
|
156
283
|
setExtendedPermissions : setExtendedPermissions,
|
157
284
|
|
158
285
|
initialized : false,
|
159
|
-
beingPromptedToLogIn : false,
|
160
|
-
beingPromptedToLogInCallback : undefined,
|
161
|
-
// this will come later, no need for it now
|
162
|
-
// successfullyLogin: successfullyLogin,
|
163
|
-
// failToLogin: failToLogin,
|
164
286
|
|
287
|
+
// Simulate interactions with Facebook
|
288
|
+
|
289
|
+
// login
|
290
|
+
beingPromptedToLogin : false,
|
291
|
+
beingPromptedToLoginOptions : undefined,
|
292
|
+
beingPromptedToLoginCallback : undefined,
|
293
|
+
successfullyLogin : successfullyLogin,
|
294
|
+
failToLogin : failToLogin,
|
295
|
+
cancelLogin : cancelLogin,
|
296
|
+
|
297
|
+
// connecting
|
165
298
|
beingPromptedToConnect : false,
|
166
|
-
|
167
|
-
|
168
|
-
|
299
|
+
beingPromptedToConnectOptions : undefined,
|
300
|
+
beingPromptedToConnectCallback : undefined,
|
301
|
+
acceptPromptToConnect : acceptPromptToConnect,
|
302
|
+
denyPromptToConnect : denyPromptToConnect,
|
303
|
+
cancelPromptToConnect : cancelPromptToConnect,
|
304
|
+
|
305
|
+
//sharing
|
306
|
+
beingPromptedToShare : false,
|
307
|
+
beingPromptedToShareOptions : undefined,
|
308
|
+
beingPromptedToShareCallback : undefined,
|
309
|
+
confirmSharePrompt : confirmSharePrompt,
|
310
|
+
cancelSharePrompt : cancelSharePrompt,
|
169
311
|
|
170
312
|
//friends
|
171
313
|
addFriend : addFriend,
|
172
314
|
friendList : friendList
|
173
315
|
};
|
174
316
|
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
175
323
|
// PRIVATE FUNCTIONS
|
176
324
|
|
177
325
|
function getStatus(permissions) {
|
@@ -216,52 +364,6 @@
|
|
216
364
|
return true;
|
217
365
|
}
|
218
366
|
|
219
|
-
function simulatePromptToLogin(callback, options) {
|
220
|
-
// simulate being prompted to log in
|
221
|
-
FBWorld.beingPromptedToLogIn = true;
|
222
|
-
FBWorld.beingPromptedToLogInCallback = function(approved) {
|
223
|
-
FBWorld.beingPromptedToLogin = false;
|
224
|
-
FBWorld.beingPromptedToLoginCallback = undefined;
|
225
|
-
if(approved) {
|
226
|
-
FBWorld.loggedIn();
|
227
|
-
if (!FBWorld.state('connected')) {
|
228
|
-
simulatePromptToConnect(callback, options);
|
229
|
-
} else {
|
230
|
-
FBWorld.state('perms', 'standard', options.perms);
|
231
|
-
callback(getStatus('standard'));
|
232
|
-
}
|
233
|
-
} else {
|
234
|
-
FBWorld.notLoggedIn();
|
235
|
-
callback(getStatus());
|
236
|
-
}
|
237
|
-
|
238
|
-
};
|
239
|
-
};
|
240
|
-
|
241
|
-
function simulatePromptToConnect(callback, options) {
|
242
|
-
// simulate being prompted to connect
|
243
|
-
FBWorld.beingPromptedToConnect = true;
|
244
|
-
FBWorld.beingPromptedToConnectCallback = function(approved) {
|
245
|
-
approved ? FBWorld.connected() : FBWorld.notConnected();
|
246
|
-
FBWorld.beingPromptedToConnect = false;
|
247
|
-
FBWorld.beingPromptedToConnectCallback = undefined;
|
248
|
-
if (approved) {
|
249
|
-
FBWorld.state('perms', 'standard', options.perms);
|
250
|
-
}
|
251
|
-
callback(getStatus('standard'));
|
252
|
-
};
|
253
|
-
};
|
254
|
-
|
255
|
-
function allowConnection() {
|
256
|
-
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
257
|
-
FBWorld.beingPromptedToConnectCallback(true);
|
258
|
-
};
|
259
|
-
|
260
|
-
function denyConnection() {
|
261
|
-
if (!FBWorld.beingPromptedToConnect) throw "you are not being prompted to connect";
|
262
|
-
FBWorld.beingPromptedToConnectCallback(false);
|
263
|
-
};
|
264
|
-
|
265
367
|
var cookieOptions = { path: '/', domain: window.location.hostname.replace(/^www/, '')};
|
266
368
|
|
267
369
|
// cookie looks like this: (with the quotes): "access_token=theToken&base_domain=local-change.org&expires=0&secret=theSecret&session_key=theSessionKeysig=theSig-Hashed&uid=theUID"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-stub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 79
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 1
|
10
|
-
-
|
11
|
-
version: 0.0.1.
|
10
|
+
- 2
|
11
|
+
version: 0.0.1.2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Change.org
|
@@ -16,10 +16,22 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
date: 2012-04-03 00:00:00 Z
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
requirement: *id001
|
32
|
+
prerelease: false
|
33
|
+
name: rake
|
34
|
+
type: :development
|
23
35
|
description: facebook-stub is a gem for stubbing out the Facebook JavaScript API in acceptance and integration tests.
|
24
36
|
email:
|
25
37
|
- techops@change.org
|
@@ -46,7 +58,6 @@ files:
|
|
46
58
|
- src/libs/sha256.js
|
47
59
|
- src/libs/utf8_encode.js
|
48
60
|
- test/test.html
|
49
|
-
has_rdoc: true
|
50
61
|
homepage: ""
|
51
62
|
licenses: []
|
52
63
|
|
@@ -76,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
87
|
requirements: []
|
77
88
|
|
78
89
|
rubyforge_project: facebook-stub
|
79
|
-
rubygems_version: 1.
|
90
|
+
rubygems_version: 1.8.10
|
80
91
|
signing_key:
|
81
92
|
specification_version: 3
|
82
93
|
summary: Stub out the FB JS API
|