omniauth-facebook-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +43 -0
  3. data/Rakefile +32 -0
  4. data/app/controllers/sessions_controller.rb +24 -0
  5. data/app/models/user.rb +8 -0
  6. data/config/routes.rb +5 -0
  7. data/db/migrate/20121204171957_add_facebook_omniauth_fields.rb +38 -0
  8. data/lib/omniauth-facebook-rails.rb +8 -0
  9. data/lib/omniauth-facebook-rails/engine.rb +14 -0
  10. data/lib/omniauth-facebook-rails/version.rb +3 -0
  11. data/lib/tasks/omniauth-facebook-rails_tasks.rake +10 -0
  12. data/spec/controllers/sessions_controller_spec.rb +83 -0
  13. data/spec/dummy/README.rdoc +261 -0
  14. data/spec/dummy/Rakefile +7 -0
  15. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  16. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  17. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  18. data/spec/dummy/app/controllers/home_controller.rb +5 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/spec/dummy/config.ru +4 -0
  22. data/spec/dummy/config/application.rb +59 -0
  23. data/spec/dummy/config/boot.rb +10 -0
  24. data/spec/dummy/config/database.yml +25 -0
  25. data/spec/dummy/config/environment.rb +5 -0
  26. data/spec/dummy/config/environments/development.rb +37 -0
  27. data/spec/dummy/config/environments/production.rb +67 -0
  28. data/spec/dummy/config/environments/test.rb +37 -0
  29. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/spec/dummy/config/initializers/inflections.rb +15 -0
  31. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  32. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  33. data/spec/dummy/config/initializers/session_store.rb +8 -0
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/spec/dummy/config/locales/en.yml +5 -0
  36. data/spec/dummy/config/routes.rb +59 -0
  37. data/spec/dummy/db/development.sqlite3 +0 -0
  38. data/spec/dummy/db/schema.rb +30 -0
  39. data/spec/dummy/db/test.sqlite3 +0 -0
  40. data/spec/dummy/log/development.log +39 -0
  41. data/spec/dummy/log/test.log +1451 -0
  42. data/spec/dummy/public/404.html +26 -0
  43. data/spec/dummy/public/422.html +26 -0
  44. data/spec/dummy/public/500.html +25 -0
  45. data/spec/dummy/public/favicon.ico +0 -0
  46. data/spec/dummy/script/rails +6 -0
  47. data/spec/factories.rb +3 -0
  48. data/spec/models/user_spec.rb +52 -0
  49. data/spec/routing/sessions_routing_spec.rb +19 -0
  50. data/spec/spec_helper.rb +39 -0
  51. metadata +220 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
data/spec/factories.rb ADDED
@@ -0,0 +1,3 @@
1
+ FactoryGirl.define do
2
+ factory :user
3
+ end
@@ -0,0 +1,52 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe User do
5
+ describe ".find_or_create_with_omniauth" do
6
+ let(:auth) { {"provider"=>"facebook", "uid"=>"123456", "credentials"=>{"token"=>"AAADv"}, "info"=>{"nickname"=>"sylvestre.mergulhao", "email"=>"mergulhao83@gmail.com", "first_name"=>"Sylvestre", "last_name"=>"Mergulhão", "name"=>"Sylvestre Mergulhão", "image"=>"http://graph.facebook.com/526830634/picture?type=square", "urls"=>{"Facebook"=>"http://www.facebook.com/sylvestre.mergulhao", "Website"=>nil}}, "extra"=>{"raw_info"=>{"id"=>"526830634", "name"=>"Sylvestre Mergulhão", "first_name"=>"Sylvestre", "last_name"=>"Mergulhão", "link"=>"http://www.facebook.com/sylvestre.mergulhao", "username"=>"sylvestre.mergulhao", "location"=>{"id"=>"110346955653479", "name"=>"Rio de Janeiro, Rio de Janeiro"}, "education"=>[{"school"=>{"id"=>"115555431792035", "name"=>"UniRio"}, "type"=>"College", "with"=>[{"id"=>"100001030509286", "name"=>"João Aguirre"}, {"id"=>"512001183", "name"=>"Marcos Brando Margulies"}, {"id"=>"100001650369677", "name"=>"Paulo Guilherme Ribeiro"}, {"id"=>"678564390", "name"=>"Duim Knurf"}]}, {"school"=>{"id"=>"109896575694939", "name"=>"Universidade Federal do Estado do Rio de Janeiro"}, "type"=>"College", "with"=>[{"id"=>"100000517388839", "name"=>"João Filho"}]}], "gender"=>"male", "email"=>"mergulhao83@gmail.com", "timezone"=>-2, "locale"=>"pt_BR", "verified"=>true, "updated_time"=>"2011-07-19T00:05:20+0000"}}} }
7
+ context "user doesnt exists" do
8
+ describe "creating a new user" do
9
+ it "should create" do
10
+ expect {
11
+ User.find_or_create_with_omniauth(auth)
12
+ }.to change(User, :count).by(1)
13
+ end
14
+ end
15
+ describe "setting data on new user" do
16
+ subject { User.find_or_create_with_omniauth(auth) }
17
+ it { subject.provider.should == "facebook" }
18
+ it { subject.uid.should == "123456" }
19
+ it { subject.name.should == "Sylvestre Mergulhão" }
20
+ it { subject.email.should == "mergulhao83@gmail.com" }
21
+ it { subject.access_token.should == "AAADv" }
22
+ it { subject.photo_url.should == "http://graph.facebook.com/526830634/picture?type=square" }
23
+ it { subject.extra.should_not be_nil }
24
+ end
25
+ end
26
+ context "user already exists" do
27
+ let!(:existing_user) { FactoryGirl.create(:user, :name => "My old name", :email => "my@old.me", :provider => "facebook", :uid => "123456")}
28
+ describe "finding existing user" do
29
+ it "should find" do
30
+ User.find_or_create_with_omniauth(auth).should == existing_user
31
+ end
32
+ it "should not create" do
33
+ expect {
34
+ User.find_or_create_with_omniauth(auth)
35
+ }.to_not change(User, :count)
36
+ end
37
+ end
38
+ describe "updating existing user" do
39
+ before do
40
+ User.find_or_create_with_omniauth(auth)
41
+ end
42
+ subject { existing_user.reload }
43
+ it { subject.provider.should == "facebook" }
44
+ it { subject.uid.should == "123456" }
45
+ it { subject.name.should == "Sylvestre Mergulhão" }
46
+ it { subject.email.should == "mergulhao83@gmail.com" }
47
+ it { subject.access_token.should == "AAADv" }
48
+ it { subject.photo_url.should == "http://graph.facebook.com/526830634/picture?type=square" }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require "spec_helper"
3
+
4
+ describe SessionsController do
5
+ describe "routing" do
6
+ it "route facebook callback" do
7
+ get("/auth/facebook/callback").should route_to("sessions#create", :provider => "facebook")
8
+ auth_callback_path("facebook").should == "/auth/facebook/callback"
9
+ end
10
+ it "route auth failure" do
11
+ get("/auth/failure").should route_to("sessions#failure")
12
+ auth_failure_path.should == "/auth/failure"
13
+ end
14
+ it "route facebook callback" do
15
+ get("/logout").should route_to("sessions#destroy")
16
+ logout_path.should == "/logout"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
10
+ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ # ## Mock Framework
14
+ #
15
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
16
+ #
17
+ # config.mock_with :mocha
18
+ # config.mock_with :flexmock
19
+ # config.mock_with :rr
20
+
21
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
22
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
23
+
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, remove the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+
29
+ # If true, the base class of anonymous controllers will be inferred
30
+ # automatically. This will be the default behavior in future versions of
31
+ # rspec-rails.
32
+ config.infer_base_class_for_anonymous_controllers = false
33
+
34
+ # Run specs in random order to surface order dependencies. If you find an
35
+ # order dependency and want to debug it, you can fix the order by providing
36
+ # the seed, which is printed after each run.
37
+ # --seed 1234
38
+ config.order = "random"
39
+ end
metadata ADDED
@@ -0,0 +1,220 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-facebook-rails
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Pedro Nascimento
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ none: false
21
+ prerelease: false
22
+ name: rails
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 3.2.0
28
+ none: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 1.4.1
36
+ none: false
37
+ prerelease: false
38
+ name: omniauth-facebook
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.4.1
44
+ none: false
45
+ type: :runtime
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ none: false
53
+ prerelease: false
54
+ name: sqlite3
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ none: false
61
+ type: :development
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ none: false
69
+ prerelease: false
70
+ name: rspec-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ none: false
77
+ type: :development
78
+ - !ruby/object:Gem::Dependency
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ none: false
85
+ prerelease: false
86
+ name: factory_girl_rails
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ none: false
93
+ type: :development
94
+ description: Integrate your app with Facebook.
95
+ email:
96
+ - pedro@helabs.com.br
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - app/controllers/sessions_controller.rb
102
+ - app/models/user.rb
103
+ - config/routes.rb
104
+ - db/migrate/20121204171957_add_facebook_omniauth_fields.rb
105
+ - lib/omniauth-facebook-rails/engine.rb
106
+ - lib/omniauth-facebook-rails/version.rb
107
+ - lib/omniauth-facebook-rails.rb
108
+ - lib/tasks/omniauth-facebook-rails_tasks.rake
109
+ - MIT-LICENSE
110
+ - Rakefile
111
+ - README.md
112
+ - spec/controllers/sessions_controller_spec.rb
113
+ - spec/dummy/app/assets/javascripts/application.js
114
+ - spec/dummy/app/assets/stylesheets/application.css
115
+ - spec/dummy/app/controllers/application_controller.rb
116
+ - spec/dummy/app/controllers/home_controller.rb
117
+ - spec/dummy/app/helpers/application_helper.rb
118
+ - spec/dummy/app/views/layouts/application.html.erb
119
+ - spec/dummy/config/application.rb
120
+ - spec/dummy/config/boot.rb
121
+ - spec/dummy/config/database.yml
122
+ - spec/dummy/config/environment.rb
123
+ - spec/dummy/config/environments/development.rb
124
+ - spec/dummy/config/environments/production.rb
125
+ - spec/dummy/config/environments/test.rb
126
+ - spec/dummy/config/initializers/backtrace_silencers.rb
127
+ - spec/dummy/config/initializers/inflections.rb
128
+ - spec/dummy/config/initializers/mime_types.rb
129
+ - spec/dummy/config/initializers/secret_token.rb
130
+ - spec/dummy/config/initializers/session_store.rb
131
+ - spec/dummy/config/initializers/wrap_parameters.rb
132
+ - spec/dummy/config/locales/en.yml
133
+ - spec/dummy/config/routes.rb
134
+ - spec/dummy/config.ru
135
+ - spec/dummy/db/development.sqlite3
136
+ - spec/dummy/db/schema.rb
137
+ - spec/dummy/db/test.sqlite3
138
+ - spec/dummy/log/development.log
139
+ - spec/dummy/log/test.log
140
+ - spec/dummy/public/404.html
141
+ - spec/dummy/public/422.html
142
+ - spec/dummy/public/500.html
143
+ - spec/dummy/public/favicon.ico
144
+ - spec/dummy/Rakefile
145
+ - spec/dummy/README.rdoc
146
+ - spec/dummy/script/rails
147
+ - spec/factories.rb
148
+ - spec/models/user_spec.rb
149
+ - spec/routing/sessions_routing_spec.rb
150
+ - spec/spec_helper.rb
151
+ homepage: http://helabs.com.br/opensource
152
+ licenses: []
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ segments:
163
+ - 0
164
+ hash: -490056415748890864
165
+ none: false
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ! '>='
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ segments:
172
+ - 0
173
+ hash: -490056415748890864
174
+ none: false
175
+ requirements: []
176
+ rubyforge_project:
177
+ rubygems_version: 1.8.24
178
+ signing_key:
179
+ specification_version: 3
180
+ summary: Integrate your app with Facebook.
181
+ test_files:
182
+ - spec/controllers/sessions_controller_spec.rb
183
+ - spec/dummy/app/assets/javascripts/application.js
184
+ - spec/dummy/app/assets/stylesheets/application.css
185
+ - spec/dummy/app/controllers/application_controller.rb
186
+ - spec/dummy/app/controllers/home_controller.rb
187
+ - spec/dummy/app/helpers/application_helper.rb
188
+ - spec/dummy/app/views/layouts/application.html.erb
189
+ - spec/dummy/config/application.rb
190
+ - spec/dummy/config/boot.rb
191
+ - spec/dummy/config/database.yml
192
+ - spec/dummy/config/environment.rb
193
+ - spec/dummy/config/environments/development.rb
194
+ - spec/dummy/config/environments/production.rb
195
+ - spec/dummy/config/environments/test.rb
196
+ - spec/dummy/config/initializers/backtrace_silencers.rb
197
+ - spec/dummy/config/initializers/inflections.rb
198
+ - spec/dummy/config/initializers/mime_types.rb
199
+ - spec/dummy/config/initializers/secret_token.rb
200
+ - spec/dummy/config/initializers/session_store.rb
201
+ - spec/dummy/config/initializers/wrap_parameters.rb
202
+ - spec/dummy/config/locales/en.yml
203
+ - spec/dummy/config/routes.rb
204
+ - spec/dummy/config.ru
205
+ - spec/dummy/db/development.sqlite3
206
+ - spec/dummy/db/schema.rb
207
+ - spec/dummy/db/test.sqlite3
208
+ - spec/dummy/log/development.log
209
+ - spec/dummy/log/test.log
210
+ - spec/dummy/public/404.html
211
+ - spec/dummy/public/422.html
212
+ - spec/dummy/public/500.html
213
+ - spec/dummy/public/favicon.ico
214
+ - spec/dummy/Rakefile
215
+ - spec/dummy/README.rdoc
216
+ - spec/dummy/script/rails
217
+ - spec/factories.rb
218
+ - spec/models/user_spec.rb
219
+ - spec/routing/sessions_routing_spec.rb
220
+ - spec/spec_helper.rb