devise_paypal 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 (82) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +4 -0
  3. data/MIT-LICENSE +21 -0
  4. data/README.markdown +125 -0
  5. data/Rakefile +2 -0
  6. data/app/controllers/devise/paypal_authable_controller.rb +24 -0
  7. data/app/controllers/devise/paypal_permissions_authable_controller.rb +25 -0
  8. data/config/locales/en.yml +7 -0
  9. data/devise_paypal.gemspec +23 -0
  10. data/features/paypal_authable.feature +30 -0
  11. data/features/paypal_permissions_authable.feature +40 -0
  12. data/features/step_definitions/extended_web_steps.rb +12 -0
  13. data/features/step_definitions/paypal_authable_steps.rb +11 -0
  14. data/features/step_definitions/paypal_authentication_steps.rb +25 -0
  15. data/features/step_definitions/paypal_permissions_authable_steps.rb +22 -0
  16. data/features/step_definitions/pickle_steps.rb +100 -0
  17. data/features/step_definitions/web_steps.rb +219 -0
  18. data/features/support/env.rb +58 -0
  19. data/features/support/fakeweb.rb +3 -0
  20. data/features/support/hooks.rb +10 -0
  21. data/features/support/paths.rb +46 -0
  22. data/features/support/paypal_response_helpers.rb +14 -0
  23. data/features/support/pickle.rb +24 -0
  24. data/lib/devise_paypal.rb +18 -0
  25. data/lib/devise_paypal/controllers/internal_helpers.rb +58 -0
  26. data/lib/devise_paypal/controllers/url_helpers.rb +16 -0
  27. data/lib/devise_paypal/models/paypal_authable.rb +22 -0
  28. data/lib/devise_paypal/models/paypal_permissions_authable.rb +22 -0
  29. data/lib/devise_paypal/rails.rb +21 -0
  30. data/lib/devise_paypal/rails/routes.rb +39 -0
  31. data/lib/devise_paypal/version.rb +3 -0
  32. data/lib/generators/devise_paypal/install_generator.rb +18 -0
  33. data/lib/generators/templates/README +20 -0
  34. data/test/rails_app/.gitignore +4 -0
  35. data/test/rails_app/Gemfile +21 -0
  36. data/test/rails_app/Gemfile.lock +169 -0
  37. data/test/rails_app/Rakefile +7 -0
  38. data/test/rails_app/app/controllers/application_controller.rb +3 -0
  39. data/test/rails_app/app/controllers/welcome_controller.rb +5 -0
  40. data/test/rails_app/app/models/user.rb +26 -0
  41. data/test/rails_app/app/views/layouts/application.html.erb +16 -0
  42. data/test/rails_app/app/views/welcome/index.html.erb +11 -0
  43. data/test/rails_app/config.ru +4 -0
  44. data/test/rails_app/config/application.rb +42 -0
  45. data/test/rails_app/config/boot.rb +13 -0
  46. data/test/rails_app/config/cucumber.yml +8 -0
  47. data/test/rails_app/config/database.yml +25 -0
  48. data/test/rails_app/config/environment.rb +5 -0
  49. data/test/rails_app/config/environments/development.rb +28 -0
  50. data/test/rails_app/config/environments/production.rb +49 -0
  51. data/test/rails_app/config/environments/test.rb +35 -0
  52. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  53. data/test/rails_app/config/initializers/devise.rb +168 -0
  54. data/test/rails_app/config/initializers/inflections.rb +10 -0
  55. data/test/rails_app/config/initializers/mime_types.rb +5 -0
  56. data/test/rails_app/config/initializers/paypal.rb +7 -0
  57. data/test/rails_app/config/initializers/secret_token.rb +7 -0
  58. data/test/rails_app/config/initializers/session_store.rb +8 -0
  59. data/test/rails_app/config/locales/devise.en.yml +43 -0
  60. data/test/rails_app/config/locales/en.yml +5 -0
  61. data/test/rails_app/config/routes.rb +5 -0
  62. data/test/rails_app/db/migrate/20101102105924_devise_create_users.rb +26 -0
  63. data/test/rails_app/db/schema.rb +34 -0
  64. data/test/rails_app/db/seeds.rb +7 -0
  65. data/test/rails_app/lib/tasks/.gitkeep +0 -0
  66. data/test/rails_app/lib/tasks/cucumber.rake +53 -0
  67. data/test/rails_app/public/404.html +26 -0
  68. data/test/rails_app/public/422.html +26 -0
  69. data/test/rails_app/public/500.html +26 -0
  70. data/test/rails_app/public/favicon.ico +0 -0
  71. data/test/rails_app/public/images/rails.png +0 -0
  72. data/test/rails_app/public/javascripts/application.js +2 -0
  73. data/test/rails_app/public/javascripts/controls.js +965 -0
  74. data/test/rails_app/public/javascripts/dragdrop.js +974 -0
  75. data/test/rails_app/public/javascripts/effects.js +1123 -0
  76. data/test/rails_app/public/javascripts/prototype.js +6001 -0
  77. data/test/rails_app/public/javascripts/rails.js +175 -0
  78. data/test/rails_app/public/robots.txt +5 -0
  79. data/test/rails_app/public/stylesheets/.gitkeep +0 -0
  80. data/test/rails_app/script/cucumber +10 -0
  81. data/test/rails_app/script/rails +6 -0
  82. metadata +159 -0
@@ -0,0 +1,16 @@
1
+ module DevisePaypal
2
+ module Controllers
3
+ module UrlHelpers
4
+ def paypal_authable_callback_url(resource_or_scope, *args)
5
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
6
+ send("#{scope}_paypal_authable_callback_url", *args)
7
+ end
8
+
9
+ def paypal_permissions_authable_callback_url(resource_or_scope, *args)
10
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
11
+ send("#{scope}_paypal_permissions_authable_callback_url", *args)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,22 @@
1
+ module Devise
2
+ module Models
3
+ # Registerable is responsible for everything related to registering a new
4
+ # resource (ie user sign up).
5
+ module PaypalAuthable
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+ # A convenience method that receives both parameters and session to
10
+ # initialize an user. This can be used by OAuth, for example, to send
11
+ # in the user token and be stored on initialization.
12
+ #
13
+ # By default discards all information sent by the session by calling
14
+ # new with params.
15
+ def new_with_session(params, session)
16
+ new(params)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,22 @@
1
+ module Devise
2
+ module Models
3
+ # Registerable is responsible for everything related to registering a new
4
+ # resource (ie user sign up).
5
+ module PaypalPermissionsAuthable
6
+ extend ActiveSupport::Concern
7
+
8
+ module ClassMethods
9
+ # A convenience method that receives both parameters and session to
10
+ # initialize an user. This can be used by OAuth, for example, to send
11
+ # in the user token and be stored on initialization.
12
+ #
13
+ # By default discards all information sent by the session by calling
14
+ # new with params.
15
+ def new_with_session(params, session)
16
+ new(params)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,21 @@
1
+ module DevisePaypal
2
+ class Engine < ::Rails::Engine
3
+ ActiveSupport.on_load(:action_controller) {
4
+ include DevisePaypal::Controllers::UrlHelpers
5
+ }
6
+
7
+ def eager_load!
8
+ mappings = Devise.mappings.values.map(&:modules).flatten.uniq
9
+ controllers = Devise::CONTROLLERS.values_at(*mappings)
10
+ path = paths.app.controllers.to_a.first
11
+ matcher = /\A#{Regexp.escape(path)}\/(.*)\.rb\Z/
12
+
13
+ Dir.glob("#{path}/devise/{#{controllers.join(',')}}_controller.rb").sort.each do |file|
14
+ require_dependency file.sub(matcher, '\1')
15
+ end
16
+
17
+ super
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,39 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ protected
4
+ def devise_paypal_authable(mapping, controllers) #:nodoc:
5
+ path_names = {
6
+ :new => mapping.path_names[:paypal_authorize_without_permissions],
7
+ }
8
+
9
+ resource :paypal_authable,
10
+ :only => :new,
11
+ :path => mapping.path_names[:registration],
12
+ :path_names => path_names,
13
+ :controller => controllers[:paypal_authable]
14
+
15
+ get "/paypal_authable/callback",
16
+ :to => controllers[:paypal_authable],
17
+ :action => :callback_action,
18
+ :as => :paypal_authable_callback
19
+ end
20
+
21
+ def devise_paypal_permissions_authable(mapping, controllers) #:nodoc:
22
+ path_names = {
23
+ :new => mapping.path_names[:paypal_authorize_with_permissions],
24
+ }
25
+
26
+ resource :paypal_permissions_authable,
27
+ :only => :new,
28
+ :path => mapping.path_names[:registration],
29
+ :path_names => path_names,
30
+ :controller => controllers[:paypal_permissions_authable]
31
+
32
+ get "/paypal_permissions_authable/callback",
33
+ :to => controllers[:paypal_permissions_authable],
34
+ :action => :callback_action,
35
+ :as => :paypal_permissions_authable_callback
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,3 @@
1
+ module DevisePaypal
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ module DevisePaypal
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Copies locale files to your application."
7
+
8
+ def copy_locale
9
+ copy_file "../../../config/locales/en.yml", "config/locales/devise_paypal.en.yml"
10
+ end
11
+
12
+ def show_readme
13
+ readme "README" if behavior == :invoke
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,20 @@
1
+
2
+ ===============================================================================
3
+
4
+ Some setup you must do manually if you haven't already:
5
+
6
+ 1. Add the paypal-ipn gem to your Gemfile
7
+
8
+ gem 'paypal-ipn', :require => 'paypal'
9
+
10
+ This is a required to communicate with paypal
11
+
12
+ 2. Generate a paypal initializer
13
+
14
+ rails g paypal:initializer
15
+
16
+ 3. Edit config/initializers/paypal.rb and configure your api details
17
+ For more info see: http://github.com/dwilkie/paypal
18
+
19
+ ===============================================================================
20
+
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/**/*
@@ -0,0 +1,21 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.1'
4
+
5
+ # Bundle edge Rails instead:
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
+
8
+ gem 'sqlite3-ruby', :require => 'sqlite3'
9
+
10
+ gem 'devise', "1.2.rc"
11
+ gem 'devise_paypal', :git => 'git://github.com/dwilkie/devise_paypal.git'
12
+ gem 'paypal-ipn', :require => 'paypal', :git => 'git://github.com/dwilkie/paypal.git'
13
+
14
+ group :test do
15
+ gem 'cucumber-rails'
16
+ gem 'capybara'
17
+ gem 'pickle'
18
+ gem 'fakeweb'
19
+ gem 'ruby-debug19'
20
+ end
21
+
@@ -0,0 +1,169 @@
1
+ GIT
2
+ remote: git://github.com/dwilkie/devise_paypal.git
3
+ revision: d28604a7c336ac6fdeec553636132dc0aea41741
4
+ specs:
5
+ devise_paypal (0.0.1)
6
+ paypal-ipn (> 0.0.1)
7
+
8
+ GIT
9
+ remote: git://github.com/dwilkie/paypal.git
10
+ revision: 7ac86013bae9e07b9355e4754a930ddcbf1e5e2a
11
+ specs:
12
+ paypal-ipn (0.0.2)
13
+ httparty
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ abstract (1.0.0)
19
+ actionmailer (3.0.1)
20
+ actionpack (= 3.0.1)
21
+ mail (~> 2.2.5)
22
+ actionpack (3.0.1)
23
+ activemodel (= 3.0.1)
24
+ activesupport (= 3.0.1)
25
+ builder (~> 2.1.2)
26
+ erubis (~> 2.6.6)
27
+ i18n (~> 0.4.1)
28
+ rack (~> 1.2.1)
29
+ rack-mount (~> 0.6.12)
30
+ rack-test (~> 0.5.4)
31
+ tzinfo (~> 0.3.23)
32
+ activemodel (3.0.1)
33
+ activesupport (= 3.0.1)
34
+ builder (~> 2.1.2)
35
+ i18n (~> 0.4.1)
36
+ activerecord (3.0.1)
37
+ activemodel (= 3.0.1)
38
+ activesupport (= 3.0.1)
39
+ arel (~> 1.0.0)
40
+ tzinfo (~> 0.3.23)
41
+ activeresource (3.0.1)
42
+ activemodel (= 3.0.1)
43
+ activesupport (= 3.0.1)
44
+ activesupport (3.0.1)
45
+ archive-tar-minitar (0.5.2)
46
+ arel (1.0.1)
47
+ activesupport (~> 3.0.0)
48
+ bcrypt-ruby (2.1.2)
49
+ builder (2.1.2)
50
+ capybara (0.3.9)
51
+ culerity (>= 0.2.4)
52
+ mime-types (>= 1.16)
53
+ nokogiri (>= 1.3.3)
54
+ rack (>= 1.0.0)
55
+ rack-test (>= 0.5.4)
56
+ selenium-webdriver (>= 0.0.3)
57
+ childprocess (0.0.7)
58
+ ffi (~> 0.6.3)
59
+ columnize (0.3.1)
60
+ crack (0.1.8)
61
+ cucumber (0.8.5)
62
+ builder (~> 2.1.2)
63
+ diff-lcs (~> 1.1.2)
64
+ gherkin (~> 2.1.4)
65
+ json_pure (~> 1.4.3)
66
+ term-ansicolor (~> 1.0.4)
67
+ cucumber-rails (0.3.2)
68
+ cucumber (>= 0.8.0)
69
+ culerity (0.2.12)
70
+ devise (1.2.rc)
71
+ bcrypt-ruby (~> 2.1.2)
72
+ warden (~> 1.0.0)
73
+ diff-lcs (1.1.2)
74
+ erubis (2.6.6)
75
+ abstract (>= 1.0.0)
76
+ fakeweb (1.3.0)
77
+ ffi (0.6.3)
78
+ rake (>= 0.8.7)
79
+ gherkin (2.1.5)
80
+ trollop (~> 1.16.2)
81
+ httparty (0.6.1)
82
+ crack (= 0.1.8)
83
+ i18n (0.4.2)
84
+ json_pure (1.4.6)
85
+ linecache19 (0.5.11)
86
+ ruby_core_source (>= 0.1.4)
87
+ mail (2.2.9)
88
+ activesupport (>= 2.3.6)
89
+ i18n (~> 0.4.1)
90
+ mime-types (~> 1.16)
91
+ treetop (~> 1.4.8)
92
+ mime-types (1.16)
93
+ nokogiri (1.4.3.1)
94
+ pickle (0.4.2)
95
+ cucumber (>= 0.8)
96
+ rake
97
+ rspec (>= 1.3)
98
+ yard
99
+ polyglot (0.3.1)
100
+ rack (1.2.1)
101
+ rack-mount (0.6.13)
102
+ rack (>= 1.0.0)
103
+ rack-test (0.5.6)
104
+ rack (>= 1.0)
105
+ rails (3.0.1)
106
+ actionmailer (= 3.0.1)
107
+ actionpack (= 3.0.1)
108
+ activerecord (= 3.0.1)
109
+ activeresource (= 3.0.1)
110
+ activesupport (= 3.0.1)
111
+ bundler (~> 1.0.0)
112
+ railties (= 3.0.1)
113
+ railties (3.0.1)
114
+ actionpack (= 3.0.1)
115
+ activesupport (= 3.0.1)
116
+ rake (>= 0.8.4)
117
+ thor (~> 0.14.0)
118
+ rake (0.8.7)
119
+ rspec (2.0.0.rc)
120
+ rspec-core (= 2.0.0.rc)
121
+ rspec-expectations (= 2.0.0.rc)
122
+ rspec-mocks (= 2.0.0.rc)
123
+ rspec-core (2.0.0.rc)
124
+ rspec-expectations (2.0.0.rc)
125
+ diff-lcs (>= 1.1.2)
126
+ rspec-mocks (2.0.0.rc)
127
+ rspec-core (= 2.0.0.rc)
128
+ rspec-expectations (= 2.0.0.rc)
129
+ ruby-debug-base19 (0.11.24)
130
+ columnize (>= 0.3.1)
131
+ linecache19 (>= 0.5.11)
132
+ ruby_core_source (>= 0.1.4)
133
+ ruby-debug19 (0.11.6)
134
+ columnize (>= 0.3.1)
135
+ linecache19 (>= 0.5.11)
136
+ ruby-debug-base19 (>= 0.11.19)
137
+ ruby_core_source (0.1.4)
138
+ archive-tar-minitar (>= 0.5.2)
139
+ rubyzip (0.9.4)
140
+ selenium-webdriver (0.0.29)
141
+ childprocess (>= 0.0.7)
142
+ ffi (~> 0.6.3)
143
+ json_pure
144
+ rubyzip
145
+ sqlite3-ruby (1.3.1)
146
+ term-ansicolor (1.0.5)
147
+ thor (0.14.4)
148
+ treetop (1.4.8)
149
+ polyglot (>= 0.3.1)
150
+ trollop (1.16.2)
151
+ tzinfo (0.3.23)
152
+ warden (1.0.0)
153
+ rack (>= 1.0.0)
154
+ yard (0.6.1)
155
+
156
+ PLATFORMS
157
+ ruby
158
+
159
+ DEPENDENCIES
160
+ capybara
161
+ cucumber-rails
162
+ devise (= 1.2.rc)
163
+ devise_paypal!
164
+ fakeweb
165
+ paypal-ipn!
166
+ pickle
167
+ rails (= 3.0.1)
168
+ ruby-debug19
169
+ sqlite3-ruby
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ DevisePaypalTest::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,5 @@
1
+ class WelcomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
5
+
@@ -0,0 +1,26 @@
1
+ class User < ActiveRecord::Base
2
+ # Include default devise modules. Others available are:
3
+ # :token_authenticatable, :confirmable, :lockable and :timeoutable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :trackable, :validatable,
6
+ :paypal_authable, :paypal_permissions_authable
7
+
8
+ # Setup accessible (or protected) attributes for your model
9
+ attr_accessible :email, :password, :password_confirmation, :remember_me
10
+
11
+ def self.find_for_paypal_auth(params)
12
+ if params
13
+ user = self.find_or_initialize_by_email(params[:email])
14
+ if user.new_record?
15
+ stubbed_password = Devise.friendly_token[0..password_length.max-1]
16
+ user.password = stubbed_password
17
+ user.password_confirmation = stubbed_password
18
+ user.save
19
+ end
20
+ else
21
+ user = self.new
22
+ end
23
+ user
24
+ end
25
+ end
26
+
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>DevisePaypalTest</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+ <p class="notice"><%= notice %></p>
11
+ <p class="alert"><%= alert %></p>
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
16
+
@@ -0,0 +1,11 @@
1
+ <% if user_signed_in? %>
2
+ Welcome <%= current_user.email %>
3
+ <br/>
4
+ <%= link_to "Logout", destroy_user_session_path %>
5
+ <% else %>
6
+ <%= link_to "Login or Signup through Paypal Authable", new_user_paypal_authable_path %>
7
+ <br/>
8
+ <br/>
9
+ <%= link_to "Login or Signup through Paypal Permissions Authable", new_user_paypal_permissions_authable_path %>
10
+ <% end %>
11
+