socialite 0.0.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/.yardopts +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +208 -0
- data/LICENSE +176 -0
- data/README.md +63 -0
- data/Rakefile +34 -0
- data/app/assets/images/socialite/.gitkeep +0 -0
- data/app/assets/javascripts/socialite/.gitkeep +0 -0
- data/app/assets/stylesheets/socialite/socialite.css +40 -0
- data/app/assets/stylesheets/socialite.css +7 -0
- data/app/controllers/socialite/identities_controller.rb +53 -0
- data/app/controllers/socialite/session_controller.rb +28 -0
- data/app/controllers/socialite/user_controller.rb +39 -0
- data/app/helpers/socialite/authentication_helper.rb +15 -0
- data/app/models/socialite/facebook_identity.rb +7 -0
- data/app/models/socialite/identity.rb +6 -0
- data/app/models/socialite/user.rb +42 -0
- data/app/views/socialite/identities/_identities.html.haml +14 -0
- data/app/views/socialite/session/new.html.haml +14 -0
- data/app/views/socialite/user/_form.html.haml +13 -0
- data/app/views/socialite/user/edit.html.haml +1 -0
- data/app/views/socialite/user/show.html.haml +16 -0
- data/config/initializers/simple_form.rb +90 -0
- data/config/locales/simple_form.en.yml +23 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20110914215410_create_users.rb +14 -0
- data/db/migrate/20110925224222_create_identities.rb +26 -0
- data/db/migrate/20110926005551_create_facebook_identities.rb +12 -0
- data/features/authentication/facebook_signin.feature +5 -0
- data/features/authentication/twitter_signin.feature +5 -0
- data/features/identities/facebook_management.feature +14 -0
- data/features/identities/twitter_management.feature +7 -0
- data/features/registration/facebook_signup.feature +10 -0
- data/features/registration/twitter_signup.feature +0 -0
- data/features/step_definitions/authentication_steps.rb +31 -0
- data/features/step_definitions/common_steps.rb +13 -0
- data/features/step_definitions/identity_steps.rb +5 -0
- data/features/step_definitions/web_steps.rb +254 -0
- data/features/support/env.rb +58 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/omniauth.rb +31 -0
- data/features/support/paths.rb +34 -0
- data/features/support/selectors.rb +39 -0
- data/lib/socialite/api_wrappers/facebook.rb +67 -0
- data/lib/socialite/api_wrappers/twitter.rb +19 -0
- data/lib/socialite/base_identity.rb +96 -0
- data/lib/socialite/controller_support.rb +136 -0
- data/lib/socialite/engine.rb +32 -0
- data/lib/socialite/service_config.rb +14 -0
- data/lib/socialite/version.rb +3 -0
- data/lib/socialite.rb +37 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/socialite_tasks.rake +4 -0
- data/script/cucumber +10 -0
- data/script/rails +6 -0
- data/socialite.gemspec +39 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/home_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/home/index.html.haml +12 -0
- data/spec/dummy/app/views/home/show.html.haml +6 -0
- data/spec/dummy/app/views/layouts/application.html.erb +18 -0
- data/spec/dummy/config/application.rb +48 -0
- data/spec/dummy/config/boot.rb +20 -0
- data/spec/dummy/config/database.yml +9 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/socialite.rb +6 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +43 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/facebook.rb +5 -0
- data/spec/factories/identity.rb +9 -0
- data/spec/factories/twitter.rb +6 -0
- data/spec/factories/user.rb +16 -0
- data/spec/models/facebook_spec.rb +28 -0
- data/spec/models/identity_spec.rb +9 -0
- data/spec/models/user_spec.rb +27 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/.gitkeep +0 -0
- data/spec/support/database_loader.rb +13 -0
- data/spec/support/databases.yml +14 -0
- data/spec/support/identity_shared_example.rb +67 -0
- metadata +409 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = '4b232d389ba2c60db3997624e83822d79577a385e82149d0a277baa7e0e8a9898fdb21b3264f9be0bd0154e7e792e4cdf52a7c0f36e93042cb247ae72b0c61e6'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters :format => [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'socialite/engine'
|
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'
|
11
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20110926005551) do
|
15
|
+
|
16
|
+
create_table "socialite_facebook_identities", :force => true do |t|
|
17
|
+
t.datetime "created_at"
|
18
|
+
t.datetime "updated_at"
|
19
|
+
end
|
20
|
+
|
21
|
+
create_table "socialite_identities", :force => true do |t|
|
22
|
+
t.integer "user_id"
|
23
|
+
t.integer "api_id"
|
24
|
+
t.string "api_type"
|
25
|
+
t.string "unique_id", :null => false
|
26
|
+
t.string "provider", :null => false
|
27
|
+
t.text "auth_hash"
|
28
|
+
t.datetime "created_at"
|
29
|
+
t.datetime "updated_at"
|
30
|
+
end
|
31
|
+
|
32
|
+
add_index "socialite_identities", ["api_id", "api_type"], :name => "index_socialite_identities_on_api_id_and_api_type"
|
33
|
+
add_index "socialite_identities", ["provider", "unique_id"], :name => "index_socialite_identities_on_provider_and_unique_id", :unique => true
|
34
|
+
add_index "socialite_identities", ["user_id", "provider"], :name => "index_socialite_identities_on_user_id_and_provider", :unique => true
|
35
|
+
add_index "socialite_identities", ["user_id"], :name => "index_socialite_identities_on_user_id"
|
36
|
+
|
37
|
+
create_table "socialite_users", :force => true do |t|
|
38
|
+
t.string "remember_token"
|
39
|
+
t.datetime "created_at"
|
40
|
+
t.datetime "updated_at"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -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,26 @@
|
|
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
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</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'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :identity, :class => Socialite::Identity do
|
3
|
+
sequence(:unique_id, 1000) { |n| "abcdef#{n}" }
|
4
|
+
# association :user, :factory => :user, :method => :build
|
5
|
+
provider 'facebook'
|
6
|
+
auth_hash { x = { 'credentials' => {'token' => '123648493','secret' => '12477388272'} } }
|
7
|
+
association :api, :factory => :facebook_identity, :method => :build
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Socialite
|
2
|
+
FactoryGirl.define do
|
3
|
+
factory :user, :class => Socialite::User do
|
4
|
+
# Something here
|
5
|
+
end
|
6
|
+
|
7
|
+
factory :linked_user, :parent => :user do
|
8
|
+
after_build do |user|
|
9
|
+
user.identities = [
|
10
|
+
FactoryGirl.build(:identity, :provider => 'facebook'),
|
11
|
+
FactoryGirl.build(:identity, :provider => 'twitter')
|
12
|
+
]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Socialite
|
4
|
+
describe FacebookIdentity do
|
5
|
+
subject { FactoryGirl.build(:facebook_identity) }
|
6
|
+
it_behaves_like 'facebook api'
|
7
|
+
|
8
|
+
describe '.api_connection' do
|
9
|
+
subject { Socialite::FacebookIdentity.api_connection }
|
10
|
+
|
11
|
+
it { should be_a(Koala::Facebook::API) }
|
12
|
+
|
13
|
+
it 'defaults to not using an access token' do
|
14
|
+
subject.access_token.should be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with specified access token' do
|
18
|
+
let!(:fake_token) { '1234567890' }
|
19
|
+
subject { Socialite::FacebookIdentity.api_connection(fake_token) }
|
20
|
+
|
21
|
+
it 'does not use an access_token unless specified' do
|
22
|
+
subject.should be_a(Koala::Facebook::API)
|
23
|
+
subject.access_token.should eql(fake_token)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Socialite
|
4
|
+
describe User do
|
5
|
+
let(:linked_user) { FactoryGirl.create(:linked_user) }
|
6
|
+
|
7
|
+
it { should have_many(:identities).dependent(:destroy) }
|
8
|
+
it { should have_one(:facebook_identity) }
|
9
|
+
it { should have_one(:twitter_identity) }
|
10
|
+
|
11
|
+
context 'with associated identities' do
|
12
|
+
subject { linked_user }
|
13
|
+
|
14
|
+
before do
|
15
|
+
subject.identities.count.should eql(2)
|
16
|
+
end
|
17
|
+
|
18
|
+
its('identities.count') { should eql(2) }
|
19
|
+
|
20
|
+
its(:facebook_identity) { should be_a(Socialite::Identity) }
|
21
|
+
its(:facebook) { should be_a(Socialite::FacebookIdentity) }
|
22
|
+
|
23
|
+
# its(:twitter_identity) { should be_a(Socialite::Identity) }
|
24
|
+
# its(:twitter) { should be_a(Socialite::TwitterIdentity) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
|
+
require 'rails/test_help'
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
# Should matchers
|
9
|
+
require 'shoulda/matchers'
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
# Load support files
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
15
|
+
|
16
|
+
# Load factories
|
17
|
+
require 'factory_girl'
|
18
|
+
Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
# Run any available migration
|
21
|
+
ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate/', __FILE__)
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
require 'rspec/expectations'
|
25
|
+
config.include RSpec::Matchers
|
26
|
+
# config.include Socialite::Identity
|
27
|
+
|
28
|
+
config.use_transactional_fixtures = true
|
29
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
configs = YAML.load_file(File.join(File.dirname(__FILE__), 'databases.yml'))
|
2
|
+
ActiveRecord::Base.configurations = configs
|
3
|
+
|
4
|
+
db_name = ENV['DB'] || 'sqlite'
|
5
|
+
ActiveRecord::Base.establish_connection(db_name)
|
6
|
+
ActiveRecord::Base.default_timezone = :utc
|
7
|
+
|
8
|
+
load_schema = lambda {
|
9
|
+
# load File.join(File.dirname(__FILE__), "../dummy/db/schema.rb") # use db agnostic schema by default
|
10
|
+
ActiveRecord::Migrator.up(File.join(File.dirname(__FILE__), '../../db/migrate')) # use migrations
|
11
|
+
}
|
12
|
+
silence_stream(STDOUT, &load_schema)
|
13
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# test/database.yml
|
2
|
+
sqlite:
|
3
|
+
adapter: sqlite3
|
4
|
+
database: ":memory:"
|
5
|
+
timeout: 500
|
6
|
+
mysql:
|
7
|
+
adapter: mysql2
|
8
|
+
database: socialite_test
|
9
|
+
username:
|
10
|
+
encoding: utf8
|
11
|
+
postgres:
|
12
|
+
adapter: postgresql
|
13
|
+
database: socialite_test
|
14
|
+
username: postgres
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Socialite
|
2
|
+
shared_examples 'identity' do
|
3
|
+
it { should belong_to(:user) }
|
4
|
+
|
5
|
+
it { should have_db_column(:unique_id) }
|
6
|
+
it { should have_db_column(:provider) }
|
7
|
+
it { should have_db_column(:auth_hash) }
|
8
|
+
|
9
|
+
it { should validate_presence_of(:unique_id) }
|
10
|
+
it { should validate_presence_of(:provider) }
|
11
|
+
|
12
|
+
it { should validate_uniqueness_of(:unique_id).scoped_to(:provider) }
|
13
|
+
it { should validate_uniqueness_of(:provider).scoped_to(:user_id).case_insensitive }
|
14
|
+
|
15
|
+
describe '.find_or_initialize_by_oauth' do
|
16
|
+
let(:auth_hash) do
|
17
|
+
{
|
18
|
+
'provider' => 'facebook',
|
19
|
+
'uid' => '555',
|
20
|
+
'credentials' => {
|
21
|
+
'token' => '123648493',
|
22
|
+
'secret' => '12477388272'
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'facebook' do
|
28
|
+
# let(:fb_identity) { }
|
29
|
+
subject { Identity.find_or_initialize_by_oauth(auth_hash) }
|
30
|
+
|
31
|
+
it { should be_a(Identity) }
|
32
|
+
its(:persisted?) { should be_false }
|
33
|
+
|
34
|
+
context 'existing identity' do
|
35
|
+
let(:user) { FactoryGirl.create(:linked_user) }
|
36
|
+
let(:identity) { user.identities.first }
|
37
|
+
let(:auth_hash) { identity.auth_hash.merge('provider' => identity.provider, 'uid' => identity.unique_id) }
|
38
|
+
subject { Identity.find_or_initialize_by_oauth(auth_hash) }
|
39
|
+
before { user.identities.count.should > 0; identity.user.should be_present }
|
40
|
+
|
41
|
+
its(:persisted?) { should be_true }
|
42
|
+
its(:user) { should be_a(User) }
|
43
|
+
its(:user) { should eql(user) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# describe 'twitter' do
|
48
|
+
# let(:twitter_identity) { subject.find_or_initialize_by_oauth(auth_hash.merge('provider' => 'twitter')) }
|
49
|
+
# subject { twitter_identity }
|
50
|
+
|
51
|
+
# it { should be_a(Identity) }
|
52
|
+
# its(:persisted?) { should be_true }
|
53
|
+
# its(:user) { should be_a(User) }
|
54
|
+
# end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
shared_examples 'facebook api' do
|
59
|
+
it { should respond_to(:account_url) }
|
60
|
+
it { should respond_to(:api) }
|
61
|
+
it { should respond_to(:api_connection) }
|
62
|
+
it { should respond_to(:checkins) }
|
63
|
+
it { should respond_to(:friends) }
|
64
|
+
it { should respond_to(:picture) }
|
65
|
+
it { should respond_to(:info) }
|
66
|
+
end
|
67
|
+
end
|