socialite 0.0.1.beta4 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +33 -34
- data/Rakefile +8 -21
- data/app/controllers/socialite/application_controller.rb +4 -0
- data/app/controllers/socialite/identities_controller.rb +2 -14
- data/app/controllers/socialite/session_controller.rb +20 -0
- data/app/controllers/socialite/users_controller.rb +0 -1
- data/app/views/layouts/socialite/application.html.haml +11 -0
- data/app/views/socialite/identities/new.html.haml +27 -0
- data/app/views/socialite/session/new.html.haml +31 -14
- data/app/views/socialite/user/edit.html.haml +1 -1
- data/config/routes.rb +7 -7
- data/lib/generators/socialite/install_generator.rb +7 -9
- data/lib/generators/socialite/migrations_generator.rb +34 -0
- data/lib/generators/socialite/templates/identity.rb.erb +25 -0
- data/lib/generators/socialite/templates/socialite.rb +20 -7
- data/lib/generators/socialite/templates/users.rb.erb +12 -0
- data/lib/socialite.rb +25 -27
- data/lib/socialite/controllers/helpers.rb +107 -111
- data/lib/socialite/engine.rb +19 -32
- data/lib/socialite/helpers/authentication.rb +1 -1
- data/lib/socialite/models/identity_concern.rb +91 -0
- data/lib/socialite/models/user_concern.rb +54 -0
- data/lib/socialite/version.rb +1 -1
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -3
- data/spec/dummy/app/assets/stylesheets/application.css +11 -5
- data/{app/assets/images/socialite → spec/dummy/app/mailers}/.gitkeep +0 -0
- data/{app/assets/javascripts/socialite → spec/dummy/app/models}/.gitkeep +0 -0
- data/spec/dummy/app/models/identity.rb +4 -0
- data/spec/dummy/app/models/user.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -5
- data/spec/dummy/config/application.rb +19 -2
- data/spec/dummy/config/boot.rb +1 -11
- data/spec/dummy/config/database.yml +18 -2
- data/spec/dummy/config/environments/development.rb +8 -1
- data/spec/dummy/config/environments/production.rb +9 -2
- data/spec/dummy/config/environments/test.rb +4 -9
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/socialite.rb +26 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/routes.rb +2 -10
- data/{db/migrate/20110914215410_create_users.rb → spec/dummy/db/migrate/20130206224516_create_socialite_users.rb} +2 -4
- data/spec/dummy/db/migrate/20130206224517_create_socialite_identities.rb +25 -0
- data/spec/dummy/db/schema.rb +12 -20
- data/{lib/tasks → spec/dummy/lib/assets}/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/500.html +0 -1
- data/spec/factories/facebook.rb +5 -5
- data/spec/factories/identity.rb +3 -3
- data/spec/factories/user.rb +10 -12
- data/spec/generators/socialite/install_generator_spec.rb +43 -0
- data/spec/generators/socialite/migrations_generator_spec.rb +27 -0
- data/spec/models/facebook_spec.rb +24 -21
- data/spec/models/identity_spec.rb +2 -2
- data/spec/models/user_spec.rb +7 -7
- data/spec/socialite_spec.rb +53 -0
- data/spec/spec_helper.rb +23 -10
- data/spec/support/identity_shared_example.rb +24 -20
- metadata +202 -144
- data/.autotest +0 -7
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -10
- data/.yardopts +0 -8
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -208
- data/app/models/socialite/facebook_identity.rb +0 -5
- data/app/models/socialite/identity.rb +0 -5
- data/app/models/socialite/user.rb +0 -10
- data/config/initializers/simple_form.rb +0 -90
- data/config/locales/simple_form.en.yml +0 -23
- data/db/migrate/20110925224222_create_identities.rb +0 -26
- data/db/migrate/20110926005551_create_facebook_identities.rb +0 -12
- data/lib/socialite/api_wrappers/facebook.rb +0 -67
- data/lib/socialite/api_wrappers/twitter.rb +0 -19
- data/lib/socialite/models/identity.rb +0 -99
- data/lib/socialite/models/user.rb +0 -50
- data/lib/socialite/service_config.rb +0 -14
- data/lib/tasks/cucumber.rake +0 -65
- data/script/cucumber +0 -10
- data/script/rails +0 -6
- data/socialite.gemspec +0 -39
- data/spec/dummy/app/controllers/home_controller.rb +0 -11
- data/spec/dummy/app/views/home/index.html.haml +0 -12
- data/spec/dummy/app/views/home/show.html.haml +0 -6
@@ -20,7 +20,7 @@ Dummy::Application.configure do
|
|
20
20
|
# Generate digests for assets URLs
|
21
21
|
config.assets.digest = true
|
22
22
|
|
23
|
-
# Defaults to
|
23
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
24
24
|
# config.assets.manifest = YOUR_PATH
|
25
25
|
|
26
26
|
# Specifies the header that your server uses for sending files
|
@@ -33,8 +33,11 @@ Dummy::Application.configure do
|
|
33
33
|
# See everything in the log (default is :info)
|
34
34
|
# config.log_level = :debug
|
35
35
|
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
36
39
|
# Use a different logger for distributed setups
|
37
|
-
# config.logger = SyslogLogger.new
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
38
41
|
|
39
42
|
# Use a different cache store in production
|
40
43
|
# config.cache_store = :mem_cache_store
|
@@ -57,4 +60,8 @@ Dummy::Application.configure do
|
|
57
60
|
|
58
61
|
# Send deprecation notices to registered listeners
|
59
62
|
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Log the query plan for queries taking more than this (works
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
60
67
|
end
|
@@ -2,9 +2,9 @@ Dummy::Application.configure do
|
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
5
|
-
# test suite.
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
6
|
# your test database is "scratch space" for the test suite and is wiped
|
7
|
-
# and recreated between test runs.
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
@@ -29,14 +29,9 @@ Dummy::Application.configure do
|
|
29
29
|
# ActionMailer::Base.deliveries array.
|
30
30
|
config.action_mailer.delivery_method = :test
|
31
31
|
|
32
|
-
#
|
33
|
-
|
34
|
-
# like if you have constraints or database-specific column types
|
35
|
-
# config.active_record.schema_format = :sql
|
32
|
+
# Raise exception on mass assignment protection for Active Record models
|
33
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
36
34
|
|
37
35
|
# Print deprecation notices to the stderr
|
38
36
|
config.active_support.deprecation = :stderr
|
39
|
-
|
40
|
-
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
41
|
-
config.assets.allow_debugging = true
|
42
37
|
end
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
Dummy::Application.config.secret_token = '
|
7
|
+
Dummy::Application.config.secret_token = 'dd75c273d85209af29b6c0cc7ddb7ef057221d5643dd1d67636895a9fb94c5191e6c79382b6afa34b0336feaf7e30d7598551fae7349d80c6c5279b5910b8f5d'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
Dummy::Application.config.session_store :cookie_store, :
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
4
|
|
5
5
|
# Use the database for sessions instead of the cookie-based default,
|
6
6
|
# which shouldn't be used to store highly confidential information
|
@@ -1,6 +1,28 @@
|
|
1
|
-
require 'socialite'
|
2
|
-
|
3
1
|
Socialite.setup do |config|
|
4
|
-
|
5
|
-
|
2
|
+
## Configure Classes
|
3
|
+
# If you are not using the default names set below. Please change them to
|
4
|
+
# reflect the correct classes.
|
5
|
+
#
|
6
|
+
# **NOTE** These _should_ be set to string values to prevent any possible
|
7
|
+
# errors caused by load order.
|
8
|
+
config.user_class = 'User'
|
9
|
+
config.identity_class = 'Identity'
|
10
|
+
|
11
|
+
## Add any supported OmniAuth providers
|
12
|
+
# You can pass any providers that are supported by OmniAuth simply by
|
13
|
+
# including it in your Gemfile.
|
14
|
+
#
|
15
|
+
# Examples:
|
16
|
+
# config.provider :facebook, ENV['FACEBOOK_APP_KEY'], ENV['FACEBOOK_SECRET'],
|
17
|
+
# :scope => 'email,friends'
|
18
|
+
# config.provider :identity, :on_failed_registration => lambda { |env|
|
19
|
+
# UsersController.action(:new).call(env)
|
20
|
+
# }
|
21
|
+
# config.provider :twitter, ENV['TWITTER_APP_KEY'], ENV['TWITTER_SECRET']
|
22
|
+
|
23
|
+
if Rails.env.production?
|
24
|
+
# Any production specific information
|
25
|
+
elsif Rails.env.development?
|
26
|
+
# Configs for development mode go here
|
27
|
+
end
|
6
28
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
7
|
ActiveSupport.on_load(:action_controller) do
|
8
|
-
wrap_parameters :
|
8
|
+
wrap_parameters format: [:json]
|
9
9
|
end
|
10
10
|
|
11
11
|
# Disable root element in JSON by default.
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,11 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Dummy::Application.routes.draw do
|
4
|
-
mount Socialite::Engine => '/socialite'
|
5
|
-
# resource :user, :module => 'socialite', :controller => 'user' do
|
6
|
-
# resources :identities, :only => [:destroy]
|
7
|
-
# end
|
8
|
-
# resource :home
|
9
|
-
match '/restricted' => 'home#show', :as => 'restricted'
|
10
|
-
root :to => 'home#index'
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
mount Socialite::Engine => "/socialite"
|
11
3
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class CreateSocialiteIdentities < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table :socialite_identities do |t|
|
4
|
+
t.string :uid, :provider
|
5
|
+
t.text :auth_hash
|
6
|
+
t.integer :socialite_user_id
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :socialite_identities,
|
11
|
+
:socialite_user_id
|
12
|
+
|
13
|
+
# Restrict each user to one identity per provider, to disable comment out.
|
14
|
+
add_index :socialite_identities,
|
15
|
+
[:socialite_user_id, :provider], :unique => true
|
16
|
+
|
17
|
+
# Database constraint to ensure uniqueness of UIDs (scoped to provider)
|
18
|
+
add_index :socialite_identities,
|
19
|
+
[:provider, :uid], :unique => true
|
20
|
+
end
|
21
|
+
|
22
|
+
def down
|
23
|
+
drop_table :socialite_identities
|
24
|
+
end
|
25
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,33 +11,25 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
15
|
-
|
16
|
-
create_table "socialite_facebook_identities", :force => true do |t|
|
17
|
-
t.datetime "created_at"
|
18
|
-
t.datetime "updated_at"
|
19
|
-
end
|
14
|
+
ActiveRecord::Schema.define(:version => 20130206224517) do
|
20
15
|
|
21
16
|
create_table "socialite_identities", :force => true do |t|
|
22
|
-
t.
|
23
|
-
t.
|
24
|
-
t.string "api_type"
|
25
|
-
t.string "unique_id", :null => false
|
26
|
-
t.string "provider", :null => false
|
17
|
+
t.string "uid"
|
18
|
+
t.string "provider"
|
27
19
|
t.text "auth_hash"
|
28
|
-
t.
|
29
|
-
t.datetime "
|
20
|
+
t.integer "socialite_user_id"
|
21
|
+
t.datetime "created_at", :null => false
|
22
|
+
t.datetime "updated_at", :null => false
|
30
23
|
end
|
31
24
|
|
32
|
-
add_index "socialite_identities", ["
|
33
|
-
add_index "socialite_identities", ["
|
34
|
-
add_index "socialite_identities", ["
|
35
|
-
add_index "socialite_identities", ["user_id"], :name => "index_socialite_identities_on_user_id"
|
25
|
+
add_index "socialite_identities", ["provider", "uid"], :name => "index_socialite_identities_on_provider_and_uid", :unique => true
|
26
|
+
add_index "socialite_identities", ["socialite_user_id", "provider"], :name => "index_socialite_identities_on_socialite_user_id_and_provider", :unique => true
|
27
|
+
add_index "socialite_identities", ["socialite_user_id"], :name => "index_socialite_identities_on_socialite_user_id"
|
36
28
|
|
37
29
|
create_table "socialite_users", :force => true do |t|
|
38
|
-
t.string "
|
39
|
-
t.datetime "created_at"
|
40
|
-
t.datetime "updated_at"
|
30
|
+
t.string "name"
|
31
|
+
t.datetime "created_at", :null => false
|
32
|
+
t.datetime "updated_at", :null => false
|
41
33
|
end
|
42
34
|
|
43
35
|
end
|
File without changes
|
File without changes
|
data/spec/dummy/public/500.html
CHANGED
data/spec/factories/facebook.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
FactoryGirl.define do
|
2
|
-
factory :facebook_identity, :class =>
|
3
|
-
# Attributes we may need should go here.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
# FactoryGirl.define do
|
2
|
+
# factory :facebook_identity, :class => MyFacebookIdentity do
|
3
|
+
# # Attributes we may need should go here.
|
4
|
+
# end
|
5
|
+
# end
|
data/spec/factories/identity.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :identity
|
3
|
-
sequence(:
|
2
|
+
factory :identity do
|
3
|
+
sequence(:uid, 1000) { |n| "abcdef#{n}" }
|
4
4
|
# association :user, :factory => :user, :method => :build
|
5
5
|
provider 'facebook'
|
6
6
|
auth_hash { x = { 'credentials' => {'token' => '123648493','secret' => '12477388272'} } }
|
7
|
-
association :api, :factory => :facebook_identity, :method => :build
|
7
|
+
# association :api, :factory => :facebook_identity, :method => :build
|
8
8
|
end
|
9
9
|
end
|
data/spec/factories/user.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
end
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :user do
|
3
|
+
# Something here
|
4
|
+
end
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
6
|
+
factory :linked_user, :parent => :user do
|
7
|
+
after(:build) do |user|
|
8
|
+
user.identities = [
|
9
|
+
FactoryGirl.build(:identity, :provider => 'facebook'),
|
10
|
+
FactoryGirl.build(:identity, :provider => 'twitter')
|
11
|
+
]
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "generators/socialite/install_generator"
|
3
|
+
|
4
|
+
describe Socialite::Generators::InstallGenerator do
|
5
|
+
destination File.expand_path("../../../../tmp", __FILE__)
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
prepare_destination
|
9
|
+
%w(config script).each do |dir|
|
10
|
+
`ln -s #{Rails.root + dir} #{destination_root}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
unless example.exception
|
16
|
+
prepare_destination
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# using mocks to ensure proper methods are called
|
21
|
+
# invoke_all - will call all the tasks in the generator
|
22
|
+
it 'should run all tasks in the generator' do
|
23
|
+
gen = generator %w(install)
|
24
|
+
gen.should_receive :copy_initializer
|
25
|
+
capture(:stdout) { gen.invoke_all }
|
26
|
+
end
|
27
|
+
|
28
|
+
# custom matchers make it easy to verify what the generator creates
|
29
|
+
describe 'the generated files' do
|
30
|
+
before do
|
31
|
+
run_generator %w(install)
|
32
|
+
end
|
33
|
+
describe 'the spec' do
|
34
|
+
# file - gives you the absolute path where the generator will create the file
|
35
|
+
subject { file('config/initializers/socialite.rb') }
|
36
|
+
# should exist - verifies the file exists
|
37
|
+
it { should exist }
|
38
|
+
|
39
|
+
# should contain - verifies the file's contents
|
40
|
+
it { should contain(/Socialite.setup do \|config\|/) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require "generators/socialite/migrations_generator"
|
3
|
+
|
4
|
+
describe Socialite::Generators::MigrationsGenerator do
|
5
|
+
destination File.expand_path("../../../../tmp", __FILE__)
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
prepare_destination
|
9
|
+
%w(config script).each do |dir|
|
10
|
+
`ln -s #{Rails.root + dir} #{destination_root}`
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
unless example.exception
|
16
|
+
prepare_destination
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# using mocks to ensure proper methods are called
|
21
|
+
# invoke_all - will call all the tasks in the generator
|
22
|
+
it 'should run all tasks in the generator' do
|
23
|
+
gen = generator %w(migrations)
|
24
|
+
gen.should_receive :copy_migrations
|
25
|
+
capture(:stdout) { gen.invoke_all }
|
26
|
+
end
|
27
|
+
end
|
@@ -1,28 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module Socialite
|
4
|
-
describe FacebookIdentity do
|
5
|
-
subject {
|
6
|
-
|
3
|
+
# module Socialite
|
4
|
+
# describe FacebookIdentity do
|
5
|
+
# # subject { MyFacebookIdentity.new }
|
6
|
+
# before { pending }
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# subject { FactoryGirl.build(:facebook_identity) }
|
9
|
+
# it_behaves_like 'facebook api'
|
10
10
|
|
11
|
-
|
11
|
+
# describe '.api_connection' do
|
12
|
+
# subject { Socialite::FacebookIdentity.api_connection }
|
12
13
|
|
13
|
-
it
|
14
|
-
subject.access_token.should be_nil
|
15
|
-
end
|
14
|
+
# it { should be_a(Koala::Facebook::API) }
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
# it 'defaults to not using an access token' do
|
17
|
+
# subject.access_token.should be_nil
|
18
|
+
# end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
20
|
+
# context 'with specified access token' do
|
21
|
+
# let!(:fake_token) { '1234567890' }
|
22
|
+
# subject { Socialite::FacebookIdentity.api_connection(fake_token) }
|
23
|
+
|
24
|
+
# it 'does not use an access_token unless specified' do
|
25
|
+
# subject.should be_a(Koala::Facebook::API)
|
26
|
+
# subject.access_token.should eql(fake_token)
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
data/spec/models/user_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
module Socialite
|
3
|
+
# module Socialite
|
4
4
|
describe User do
|
5
5
|
let(:linked_user) { FactoryGirl.create(:linked_user) }
|
6
6
|
|
7
7
|
it { should have_many(:identities).dependent(:destroy) }
|
8
|
-
it { should have_one(:facebook_identity) }
|
9
|
-
it { should have_one(:twitter_identity) }
|
8
|
+
# it { should have_one(:facebook_identity) }
|
9
|
+
# it { should have_one(:twitter_identity) }
|
10
10
|
|
11
11
|
context 'with associated identities' do
|
12
12
|
subject { linked_user }
|
@@ -17,11 +17,11 @@ module Socialite
|
|
17
17
|
|
18
18
|
its('identities.count') { should eql(2) }
|
19
19
|
|
20
|
-
its(:facebook_identity) { should be_a(
|
21
|
-
its(:facebook) { should be_a(Socialite::FacebookIdentity) }
|
20
|
+
its(:facebook_identity) { should be_a(identity_class) }
|
21
|
+
# its(:facebook) { should be_a(Socialite::FacebookIdentity) }
|
22
22
|
|
23
|
-
|
23
|
+
its(:twitter_identity) { should be_a(identity_class) }
|
24
24
|
# its(:twitter) { should be_a(Socialite::TwitterIdentity) }
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
# end
|