spree_paypal_express 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +14 -0
  3. data/Gemfile +3 -0
  4. data/LICENSE +23 -0
  5. data/README.markdown +146 -0
  6. data/Rakefile +13 -0
  7. data/Versionfile +5 -0
  8. data/app/assets/images/paypal.png +0 -0
  9. data/app/assets/javascripts/admin/spree_paypal_express.js +0 -0
  10. data/app/assets/javascripts/store/spree_paypal_express.js +0 -0
  11. data/app/assets/stylesheets/admin/spree_paypal_express.css +0 -0
  12. data/app/assets/stylesheets/store/spree_paypal_express.css +0 -0
  13. data/app/controllers/spree/checkout_controller_decorator.rb +384 -0
  14. data/app/controllers/spree/paypal_express_callbacks_controller.rb +44 -0
  15. data/app/helpers/spree/checkout_helper_decorator.rb +7 -0
  16. data/app/models/spree/billing_integration/paypal_express.rb +3 -0
  17. data/app/models/spree/billing_integration/paypal_express_base.rb +62 -0
  18. data/app/models/spree/billing_integration/paypal_express_uk.rb +3 -0
  19. data/app/models/spree/log_entry_decorator.rb +3 -0
  20. data/app/models/spree/payment_decorator.rb +3 -0
  21. data/app/models/spree/paypal_account.rb +36 -0
  22. data/app/overrides/spree/shared/_order_details/add_paypal_details.html.erb.deface +16 -0
  23. data/app/views/spree/admin/payments/source_forms/_paypalexpress.html.erb +9 -0
  24. data/app/views/spree/admin/payments/source_forms/_paypalexpressuk.html.erb +9 -0
  25. data/app/views/spree/admin/payments/source_views/_paypalexpress.html.erb +110 -0
  26. data/app/views/spree/admin/payments/source_views/_paypalexpressuk.html.erb +110 -0
  27. data/app/views/spree/admin/paypal_payments/refund.html.erb +15 -0
  28. data/app/views/spree/checkout/payment/_paypalexpress.html.erb +3 -0
  29. data/app/views/spree/checkout/payment/_paypalexpressuk.html.erb +3 -0
  30. data/app/views/spree/shared/_paypal_express_checkout.html.erb +3 -0
  31. data/app/views/spree/shared/paypal_express_confirm.html.erb +23 -0
  32. data/capture-notes +28 -0
  33. data/config/initializers/paypal_express.rb +1 -0
  34. data/config/locales/en-GB.yml +30 -0
  35. data/config/locales/en.yml +32 -0
  36. data/config/routes.rb +25 -0
  37. data/db/migrate/20100224133156_create_paypal_accounts.rb +14 -0
  38. data/db/migrate/20120117182027_namespace_paypal_accounts.rb +5 -0
  39. data/lib/generators/spree_paypal_express/install/install_generator.rb +18 -0
  40. data/lib/spree/paypal_express_configuration.rb +5 -0
  41. data/lib/spree_paypal_express.rb +3 -0
  42. data/lib/spree_paypal_express/engine.rb +38 -0
  43. data/response-example-one +55 -0
  44. data/response-xml-one +137 -0
  45. data/spec/controllers/checkout_controller_spec.rb +323 -0
  46. data/spec/factories/address_factory.rb +13 -0
  47. data/spec/factories/order_factory.rb +11 -0
  48. data/spec/factories/ppx_factory.rb +5 -0
  49. data/spec/factories/state_factory.rb +5 -0
  50. data/spec/models/billing_integration/paypal_express_base_spec.rb +135 -0
  51. data/spec/requests/paypal_express_spec.rb +40 -0
  52. data/spec/spec_helper.rb +37 -0
  53. data/spec/support/authentication_helpers.rb +13 -0
  54. data/spec/support/controller_hacks.rb +33 -0
  55. data/spec/support/shared_connection.rb +12 -0
  56. data/spec/support/url_helpers.rb +7 -0
  57. data/spree_paypal_express.gemspec +24 -0
  58. metadata +224 -0
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Paypal Express checkout" do
4
+ before do
5
+ FactoryGirl.create(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
6
+ FactoryGirl.create(:payment_method, :environment => 'test')
7
+ @product = FactoryGirl.create(:product, :name => "RoR Mug")
8
+ sign_in_as! FactoryGirl.create(:user)
9
+
10
+ FactoryGirl.create(:ppx)
11
+ end
12
+
13
+ let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) }
14
+
15
+ it "should display paypal link", :js => true do
16
+ visit spree.product_path(@product)
17
+
18
+ click_button "Add To Cart"
19
+ click_link "Checkout"
20
+
21
+ str_addr = "bill_address"
22
+ select "United States", :from => "order_#{str_addr}_attributes_country_id"
23
+ ['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field|
24
+ fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}"
25
+ end
26
+
27
+ select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id"
28
+ check "order_use_billing"
29
+ click_button "Save and Continue"
30
+
31
+ #delivery
32
+ click_button "Save and Continue"
33
+
34
+ choose "Paypal"
35
+ page.should have_selector('a#ppx')
36
+ click_button "Save and Continue"
37
+
38
+ current_path.should match /\A\/orders\/[A-Z][0-9]{9}\/checkout\/paypal_payment\z/
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
+ # from the project root directory.
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+ require File.expand_path("../dummy/config/environment", __FILE__)
5
+ require 'rspec/rails'
6
+ require 'capybara/rspec'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
11
+
12
+ #include spree's factories
13
+ require 'spree/core/testing_support/factories'
14
+ require 'spree/core/testing_support/fixtures'
15
+
16
+ # include local factories
17
+ Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
18
+ fp = File.expand_path(f)
19
+ require fp
20
+ end
21
+
22
+ require 'ffaker'
23
+
24
+ RSpec.configure do |config|
25
+ config.mock_with :rspec
26
+
27
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
28
+
29
+ config.use_transactional_fixtures = true
30
+ config.include Spree::UrlHelpers
31
+ end
32
+
33
+ Spree::Zone.class_eval do
34
+ def self.global
35
+ find_by_name("GlobalZone") || Factory(:global_zone)
36
+ end
37
+ end
@@ -0,0 +1,13 @@
1
+ module AuthenticationHelpers
2
+ def sign_in_as!(user)
3
+ visit '/login'
4
+ fill_in 'Email', :with => user.email
5
+ fill_in 'Password', :with => 'secret'
6
+ click_button 'Login'
7
+ end
8
+
9
+ end
10
+
11
+ RSpec.configure do |c|
12
+ c.include AuthenticationHelpers, :type => :request
13
+ end
@@ -0,0 +1,33 @@
1
+ module Spree
2
+ module ControllerHacks
3
+ def get(action, parameters = nil, session = nil, flash = nil)
4
+ process_spree_action(action, parameters, session, flash, "GET")
5
+ end
6
+
7
+ # Executes a request simulating POST HTTP method and set/volley the response
8
+ def post(action, parameters = nil, session = nil, flash = nil)
9
+ process_spree_action(action, parameters, session, flash, "POST")
10
+ end
11
+
12
+ # Executes a request simulating PUT HTTP method and set/volley the response
13
+ def put(action, parameters = nil, session = nil, flash = nil)
14
+ process_spree_action(action, parameters, session, flash, "PUT")
15
+ end
16
+
17
+ # Executes a request simulating DELETE HTTP method and set/volley the response
18
+ def delete(action, parameters = nil, session = nil, flash = nil)
19
+ process_spree_action(action, parameters, session, flash, "DELETE")
20
+ end
21
+
22
+ private
23
+
24
+ def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
25
+ parameters ||= {}
26
+ process(action, parameters.merge!(:use_route => :spree), session, flash, method)
27
+ end
28
+ end
29
+ end
30
+
31
+ RSpec.configure do |c|
32
+ c.include Spree::ControllerHacks, :type => :controller
33
+ end
@@ -0,0 +1,12 @@
1
+ class ActiveRecord::Base
2
+ mattr_accessor :shared_connection
3
+ @@shared_connection = nil
4
+
5
+ def self.connection
6
+ @@shared_connection || retrieve_connection
7
+ end
8
+ end
9
+
10
+ # Forces all threads to share the same connection. This works on
11
+ # Capybara because it starts the web server in a thread.
12
+ ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ module UrlHelpers
3
+ def spree
4
+ Spree::Core::Engine.routes.url_helpers
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'spree_paypal_express'
4
+ s.version = '1.1.0'
5
+ s.summary = 'Adds PayPal Express as a Payment Method to Spree store'
6
+ s.homepage = 'http://www.spreecommerce.com'
7
+ s.author = 'Spree Commerce'
8
+ s.email = 'gems@spreecommerce.com'
9
+ s.required_ruby_version = '>= 1.8.7'
10
+
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.require_paths = ["lib"]
14
+ s.has_rdoc = false
15
+
16
+ s.add_dependency('spree_core', '>=1.0.0')
17
+ s.add_dependency('spree_auth', '>=1.0.0')
18
+
19
+ s.add_development_dependency 'capybara', '1.1.2'
20
+ s.add_development_dependency 'factory_girl', '~> 3.5.0'
21
+ s.add_development_dependency 'ffaker'
22
+ s.add_development_dependency 'rspec-rails', '~> 2.11.0'
23
+ s.add_development_dependency 'sqlite3'
24
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_paypal_express
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 0
9
+ version: 1.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Spree Commerce
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-08-06 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: spree_core
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
31
+ version: 1.0.0
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: spree_auth
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 0
45
+ version: 1.0.0
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: capybara
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 1
58
+ - 2
59
+ version: 1.1.2
60
+ type: :development
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: factory_girl
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 3
71
+ - 5
72
+ - 0
73
+ version: 3.5.0
74
+ type: :development
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: ffaker
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ type: :development
87
+ version_requirements: *id005
88
+ - !ruby/object:Gem::Dependency
89
+ name: rspec-rails
90
+ prerelease: false
91
+ requirement: &id006 !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 2
97
+ - 11
98
+ - 0
99
+ version: 2.11.0
100
+ type: :development
101
+ version_requirements: *id006
102
+ - !ruby/object:Gem::Dependency
103
+ name: sqlite3
104
+ prerelease: false
105
+ requirement: &id007 !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ type: :development
113
+ version_requirements: *id007
114
+ description:
115
+ email: gems@spreecommerce.com
116
+ executables: []
117
+
118
+ extensions: []
119
+
120
+ extra_rdoc_files: []
121
+
122
+ files:
123
+ - .gitignore
124
+ - .travis.yml
125
+ - Gemfile
126
+ - LICENSE
127
+ - README.markdown
128
+ - Rakefile
129
+ - Versionfile
130
+ - app/assets/images/paypal.png
131
+ - app/assets/javascripts/admin/spree_paypal_express.js
132
+ - app/assets/javascripts/store/spree_paypal_express.js
133
+ - app/assets/stylesheets/admin/spree_paypal_express.css
134
+ - app/assets/stylesheets/store/spree_paypal_express.css
135
+ - app/controllers/spree/checkout_controller_decorator.rb
136
+ - app/controllers/spree/paypal_express_callbacks_controller.rb
137
+ - app/helpers/spree/checkout_helper_decorator.rb
138
+ - app/models/spree/billing_integration/paypal_express.rb
139
+ - app/models/spree/billing_integration/paypal_express_base.rb
140
+ - app/models/spree/billing_integration/paypal_express_uk.rb
141
+ - app/models/spree/log_entry_decorator.rb
142
+ - app/models/spree/payment_decorator.rb
143
+ - app/models/spree/paypal_account.rb
144
+ - app/overrides/spree/shared/_order_details/add_paypal_details.html.erb.deface
145
+ - app/views/spree/admin/payments/source_forms/_paypalexpress.html.erb
146
+ - app/views/spree/admin/payments/source_forms/_paypalexpressuk.html.erb
147
+ - app/views/spree/admin/payments/source_views/_paypalexpress.html.erb
148
+ - app/views/spree/admin/payments/source_views/_paypalexpressuk.html.erb
149
+ - app/views/spree/admin/paypal_payments/refund.html.erb
150
+ - app/views/spree/checkout/payment/_paypalexpress.html.erb
151
+ - app/views/spree/checkout/payment/_paypalexpressuk.html.erb
152
+ - app/views/spree/shared/_paypal_express_checkout.html.erb
153
+ - app/views/spree/shared/paypal_express_confirm.html.erb
154
+ - capture-notes
155
+ - config/initializers/paypal_express.rb
156
+ - config/locales/en-GB.yml
157
+ - config/locales/en.yml
158
+ - config/routes.rb
159
+ - db/migrate/20100224133156_create_paypal_accounts.rb
160
+ - db/migrate/20120117182027_namespace_paypal_accounts.rb
161
+ - lib/generators/spree_paypal_express/install/install_generator.rb
162
+ - lib/spree/paypal_express_configuration.rb
163
+ - lib/spree_paypal_express.rb
164
+ - lib/spree_paypal_express/engine.rb
165
+ - response-example-one
166
+ - response-xml-one
167
+ - spec/controllers/checkout_controller_spec.rb
168
+ - spec/factories/address_factory.rb
169
+ - spec/factories/order_factory.rb
170
+ - spec/factories/ppx_factory.rb
171
+ - spec/factories/state_factory.rb
172
+ - spec/models/billing_integration/paypal_express_base_spec.rb
173
+ - spec/requests/paypal_express_spec.rb
174
+ - spec/spec_helper.rb
175
+ - spec/support/authentication_helpers.rb
176
+ - spec/support/controller_hacks.rb
177
+ - spec/support/shared_connection.rb
178
+ - spec/support/url_helpers.rb
179
+ - spree_paypal_express.gemspec
180
+ has_rdoc: true
181
+ homepage: http://www.spreecommerce.com
182
+ licenses: []
183
+
184
+ post_install_message:
185
+ rdoc_options: []
186
+
187
+ require_paths:
188
+ - lib
189
+ required_ruby_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ segments:
194
+ - 1
195
+ - 8
196
+ - 7
197
+ version: 1.8.7
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ segments:
203
+ - 0
204
+ version: "0"
205
+ requirements: []
206
+
207
+ rubyforge_project:
208
+ rubygems_version: 1.3.6
209
+ signing_key:
210
+ specification_version: 3
211
+ summary: Adds PayPal Express as a Payment Method to Spree store
212
+ test_files:
213
+ - spec/controllers/checkout_controller_spec.rb
214
+ - spec/factories/address_factory.rb
215
+ - spec/factories/order_factory.rb
216
+ - spec/factories/ppx_factory.rb
217
+ - spec/factories/state_factory.rb
218
+ - spec/models/billing_integration/paypal_express_base_spec.rb
219
+ - spec/requests/paypal_express_spec.rb
220
+ - spec/spec_helper.rb
221
+ - spec/support/authentication_helpers.rb
222
+ - spec/support/controller_hacks.rb
223
+ - spec/support/shared_connection.rb
224
+ - spec/support/url_helpers.rb