authlogic_facebook_shim 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +76 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/authlogic_facebook_shim.gemspec +30 -0
- data/init.rb +1 -0
- data/lib/authlogic_facebook_shim/acts_as_authentic.rb +20 -0
- data/lib/authlogic_facebook_shim/helper.rb +4 -0
- data/lib/authlogic_facebook_shim/session/adapter.rb +1 -0
- data/lib/authlogic_facebook_shim/session/adapters/koala_adapter.rb +35 -0
- data/lib/authlogic_facebook_shim/session/config.rb +82 -0
- data/lib/authlogic_facebook_shim/session/facebook.rb +72 -0
- data/lib/authlogic_facebook_shim/session.rb +12 -0
- data/lib/authlogic_facebook_shim.rb +15 -0
- data/rails/init.rb +1 -0
- data/test/rails_root/app/controllers/application_controller.rb +10 -0
- data/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/app/models/user.rb +7 -0
- data/test/rails_root/app/models/user_session.rb +7 -0
- data/test/rails_root/config/boot.rb +110 -0
- data/test/rails_root/config/database.yml +10 -0
- data/test/rails_root/config/environment.rb +31 -0
- data/test/rails_root/config/environments/development.rb +0 -0
- data/test/rails_root/config/environments/test.rb +0 -0
- data/test/rails_root/config/facebook.yml +7 -0
- data/test/rails_root/config/initializers/authlogic_facebook_koala.rb +5 -0
- data/test/rails_root/config/initializers/new_rails_defaults.rb +21 -0
- data/test/rails_root/config/initializers/session_store.rb +15 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +43 -0
- data/test/rails_root/db/migrate/20101217000008_create_users.rb +37 -0
- data/test/rails_root/db/seeds.rb +7 -0
- data/test/rails_root/log/test.log +159 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/test_helper.rb +43 -0
- data/test/units/session/adapter_test.rb +182 -0
- data/test/units/session/config_test.rb +145 -0
- data/test/units/session/facebook_test.rb +221 -0
- metadata +234 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
|
4
|
+
# Sample of regular route:
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
7
|
+
|
8
|
+
# Sample of named route:
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
11
|
+
|
12
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
13
|
+
# map.resources :products
|
14
|
+
|
15
|
+
# Sample resource route with options:
|
16
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
17
|
+
|
18
|
+
# Sample resource route with sub-resources:
|
19
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
20
|
+
|
21
|
+
# Sample resource route with more complex sub-resources
|
22
|
+
# map.resources :products do |products|
|
23
|
+
# products.resources :comments
|
24
|
+
# products.resources :sales, :collection => { :recent => :get }
|
25
|
+
# end
|
26
|
+
|
27
|
+
# Sample resource route within a namespace:
|
28
|
+
# map.namespace :admin do |admin|
|
29
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
30
|
+
# admin.resources :products
|
31
|
+
# end
|
32
|
+
|
33
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
34
|
+
# map.root :controller => "welcome"
|
35
|
+
|
36
|
+
# See how all your routes lay out with "rake routes"
|
37
|
+
|
38
|
+
# Install the default routes as the lowest priority.
|
39
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
40
|
+
# consider removing or commenting them out if you're using named routes and resources.
|
41
|
+
map.connect ':controller/:action/:id'
|
42
|
+
map.connect ':controller/:action/:id.:format'
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :users do |t|
|
5
|
+
t.datetime :created_at
|
6
|
+
t.datetime :updated_at
|
7
|
+
t.integer :lock_version, :default => 0
|
8
|
+
t.integer :company_id
|
9
|
+
t.string :login
|
10
|
+
t.string :crypted_password
|
11
|
+
t.string :password_salt
|
12
|
+
t.string :persistence_token
|
13
|
+
t.string :single_access_token
|
14
|
+
t.string :perishable_token
|
15
|
+
t.string :email
|
16
|
+
t.string :first_name
|
17
|
+
t.string :last_name
|
18
|
+
t.integer :login_count, :default => 0, :null => false
|
19
|
+
t.integer :failed_login_count, :default => 0, :null => false
|
20
|
+
t.datetime :last_request_at
|
21
|
+
t.datetime :current_login_at
|
22
|
+
t.datetime :last_login_at
|
23
|
+
t.string :current_login_ip
|
24
|
+
t.string :last_login_ip
|
25
|
+
t.boolean :active, :default => true
|
26
|
+
t.boolean :approved, :default => true
|
27
|
+
t.boolean :confirmed, :default => true
|
28
|
+
t.string :facebook_uid
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.down
|
34
|
+
drop_table :users
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
7
|
+
# Major.create(:name => 'Daley', :city => cities.first)
|
@@ -0,0 +1,159 @@
|
|
1
|
+
# Logfile created on Wed Jan 05 01:40:52 +0000 2011 [4;36;1mSQL (0.2ms)[0m [0;1m SELECT name
|
2
|
+
FROM sqlite_master
|
3
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
4
|
+
[0m
|
5
|
+
[4;35;1mSQL (0.1ms)[0m [0mselect sqlite_version(*)[0m
|
6
|
+
[4;36;1mSQL (0.2ms)[0m [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
7
|
+
[4;35;1mSQL (7.2ms)[0m [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
8
|
+
[4;36;1mSQL (0.1ms)[0m [0;1m SELECT name
|
9
|
+
FROM sqlite_master
|
10
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
11
|
+
[0m
|
12
|
+
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM schema_migrations[0m
|
13
|
+
Migrating to CreateUsers (20101217000008)
|
14
|
+
[4;36;1mSQL (0.4ms)[0m [0;1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "lock_version" integer DEFAULT 0, "company_id" integer, "login" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "single_access_token" varchar(255), "perishable_token" varchar(255), "email" varchar(255), "first_name" varchar(255), "last_name" varchar(255), "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" datetime, "current_login_at" datetime, "last_login_at" datetime, "current_login_ip" varchar(255), "last_login_ip" varchar(255), "active" boolean DEFAULT 't', "approved" boolean DEFAULT 't', "confirmed" boolean DEFAULT 't', "facebook_uid" varchar(255)) [0m
|
15
|
+
[4;35;1mSQL (0.1ms)[0m [0mINSERT INTO schema_migrations (version) VALUES ('20101217000008')[0m
|
16
|
+
[4;36;1mSQL (0.2ms)[0m [0;1m SELECT name
|
17
|
+
FROM sqlite_master
|
18
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
19
|
+
[0m
|
20
|
+
[4;35;1mSQL (0.1ms)[0m [0mselect sqlite_version(*)[0m
|
21
|
+
[4;36;1mSQL (0.2ms)[0m [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
22
|
+
[4;35;1mSQL (0.1ms)[0m [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
23
|
+
[4;36;1mSQL (0.1ms)[0m [0;1m SELECT name
|
24
|
+
FROM sqlite_master
|
25
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
26
|
+
[0m
|
27
|
+
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM schema_migrations[0m
|
28
|
+
Migrating to CreateUsers (20101217000008)
|
29
|
+
[4;36;1mSQL (0.4ms)[0m [0;1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "lock_version" integer DEFAULT 0, "company_id" integer, "login" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "single_access_token" varchar(255), "perishable_token" varchar(255), "email" varchar(255), "first_name" varchar(255), "last_name" varchar(255), "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" datetime, "current_login_at" datetime, "last_login_at" datetime, "current_login_ip" varchar(255), "last_login_ip" varchar(255), "active" boolean DEFAULT 't', "approved" boolean DEFAULT 't', "confirmed" boolean DEFAULT 't', "facebook_uid" varchar(255)) [0m
|
30
|
+
[4;35;1mSQL (0.1ms)[0m [0mINSERT INTO schema_migrations (version) VALUES ('20101217000008')[0m
|
31
|
+
[4;36;1mSQL (0.2ms)[0m [0;1m SELECT name
|
32
|
+
FROM sqlite_master
|
33
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
34
|
+
[0m
|
35
|
+
[4;35;1mSQL (0.1ms)[0m [0mselect sqlite_version(*)[0m
|
36
|
+
[4;36;1mSQL (0.2ms)[0m [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
37
|
+
[4;35;1mSQL (0.1ms)[0m [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
38
|
+
[4;36;1mSQL (0.1ms)[0m [0;1m SELECT name
|
39
|
+
FROM sqlite_master
|
40
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
41
|
+
[0m
|
42
|
+
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM schema_migrations[0m
|
43
|
+
Migrating to CreateUsers (20101217000008)
|
44
|
+
[4;36;1mSQL (0.4ms)[0m [0;1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "lock_version" integer DEFAULT 0, "company_id" integer, "login" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "single_access_token" varchar(255), "perishable_token" varchar(255), "email" varchar(255), "first_name" varchar(255), "last_name" varchar(255), "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" datetime, "current_login_at" datetime, "last_login_at" datetime, "current_login_ip" varchar(255), "last_login_ip" varchar(255), "active" boolean DEFAULT 't', "approved" boolean DEFAULT 't', "confirmed" boolean DEFAULT 't', "facebook_uid" varchar(255)) [0m
|
45
|
+
[4;35;1mSQL (0.1ms)[0m [0mINSERT INTO schema_migrations (version) VALUES ('20101217000008')[0m
|
46
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = '72a56332b80ccce18b13e24b0e193383419b63c3fb1798474d1d2fbc49e0e0c640d9eb328ea3949cfdbe9f4984ef51132dc821dcafe82291d6a7f9654578fdd0') LIMIT 1[0m
|
47
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'o1TkjpoSNbRglu_Nny9i') LIMIT 1[0m
|
48
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 01:47:31', 'o1TkjpoSNbRglu_Nny9i', NULL, NULL, 't', '2011-01-05 01:47:31', 'kbKVu_fzl3zAdkaKqm8k', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, '72a56332b80ccce18b13e24b0e193383419b63c3fb1798474d1d2fbc49e0e0c640d9eb328ea3949cfdbe9f4984ef51132dc821dcafe82291d6a7f9654578fdd0', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
49
|
+
[4;35;1mUser Update with optimistic locking (0.2ms)[0m [0m UPDATE "users"
|
50
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 01:47:31', "perishable_token" = 'eBX7IHdAgmkD1NuYf6ks', "last_request_at" = '2011-01-05 01:47:31', "lock_version" = 1, "current_login_at" = '2011-01-05 01:47:31'
|
51
|
+
WHERE id = 1
|
52
|
+
AND "lock_version" = 0
|
53
|
+
[0m
|
54
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = 'ba949a3c116ccf90e278370aefe8d198b1c44b06d330d2785965d6d06932eab5e5d04a11eba78793981ce99709e040638af0187b94d0e02d5d348527c6403fe9') LIMIT 1[0m
|
55
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'QBTbe977IaKzGNEmbGeT') LIMIT 1[0m
|
56
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 01:47:31', 'QBTbe977IaKzGNEmbGeT', NULL, NULL, 't', '2011-01-05 01:47:31', 'EdnvXXaE3DgvItlwrQTE', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, 'ba949a3c116ccf90e278370aefe8d198b1c44b06d330d2785965d6d06932eab5e5d04a11eba78793981ce99709e040638af0187b94d0e02d5d348527c6403fe9', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
57
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
58
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 01:47:31', "perishable_token" = 'yfo9QWt0wyoR9cyueALR', "last_request_at" = '2011-01-05 01:47:31', "lock_version" = 1, "current_login_at" = '2011-01-05 01:47:31'
|
59
|
+
WHERE id = 2
|
60
|
+
AND "lock_version" = 0
|
61
|
+
[0m
|
62
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 01:47:31', NULL, NULL, NULL, 't', '2011-01-05 01:47:31', 'o9xqKY8m8w5YJNW6sAl4', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
63
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
64
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 01:47:31', "perishable_token" = 'P0kwHxl3Vx33kfdJnDeG', "last_request_at" = '2011-01-05 01:47:31', "lock_version" = 1, "current_login_at" = '2011-01-05 01:47:31'
|
65
|
+
WHERE id = 3
|
66
|
+
AND "lock_version" = 0
|
67
|
+
[0m
|
68
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 01:47:31', NULL, NULL, NULL, 't', '2011-01-05 01:47:31', 'bIvjHnDDx6lWoACx4RDq', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
69
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
70
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 01:47:31', "perishable_token" = 'RkxnsBc6tZx5cUseox5f', "last_request_at" = '2011-01-05 01:47:31', "lock_version" = 1, "current_login_at" = '2011-01-05 01:47:31'
|
71
|
+
WHERE id = 4
|
72
|
+
AND "lock_version" = 0
|
73
|
+
[0m
|
74
|
+
[4;36;1mSQL (0.2ms)[0m [0;1m SELECT name
|
75
|
+
FROM sqlite_master
|
76
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
77
|
+
[0m
|
78
|
+
[4;35;1mSQL (0.1ms)[0m [0mselect sqlite_version(*)[0m
|
79
|
+
[4;36;1mSQL (0.2ms)[0m [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
80
|
+
[4;35;1mSQL (0.1ms)[0m [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
81
|
+
[4;36;1mSQL (0.1ms)[0m [0;1m SELECT name
|
82
|
+
FROM sqlite_master
|
83
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
84
|
+
[0m
|
85
|
+
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM schema_migrations[0m
|
86
|
+
Migrating to CreateUsers (20101217000008)
|
87
|
+
[4;36;1mSQL (0.4ms)[0m [0;1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "lock_version" integer DEFAULT 0, "company_id" integer, "login" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "single_access_token" varchar(255), "perishable_token" varchar(255), "email" varchar(255), "first_name" varchar(255), "last_name" varchar(255), "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" datetime, "current_login_at" datetime, "last_login_at" datetime, "current_login_ip" varchar(255), "last_login_ip" varchar(255), "active" boolean DEFAULT 't', "approved" boolean DEFAULT 't', "confirmed" boolean DEFAULT 't', "facebook_uid" varchar(255)) [0m
|
88
|
+
[4;35;1mSQL (0.1ms)[0m [0mINSERT INTO schema_migrations (version) VALUES ('20101217000008')[0m
|
89
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = '2339319a4fd4b9e6aeb8aedd56dc78fdb960edcd9591edada9623f8494f29684aa1057a2279c68ef2f532e222fbf1584e2355f739405084910737239e6f6faac') LIMIT 1[0m
|
90
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'x9trgkKYah_VHQOaSbq9') LIMIT 1[0m
|
91
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:49:27', 'x9trgkKYah_VHQOaSbq9', NULL, NULL, 't', '2011-01-05 02:49:27', 'Xh4yvJBdbhgKKgOxBpbQ', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, '2339319a4fd4b9e6aeb8aedd56dc78fdb960edcd9591edada9623f8494f29684aa1057a2279c68ef2f532e222fbf1584e2355f739405084910737239e6f6faac', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
92
|
+
[4;35;1mUser Update with optimistic locking (0.2ms)[0m [0m UPDATE "users"
|
93
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:49:27', "perishable_token" = '5jXBntUCMDJKgvCOcd6y', "last_request_at" = '2011-01-05 02:49:27', "lock_version" = 1, "current_login_at" = '2011-01-05 02:49:27'
|
94
|
+
WHERE id = 1
|
95
|
+
AND "lock_version" = 0
|
96
|
+
[0m
|
97
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = 'e13ed14d0711ed4f29218cdb9546b92aff7c89a83826f8b2368df24d5fb0fdb033401a1e670bb67ba686c171fdfeeb4203a87223de46c899a9ea7a706a249043') LIMIT 1[0m
|
98
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'aFx5vHL_bbNpu7KfP9Sh') LIMIT 1[0m
|
99
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:49:27', 'aFx5vHL_bbNpu7KfP9Sh', NULL, NULL, 't', '2011-01-05 02:49:27', 'lPEBVK4Axjveuiw2x8dB', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, 'e13ed14d0711ed4f29218cdb9546b92aff7c89a83826f8b2368df24d5fb0fdb033401a1e670bb67ba686c171fdfeeb4203a87223de46c899a9ea7a706a249043', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
100
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
101
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:49:27', "perishable_token" = 'Rui7XLyC1M8Vm0zlkAku', "last_request_at" = '2011-01-05 02:49:27', "lock_version" = 1, "current_login_at" = '2011-01-05 02:49:27'
|
102
|
+
WHERE id = 2
|
103
|
+
AND "lock_version" = 0
|
104
|
+
[0m
|
105
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:49:27', NULL, NULL, NULL, 't', '2011-01-05 02:49:27', 'kTXskzxx7WsMS61XcW6D', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
106
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
107
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:49:27', "perishable_token" = 'lwlqmU2qDSSOjGqNTd5a', "last_request_at" = '2011-01-05 02:49:27', "lock_version" = 1, "current_login_at" = '2011-01-05 02:49:27'
|
108
|
+
WHERE id = 3
|
109
|
+
AND "lock_version" = 0
|
110
|
+
[0m
|
111
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:49:27', NULL, NULL, NULL, 't', '2011-01-05 02:49:27', 'Lz2QOBzhZOXHtHdjL9bs', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
112
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
113
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:49:27', "perishable_token" = 'AV6UlHvtzrat83rWOY3Y', "last_request_at" = '2011-01-05 02:49:27', "lock_version" = 1, "current_login_at" = '2011-01-05 02:49:27'
|
114
|
+
WHERE id = 4
|
115
|
+
AND "lock_version" = 0
|
116
|
+
[0m
|
117
|
+
[4;36;1mSQL (0.3ms)[0m [0;1m SELECT name
|
118
|
+
FROM sqlite_master
|
119
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
120
|
+
[0m
|
121
|
+
[4;35;1mSQL (0.1ms)[0m [0mselect sqlite_version(*)[0m
|
122
|
+
[4;36;1mSQL (0.2ms)[0m [0;1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
123
|
+
[4;35;1mSQL (0.1ms)[0m [0mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
124
|
+
[4;36;1mSQL (0.1ms)[0m [0;1m SELECT name
|
125
|
+
FROM sqlite_master
|
126
|
+
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
127
|
+
[0m
|
128
|
+
[4;35;1mSQL (0.1ms)[0m [0mSELECT version FROM schema_migrations[0m
|
129
|
+
Migrating to CreateUsers (20101217000008)
|
130
|
+
[4;36;1mSQL (0.4ms)[0m [0;1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "lock_version" integer DEFAULT 0, "company_id" integer, "login" varchar(255), "crypted_password" varchar(255), "password_salt" varchar(255), "persistence_token" varchar(255), "single_access_token" varchar(255), "perishable_token" varchar(255), "email" varchar(255), "first_name" varchar(255), "last_name" varchar(255), "login_count" integer DEFAULT 0 NOT NULL, "failed_login_count" integer DEFAULT 0 NOT NULL, "last_request_at" datetime, "current_login_at" datetime, "last_login_at" datetime, "current_login_ip" varchar(255), "last_login_ip" varchar(255), "active" boolean DEFAULT 't', "approved" boolean DEFAULT 't', "confirmed" boolean DEFAULT 't', "facebook_uid" varchar(255)) [0m
|
131
|
+
[4;35;1mSQL (0.1ms)[0m [0mINSERT INTO schema_migrations (version) VALUES ('20101217000008')[0m
|
132
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = 'fcb5d9b05abae3defaf0a0d573341370376b1b5b34114634ab148b2db6477b86f32c092d289c4d76359ea0e9052374659a0bfeb59c656e9558c75c89ad634850') LIMIT 1[0m
|
133
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'Jk4t2D8xIVzr-drf1g9D') LIMIT 1[0m
|
134
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:56:52', 'Jk4t2D8xIVzr-drf1g9D', NULL, NULL, 't', '2011-01-05 02:56:52', 'YEqFCrp4ZlmtuDyIBoa2', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, 'fcb5d9b05abae3defaf0a0d573341370376b1b5b34114634ab148b2db6477b86f32c092d289c4d76359ea0e9052374659a0bfeb59c656e9558c75c89ad634850', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
135
|
+
[4;35;1mUser Update with optimistic locking (0.2ms)[0m [0m UPDATE "users"
|
136
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:56:52', "perishable_token" = 'viIYjwY-It_i3eudsN2D', "last_request_at" = '2011-01-05 02:56:52', "lock_version" = 1, "current_login_at" = '2011-01-05 02:56:52'
|
137
|
+
WHERE id = 1
|
138
|
+
AND "lock_version" = 0
|
139
|
+
[0m
|
140
|
+
[4;36;1mUser Load (0.1ms)[0m [0;1mSELECT "users".id FROM "users" WHERE ("users"."persistence_token" = 'fd0682ff46cc5f1d729924b839c32a0f94454562bc15b4cec105c48908eeca8673c70cb6449efc916b0eedb51c155714a9d1b0ed00ccd1cae1219565ee810fd3') LIMIT 1[0m
|
141
|
+
[4;35;1mUser Load (0.1ms)[0m [0mSELECT "users".id FROM "users" WHERE ("users"."single_access_token" = 'J6zUBKnQNklM79gLDds5') LIMIT 1[0m
|
142
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:56:52', 'J6zUBKnQNklM79gLDds5', NULL, NULL, 't', '2011-01-05 02:56:52', 'lQ5EWLf3AvmiNZuCWmF3', NULL, 0, 0, NULL, 't', NULL, NULL, NULL, 'fd0682ff46cc5f1d729924b839c32a0f94454562bc15b4cec105c48908eeca8673c70cb6449efc916b0eedb51c155714a9d1b0ed00ccd1cae1219565ee810fd3', NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
143
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
144
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:56:52', "perishable_token" = '4xCFZCZTyEJkuncNmwe2', "last_request_at" = '2011-01-05 02:56:52', "lock_version" = 1, "current_login_at" = '2011-01-05 02:56:52'
|
145
|
+
WHERE id = 2
|
146
|
+
AND "lock_version" = 0
|
147
|
+
[0m
|
148
|
+
[4;36;1mUser Create (0.2ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:56:53', NULL, NULL, NULL, 't', '2011-01-05 02:56:53', 'QPUSDFsbQNvlzmiKsMdQ', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
149
|
+
[4;35;1mUser Update with optimistic locking (0.2ms)[0m [0m UPDATE "users"
|
150
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:56:53', "perishable_token" = 'zM5_WranpRa5tV_xGpOn', "last_request_at" = '2011-01-05 02:56:53', "lock_version" = 1, "current_login_at" = '2011-01-05 02:56:53'
|
151
|
+
WHERE id = 3
|
152
|
+
AND "lock_version" = 0
|
153
|
+
[0m
|
154
|
+
[4;36;1mUser Create (0.1ms)[0m [0;1mINSERT INTO "users" ("created_at", "single_access_token", "last_request_at", "crypted_password", "confirmed", "updated_at", "perishable_token", "facebook_uid", "lock_version", "failed_login_count", "current_login_ip", "approved", "password_salt", "current_login_at", "company_id", "persistence_token", "last_name", "login_count", "last_login_ip", "login", "last_login_at", "email", "first_name", "active") VALUES('2011-01-05 02:56:53', NULL, NULL, NULL, 't', '2011-01-05 02:56:53', 'c342yHUJlfrSqwKLL_I8', 'mockuid', 0, 0, NULL, 't', NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 't')[0m
|
155
|
+
[4;35;1mUser Update with optimistic locking (0.1ms)[0m [0m UPDATE "users"
|
156
|
+
SET "login_count" = 1, "current_login_ip" = '1.1.1.1', "updated_at" = '2011-01-05 02:56:53', "perishable_token" = 'R35njl1Msiul4-GbHuQD', "last_request_at" = '2011-01-05 02:56:53', "lock_version" = 1, "current_login_at" = '2011-01-05 02:56:53'
|
157
|
+
WHERE id = 4
|
158
|
+
AND "lock_version" = 0
|
159
|
+
[0m
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Load the environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
rails_root = File.dirname(__FILE__) + '/rails_root'
|
4
|
+
require "#{rails_root}/config/environment.rb"
|
5
|
+
|
6
|
+
# Load the testing framework
|
7
|
+
require 'test_help'
|
8
|
+
require 'flexmock/test_unit'
|
9
|
+
require "authlogic/test_case"
|
10
|
+
|
11
|
+
silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
|
12
|
+
|
13
|
+
# Run the migrations
|
14
|
+
ActiveRecord::Migration.verbose = false
|
15
|
+
ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
|
16
|
+
|
17
|
+
# Setup the fixtures path
|
18
|
+
|
19
|
+
class ActiveSupport::TestCase #:nodoc:
|
20
|
+
self.fixture_path = File.join(File.dirname(__FILE__), "fixtures")
|
21
|
+
self.use_transactional_fixtures = false
|
22
|
+
self.use_instantiated_fixtures = false
|
23
|
+
self.pre_loaded_fixtures = false
|
24
|
+
|
25
|
+
fixtures :all
|
26
|
+
setup :activate_authlogic
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# --- Sample valid cookie hash generated with the code below
|
31
|
+
# cookie_hash = {'fbs_233423200151' => 'access_token=233423200151|6892d62675cd952ade8b3f9b-6184456410|xrNaOlTCUF0QFZrJCHmVWzTb5Mk.&expires=0&secret=339a00cdafe6959c3caa1b8004e5f8db&session_key=6892d62675cd952ade8b3f9b-6184456410&sig=19d3c9ccb5b5a55d680ed1cf18698f57&uid=6184456410'}
|
32
|
+
|
33
|
+
# --- Generates user params from cookie for this app_id & secret
|
34
|
+
# oauth = Koala::Facebook::OAuth.new('233423200151', '8371c9fc95a7d0a3d9cdb6bbacfea306')
|
35
|
+
# params = oauth.get_user_from_cookie(cookie_hash)
|
36
|
+
|
37
|
+
# --- Generates a signature for a cookie hash
|
38
|
+
# fb_cookie = cookie_hash["fbs_233423200151"]
|
39
|
+
# components = {}
|
40
|
+
# fb_cookie.split("&").map {|param| param = param.split("="); components[param[0]] = param[1]}
|
41
|
+
# auth_string = components.keys.sort.collect {|a| a == "sig" ? nil : "#{a}=#{components[a]}"}.reject {|a| a.nil?}.join("")
|
42
|
+
# sig = Digest::MD5.hexdigest(auth_string + '8371c9fc95a7d0a3d9cdb6bbacfea306')
|
43
|
+
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require File.expand_path( '../../test_helper.rb', File.dirname(__FILE__) )
|
2
|
+
|
3
|
+
class AuthlogicFacebookShim::Session::AdapterTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup :activate_authlogic
|
6
|
+
|
7
|
+
context "Session::Adapter" do
|
8
|
+
setup do
|
9
|
+
@user_info = {
|
10
|
+
'session_key' => 'mocksessionkey',
|
11
|
+
'expires' => '0',
|
12
|
+
'uid' => 'mockuid',
|
13
|
+
'sig' => 'cbd80b97f124bf392f76e2ee61168990',
|
14
|
+
'secret' => 'mocksecret',
|
15
|
+
'access_token' => 'mockaccesstoken'
|
16
|
+
}
|
17
|
+
@mock_cookies = MockCookieJar.new
|
18
|
+
@mock_cookies['fbs_mockappid'] = {:value => 'access_token=mockaccesstoken&expires=0&secret=mocksecret&session_key=mocksessionkey&sig=cbd80b97f124bf392f76e2ee61168990&uid=mockuid'}
|
19
|
+
@session = flexmock(UserSession.new)
|
20
|
+
@controller = flexmock('Controller')
|
21
|
+
|
22
|
+
@session.should_receive(:facebook_app_id).and_return('mockappid').by_default
|
23
|
+
@session.should_receive(:facebook_api_key).and_return('mockapikey').by_default
|
24
|
+
@session.should_receive(:facebook_secret_key).and_return('mocksecret').by_default
|
25
|
+
@session.should_receive(:controller).and_return(@controller).by_default
|
26
|
+
@controller.should_receive(:cookies).and_return(@mock_cookies).by_default
|
27
|
+
end
|
28
|
+
|
29
|
+
context "setup - for my own sanity" do
|
30
|
+
|
31
|
+
should "set the controller" do
|
32
|
+
assert_equal @controller, @session.controller
|
33
|
+
end
|
34
|
+
|
35
|
+
should "set the cookies" do
|
36
|
+
assert_equal @mock_cookies, @session.controller.cookies
|
37
|
+
end
|
38
|
+
|
39
|
+
should "set the facebook_app_id" do
|
40
|
+
assert_equal 'mockappid', @session.facebook_app_id
|
41
|
+
end
|
42
|
+
|
43
|
+
should "set the facebook_secret_key" do
|
44
|
+
assert_equal 'mocksecret', @session.facebook_secret_key
|
45
|
+
end
|
46
|
+
|
47
|
+
should "set the facebook_api_key" do
|
48
|
+
assert_equal 'mockapikey', @session.facebook_api_key
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
context "facebook_session" do
|
54
|
+
|
55
|
+
context "with a valid facebook cookie" do
|
56
|
+
|
57
|
+
context "and koala support for get_user_info_from_cookie" do
|
58
|
+
|
59
|
+
should "return a session_key" do
|
60
|
+
assert_equal 'mocksessionkey', @session.facebook_session.session_key
|
61
|
+
end
|
62
|
+
|
63
|
+
should "return a uid" do
|
64
|
+
assert_equal 'mockuid', @session.facebook_session.uid
|
65
|
+
end
|
66
|
+
|
67
|
+
should "return a secret" do
|
68
|
+
assert_equal 'mocksecret', @session.facebook_session.secret
|
69
|
+
end
|
70
|
+
|
71
|
+
should "return a sig" do
|
72
|
+
assert_equal 'cbd80b97f124bf392f76e2ee61168990', @session.facebook_session.sig
|
73
|
+
end
|
74
|
+
|
75
|
+
should "return an access_token" do
|
76
|
+
assert_equal 'mockaccesstoken', @session.facebook_session.access_token
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
context "with previous koala api" do
|
82
|
+
|
83
|
+
should "get user info with the get_user_from_cookie method" do
|
84
|
+
@oauth = flexmock('oauth')
|
85
|
+
flexmock(Koala::Facebook::OAuth).should_receive(:new).and_return(@oauth).once
|
86
|
+
@oauth.should_receive(:respond_to?).with(:get_user_info_from_cookie).and_return(false).once
|
87
|
+
@oauth.should_receive(:get_user_from_cookie).with(@mock_cookies).and_return(@user_info).once
|
88
|
+
|
89
|
+
assert_equal 'mocksessionkey', @session.facebook_session.session_key
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
context "with no valid facebook cookie" do
|
97
|
+
|
98
|
+
should "return nil" do
|
99
|
+
@session.should_receive('facebook_app_id').and_return(nil).once
|
100
|
+
assert_nil @session.facebook_session
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
context "facebook_session?" do
|
108
|
+
|
109
|
+
context "with a valid facebook session" do
|
110
|
+
|
111
|
+
should "be true" do
|
112
|
+
assert @session.facebook_session?
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context "without a valid facebook session" do
|
118
|
+
|
119
|
+
should "return nil" do
|
120
|
+
@session.should_receive('facebook_app_id').and_return(nil).once
|
121
|
+
assert_equal false, @session.facebook_session?
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
context "facebook_user" do
|
129
|
+
|
130
|
+
context "with a valid facebook session" do
|
131
|
+
|
132
|
+
setup do
|
133
|
+
@user = {
|
134
|
+
"id" => "mockid",
|
135
|
+
"name" => "Full name",
|
136
|
+
"first_name" => "First name",
|
137
|
+
"last_name" => "Last name"
|
138
|
+
}
|
139
|
+
|
140
|
+
@access_token = flexmock('access token')
|
141
|
+
@session.should_receive('facebook_session.access_token').and_return(@access_token).by_default
|
142
|
+
@session.should_receive('facebook_session?').and_return(true).by_default
|
143
|
+
|
144
|
+
@graph_api = flexmock('graph api', :get_object => @user)
|
145
|
+
flexmock(Koala::Facebook::GraphAPI).should_receive(:new).and_return(@graph_api).by_default
|
146
|
+
end
|
147
|
+
|
148
|
+
should "initialize the graph api" do
|
149
|
+
flexmock(Koala::Facebook::GraphAPI).should_receive(:new).with(@access_token).and_return(@graph_api).once
|
150
|
+
@session.facebook_user
|
151
|
+
end
|
152
|
+
|
153
|
+
should "return an OpenStruct" do
|
154
|
+
assert @session.facebook_user.is_a?(OpenStruct)
|
155
|
+
end
|
156
|
+
|
157
|
+
should "return the user details" do
|
158
|
+
assert_equal 'Full name', @session.facebook_user.name
|
159
|
+
assert_equal 'First name', @session.facebook_user.first_name
|
160
|
+
assert_equal 'Last name', @session.facebook_user.last_name
|
161
|
+
end
|
162
|
+
|
163
|
+
should "return the facebook id as uid" do
|
164
|
+
assert_equal 'mockid', @session.facebook_user.uid
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
context "with no valid facebook session" do
|
170
|
+
|
171
|
+
should "return nil" do
|
172
|
+
@session.should_receive('facebook_session?').and_return(false).once
|
173
|
+
assert_nil @session.facebook_user
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|