socialite 0.1.0.pre → 0.1.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/app/assets/images/socialite/facebook_64.png +0 -0
  2. data/app/assets/images/socialite/twitter_64.png +0 -0
  3. data/app/controllers/socialite/sessions_controller.rb +69 -0
  4. data/app/controllers/socialite/users_controller.rb +2 -31
  5. data/app/views/layouts/socialite/application.html.haml +1 -1
  6. data/app/views/socialite/identities/new.html.haml +6 -19
  7. data/app/views/socialite/sessions/new.html.haml +30 -0
  8. data/app/views/socialite/users/new.html.haml +10 -0
  9. data/config/routes.rb +6 -7
  10. data/lib/generators/socialite/install_generator.rb +24 -5
  11. data/lib/generators/socialite/migrations_generator.rb +1 -1
  12. data/lib/generators/socialite/templates/socialite.rb +9 -0
  13. data/lib/generators/socialite/templates/users.rb.erb +5 -1
  14. data/lib/generators/socialite/views_generator.rb +22 -0
  15. data/lib/socialite.rb +4 -8
  16. data/lib/socialite/controllers/helpers.rb +5 -115
  17. data/lib/socialite/engine.rb +8 -11
  18. data/lib/socialite/ext/omniauth/identity/model.rb +29 -0
  19. data/lib/socialite/models/identity_concern.rb +24 -5
  20. data/lib/socialite/models/user_concern.rb +39 -0
  21. data/lib/socialite/version.rb +1 -1
  22. data/spec/dummy/app/controllers/pages_controller.rb +7 -0
  23. data/spec/dummy/app/models/user.rb +2 -0
  24. data/spec/dummy/app/views/pages/index.html.haml +5 -0
  25. data/spec/dummy/config/initializers/omniauth-identity.rb +11 -0
  26. data/spec/dummy/config/initializers/socialite.rb +9 -0
  27. data/spec/dummy/config/routes.rb +17 -1
  28. data/spec/dummy/db/migrate/20130207223009_create_socialite_users.rb +16 -0
  29. data/spec/dummy/db/migrate/{20130206224517_create_socialite_identities.rb → 20130207223010_create_socialite_identities.rb} +0 -0
  30. data/spec/dummy/db/schema.rb +7 -3
  31. data/spec/factories/user.rb +11 -1
  32. data/{features/registration/twitter_signup.feature → spec/features/.gitkeep} +0 -0
  33. data/spec/features/facebook_registration_spec.rb +16 -0
  34. data/spec/features/identity_login_spec.rb +26 -0
  35. data/spec/features/identity_registration_spec.rb +31 -0
  36. data/spec/generators/socialite/install_generator_spec.rb +8 -1
  37. data/spec/generators/socialite/views_generator_spec.rb +27 -0
  38. data/spec/models/identity_spec.rb +4 -6
  39. data/spec/models/user_spec.rb +18 -18
  40. data/spec/socialite_spec.rb +31 -7
  41. data/spec/spec_helper.rb +4 -1
  42. data/spec/support/capybara.rb +3 -0
  43. data/spec/support/database_cleaner.rb +18 -0
  44. data/spec/support/identity_shared_example.rb +4 -23
  45. data/spec/support/omniauth.rb +35 -0
  46. metadata +95 -78
  47. data/app/controllers/socialite/identities_controller.rb +0 -41
  48. data/app/controllers/socialite/session_controller.rb +0 -32
  49. data/app/views/socialite/session/new.html.haml +0 -31
  50. data/app/views/socialite/user/_form.html.haml +0 -13
  51. data/app/views/socialite/user/edit.html.haml +0 -1
  52. data/app/views/socialite/user/show.html.haml +0 -16
  53. data/features/authentication/facebook_signin.feature +0 -5
  54. data/features/authentication/twitter_signin.feature +0 -5
  55. data/features/identities/facebook_management.feature +0 -14
  56. data/features/identities/twitter_management.feature +0 -7
  57. data/features/registration/facebook_signup.feature +0 -10
  58. data/features/step_definitions/authentication_steps.rb +0 -31
  59. data/features/step_definitions/common_steps.rb +0 -13
  60. data/features/step_definitions/identity_steps.rb +0 -5
  61. data/features/step_definitions/web_steps.rb +0 -254
  62. data/features/support/env.rb +0 -58
  63. data/features/support/hooks.rb +0 -3
  64. data/features/support/omniauth.rb +0 -31
  65. data/features/support/paths.rb +0 -34
  66. data/features/support/selectors.rb +0 -39
  67. data/lib/socialite/helpers/authentication.rb +0 -17
  68. data/lib/socialite/models/facebook_identity.rb +0 -14
  69. data/spec/dummy/db/migrate/20130206224516_create_socialite_users.rb +0 -12
  70. data/spec/factories/facebook.rb +0 -5
  71. data/spec/factories/twitter.rb +0 -6
  72. data/spec/models/facebook_spec.rb +0 -31
@@ -1,58 +0,0 @@
1
- ENV["RAILS_ENV"] ||= "test"
2
- require File.expand_path("../../../spec/dummy/config/environment.rb", __FILE__)
3
- ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../spec/dummy"
4
-
5
- # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
6
- # It is recommended to regenerate this file in the future when you upgrade to a
7
- # newer version of cucumber-rails. Consider adding your own code to a new file
8
- # instead of editing this one. Cucumber will automatically load all features/**/*.rb
9
- # files.
10
-
11
- require 'cucumber/rails'
12
-
13
- # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
14
- # order to ease the transition to Capybara we set the default here. If you'd
15
- # prefer to use XPath just remove this line and adjust any selectors in your
16
- # steps to use the XPath syntax.
17
- Capybara.default_selector = :css
18
-
19
- # By default, any exception happening in your Rails application will bubble up
20
- # to Cucumber so that your scenario will fail. This is a different from how
21
- # your application behaves in the production environment, where an error page will
22
- # be rendered instead.
23
- #
24
- # Sometimes we want to override this default behaviour and allow Rails to rescue
25
- # exceptions and display an error page (just like when the app is running in production).
26
- # Typical scenarios where you want to do this is when you test your error pages.
27
- # There are two ways to allow Rails to rescue exceptions:
28
- #
29
- # 1) Tag your scenario (or feature) with @allow-rescue
30
- #
31
- # 2) Set the value below to true. Beware that doing this globally is not
32
- # recommended as it will mask a lot of errors for you!
33
- #
34
- ActionController::Base.allow_rescue = false
35
-
36
- # Remove/comment out the lines below if your app doesn't have a database.
37
- # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
38
- begin
39
- DatabaseCleaner.strategy = :transaction
40
- rescue NameError
41
- raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
42
- end
43
-
44
- # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
45
- # See the DatabaseCleaner documentation for details. Example:
46
- #
47
- # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
48
- # DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
49
- # end
50
- #
51
- # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
52
- # DatabaseCleaner.strategy = :transaction
53
- # end
54
-
55
-
56
- # Run any available migration
57
- ActiveRecord::Migrator.migrate File.expand_path('../../../spec/dummy/db/migrate/', __FILE__)
58
-
@@ -1,3 +0,0 @@
1
- Before do
2
- @default_user = { :email => 'foobar@example.com', :password => 'default' }
3
- end
@@ -1,31 +0,0 @@
1
- Before '@omniauth' do
2
- OmniAuth.config.test_mode = true
3
-
4
- # the symbol passed to mock_auth is the same as the name of the provider set up in the initializer
5
- # OmniAuth.config.mock_auth[:google] = {
6
- # "provider"=>"google",
7
- # "uid"=>"http://xxxx.com/openid?id=118181138998978630963",
8
- # "user_info"=>{"email"=>"test@xxxx.com", "first_name"=>"Test", "last_name"=>"User", "name"=>"Test User"}
9
- # }
10
-
11
- OmniAuth.config.add_mock(:facebook, {
12
- 'uid' => '1234',
13
- 'extra' => {
14
- 'user_hash' => {
15
- 'email' => 'foobar@example.com',
16
- 'first_name' => 'John',
17
- 'last_name' => 'Doe',
18
- 'gender' => 'Male'
19
- }
20
- }
21
- })
22
-
23
- OmniAuth.config.add_mock(:twitter, {
24
- :uid => '12345',
25
- :nickname => 'zapnap'
26
- })
27
- end
28
-
29
- After '@omniauth' do
30
- OmniAuth.config.test_mode = false
31
- end
@@ -1,34 +0,0 @@
1
- module NavigationHelpers
2
- # Maps a name to a path. Used by the
3
- #
4
- # When /^I go to (.+)$/ do |page_name|
5
- #
6
- # step definition in web_steps.rb
7
- #
8
- def path_to(page_name)
9
- case page_name
10
-
11
- when /^the home\s?page$/
12
- '/'
13
-
14
- # Add more mappings here.
15
- # Here is an example that pulls values out of the Regexp:
16
- #
17
- # when /^(.*)'s profile page$/i
18
- # user_profile_path(User.find_by_login($1))
19
-
20
- else
21
- begin
22
- page_name =~ /^the (.*) page$/
23
- path_components = $1.split(/\s+/)
24
- self.send(path_components.push('path').join('_').to_sym)
25
- rescue NoMethodError, ArgumentError
26
- raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
- "Now, go and add a mapping in #{__FILE__}"
28
- end
29
- end
30
- end
31
- end
32
-
33
- World(NavigationHelpers)
34
- World(Rails.application.routes.url_helpers)
@@ -1,39 +0,0 @@
1
- module HtmlSelectorsHelpers
2
- # Maps a name to a selector. Used primarily by the
3
- #
4
- # When /^(.+) within (.+)$/ do |step, scope|
5
- #
6
- # step definitions in web_steps.rb
7
- #
8
- def selector_for(locator)
9
- case locator
10
-
11
- when "the page"
12
- "html > body"
13
-
14
- # Add more mappings here.
15
- # Here is an example that pulls values out of the Regexp:
16
- #
17
- # when /^the (notice|error|info) flash$/
18
- # ".flash.#{$1}"
19
-
20
- # You can also return an array to use a different selector
21
- # type, like:
22
- #
23
- # when /the header/
24
- # [:xpath, "//header"]
25
-
26
- # This allows you to provide a quoted selector as the scope
27
- # for "within" steps as was previously the default for the
28
- # web steps:
29
- when /^"(.+)"$/
30
- $1
31
-
32
- else
33
- raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
34
- "Now, go and add a mapping in #{__FILE__}"
35
- end
36
- end
37
- end
38
-
39
- World(HtmlSelectorsHelpers)
@@ -1,17 +0,0 @@
1
- module Socialite
2
- module Helpers
3
- module Authentication
4
- def identity_request_path(options={})
5
- ['/auth', options[:service]].join('/')
6
- end
7
-
8
- def twitter_login_button
9
- content_tag(:a, content_tag(:span, 'Sign in with Twitter'), :class => 'socialite_button twitter', :href => identity_request_path(:service => 'twitter'), :rel => 'external')
10
- end
11
-
12
- def facebook_login_button
13
- content_tag(:a, content_tag(:span, 'Sign in with Facebook'), :class => 'socialite_button facebook', :href => identity_request_path(:service => 'facebook'), :rel => 'external')
14
- end
15
- end
16
- end
17
- end
@@ -1,14 +0,0 @@
1
- module Socialite
2
- module Models
3
- module FacebookIdentity
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- include Socialite::ApiWrappers::Facebook
8
-
9
- has_one :identity, :as => :api
10
- delegate :access_token, :access_token_secret, :to => :identity, :allow_nil => true
11
- end
12
- end
13
- end
14
- end
@@ -1,12 +0,0 @@
1
- class CreateSocialiteUsers < ActiveRecord::Migration
2
- def up
3
- create_table :socialite_users do |t|
4
- t.string :name
5
- t.timestamps
6
- end
7
- end
8
-
9
- def down
10
- drop_table :socialite_users
11
- end
12
- end
@@ -1,5 +0,0 @@
1
- # FactoryGirl.define do
2
- # factory :facebook_identity, :class => MyFacebookIdentity do
3
- # # Attributes we may need should go here.
4
- # end
5
- # end
@@ -1,6 +0,0 @@
1
- FactoryGirl.define do
2
- # factory :twitter_identity, :class => Socialite::TwitterIdentity do
3
-
4
- # end
5
- end
6
-
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # module Socialite
4
- # describe FacebookIdentity do
5
- # # subject { MyFacebookIdentity.new }
6
- # before { pending }
7
-
8
- # subject { FactoryGirl.build(:facebook_identity) }
9
- # it_behaves_like 'facebook api'
10
-
11
- # describe '.api_connection' do
12
- # subject { Socialite::FacebookIdentity.api_connection }
13
-
14
- # it { should be_a(Koala::Facebook::API) }
15
-
16
- # it 'defaults to not using an access token' do
17
- # subject.access_token.should be_nil
18
- # end
19
-
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