catarse_moip 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -6
  3. data/.rspec +2 -0
  4. data/.travis.yml +17 -0
  5. data/Gemfile +2 -109
  6. data/Gemfile.lock +73 -476
  7. data/README.md +2 -26
  8. data/Rakefile +7 -2
  9. data/app/assets/javascripts/catarse_moip/moip_form.js +80 -0
  10. data/app/assets/javascripts/catarse_moip/payment_account.js +37 -0
  11. data/app/assets/javascripts/catarse_moip/payment_card.js +89 -0
  12. data/app/assets/javascripts/catarse_moip/payment_choice.js +19 -0
  13. data/app/assets/javascripts/catarse_moip/payment_slip.js +35 -0
  14. data/app/assets/javascripts/catarse_moip/user_document.js +111 -0
  15. data/app/assets/javascripts/catarse_moip.js +7 -0
  16. data/app/controllers/catarse_moip/moip_controller.rb +126 -0
  17. data/app/views/catarse_moip/moip/review.html.slim +105 -0
  18. data/catarse_moip.gemspec +5 -5
  19. data/config/initializers/moip.rb +4 -7
  20. data/config/initializers/register.rb +5 -0
  21. data/config/locales/en.yml +2 -0
  22. data/config/locales/pt.yml +19 -0
  23. data/config/routes.rb +9 -5
  24. data/lib/catarse_moip/engine.rb +7 -0
  25. data/lib/catarse_moip/version.rb +1 -1
  26. data/lib/catarse_moip.rb +1 -1
  27. data/lib/moip_transparente/checkout.rb +218 -0
  28. data/lib/moip_transparente/version.rb +3 -0
  29. data/lib/moip_transparente.rb +32 -0
  30. data/spec/controllers/catarse_moip/moip_controller_spec.rb +230 -0
  31. data/spec/fixtures/ipn_data.txt +1 -0
  32. data/spec/javascripts/moip_form_spec.js +25 -0
  33. data/spec/javascripts/support/app.js +1 -0
  34. data/spec/javascripts/support/backbone.js +1571 -0
  35. data/spec/javascripts/support/jquery.js +8829 -0
  36. data/spec/javascripts/support/skull.js +64 -0
  37. data/spec/javascripts/support/underscore.js +1227 -0
  38. data/spec/spec_helper.rb +2 -23
  39. data/spec/support/payment_engines.rb +3 -0
  40. data/test/dummy/README.rdoc +261 -0
  41. data/test/dummy/Rakefile +7 -0
  42. data/test/dummy/app/assets/javascripts/application.js +15 -0
  43. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  44. data/test/dummy/app/controllers/application_controller.rb +3 -0
  45. data/test/dummy/app/helpers/application_helper.rb +2 -0
  46. data/test/dummy/app/mailers/.gitkeep +0 -0
  47. data/test/dummy/app/models/.gitkeep +0 -0
  48. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  49. data/test/dummy/config/application.rb +59 -0
  50. data/test/dummy/config/boot.rb +10 -0
  51. data/test/dummy/config/database.yml +50 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +37 -0
  54. data/test/dummy/config/environments/production.rb +67 -0
  55. data/test/dummy/config/environments/test.rb +37 -0
  56. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  57. data/test/dummy/config/initializers/inflections.rb +15 -0
  58. data/test/dummy/config/initializers/mime_types.rb +5 -0
  59. data/test/dummy/config/initializers/secret_token.rb +7 -0
  60. data/test/dummy/config/initializers/session_store.rb +8 -0
  61. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/test/dummy/config/locales/en.yml +5 -0
  63. data/test/dummy/config/routes.rb +4 -0
  64. data/test/dummy/config.ru +4 -0
  65. data/test/dummy/lib/assets/.gitkeep +0 -0
  66. data/test/dummy/log/.gitkeep +0 -0
  67. data/test/dummy/public/404.html +26 -0
  68. data/test/dummy/public/422.html +26 -0
  69. data/test/dummy/public/500.html +25 -0
  70. data/test/dummy/public/favicon.ico +0 -0
  71. data/test/dummy/script/rails +6 -0
  72. metadata +120 -35
  73. data/.gitmodules +0 -3
  74. data/app/controllers/catarse_moip/payment/moip_controller.rb +0 -49
  75. data/spec/controllers/catarse_moip/payment/moip_controller_spec.rb +0 -81
@@ -0,0 +1,15 @@
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
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -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 = '21c461065b81f8bee3308c8773a98feacd4ea509c775b99e402b8bb08bdfc10334b69e2a19ce26ee8b053287947887e6d30b2ac53601fec09db1108d50b34182'
@@ -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,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do
2
+
3
+ mount CatarseMoip::Engine => "/catarse_moip"
4
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
File without changes
File without changes
@@ -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,25 @@
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
+ </div>
24
+ </body>
25
+ </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'
metadata CHANGED
@@ -1,147 +1,232 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catarse_moip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Antônio Roberto Silva
8
+ - Diogo Biazus
9
+ - Josemar Davi Luedke
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-08-14 00:00:00.000000000 Z
13
+ date: 2013-08-15 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rails
16
17
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 3.2.6
21
+ version: 3.2.12
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- version: 3.2.6
28
+ version: 3.2.12
30
29
  - !ruby/object:Gem::Dependency
31
- name: moip_catarse
30
+ name: libxml-ruby
32
31
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
32
  requirements:
35
33
  - - ~>
36
34
  - !ruby/object:Gem::Version
37
- version: 1.0.6
35
+ version: 2.6.0
38
36
  type: :runtime
39
37
  prerelease: false
40
38
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
39
  requirements:
43
40
  - - ~>
44
41
  - !ruby/object:Gem::Version
45
- version: 1.0.6
42
+ version: 2.6.0
46
43
  - !ruby/object:Gem::Dependency
47
44
  name: rspec-rails
48
45
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
46
  requirements:
51
- - - ! '>='
47
+ - - '>='
52
48
  - !ruby/object:Gem::Version
53
49
  version: '0'
54
50
  type: :development
55
51
  prerelease: false
56
52
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
53
  requirements:
59
- - - ! '>='
54
+ - - '>='
60
55
  - !ruby/object:Gem::Version
61
56
  version: '0'
62
57
  - !ruby/object:Gem::Dependency
63
58
  name: factory_girl_rails
64
59
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
60
  requirements:
67
- - - ! '>='
61
+ - - '>='
68
62
  - !ruby/object:Gem::Version
69
63
  version: '0'
70
64
  type: :development
71
65
  prerelease: false
72
66
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
67
  requirements:
75
- - - ! '>='
68
+ - - '>='
76
69
  - !ruby/object:Gem::Version
77
70
  version: '0'
78
71
  - !ruby/object:Gem::Dependency
79
72
  name: database_cleaner
80
73
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
74
  requirements:
83
- - - ! '>='
75
+ - - '>='
84
76
  - !ruby/object:Gem::Version
85
77
  version: '0'
86
78
  type: :development
87
79
  prerelease: false
88
80
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
81
  requirements:
91
- - - ! '>='
82
+ - - '>='
92
83
  - !ruby/object:Gem::Version
93
84
  version: '0'
94
85
  description: MoIP integration with Catarse crowdfunding platform
95
86
  email:
96
87
  - forevertonny@gmail.com
88
+ - diogob@gmail.com
89
+ - josemarluedke@gmail.com
97
90
  executables: []
98
91
  extensions: []
99
92
  extra_rdoc_files: []
100
93
  files:
101
94
  - .gitignore
102
- - .gitmodules
95
+ - .rspec
96
+ - .travis.yml
103
97
  - Gemfile
104
98
  - Gemfile.lock
105
99
  - MIT-LICENSE
106
100
  - README.md
107
101
  - Rakefile
108
- - app/controllers/catarse_moip/payment/moip_controller.rb
102
+ - app/assets/javascripts/catarse_moip.js
103
+ - app/assets/javascripts/catarse_moip/moip_form.js
104
+ - app/assets/javascripts/catarse_moip/payment_account.js
105
+ - app/assets/javascripts/catarse_moip/payment_card.js
106
+ - app/assets/javascripts/catarse_moip/payment_choice.js
107
+ - app/assets/javascripts/catarse_moip/payment_slip.js
108
+ - app/assets/javascripts/catarse_moip/user_document.js
109
+ - app/controllers/catarse_moip/moip_controller.rb
110
+ - app/views/catarse_moip/moip/review.html.slim
109
111
  - catarse_moip.gemspec
110
112
  - config/initializers/moip.rb
113
+ - config/initializers/register.rb
111
114
  - config/locales/en.yml
112
115
  - config/locales/pt.yml
113
116
  - config/routes.rb
114
117
  - lib/catarse_moip.rb
115
118
  - lib/catarse_moip/engine.rb
116
119
  - lib/catarse_moip/version.rb
120
+ - lib/moip_transparente.rb
121
+ - lib/moip_transparente/checkout.rb
122
+ - lib/moip_transparente/version.rb
117
123
  - lib/tasks/catarse_moip_tasks.rake
118
124
  - script/rails
119
- - spec/controllers/catarse_moip/payment/moip_controller_spec.rb
125
+ - spec/controllers/catarse_moip/moip_controller_spec.rb
126
+ - spec/fixtures/ipn_data.txt
127
+ - spec/javascripts/moip_form_spec.js
128
+ - spec/javascripts/support/app.js
129
+ - spec/javascripts/support/backbone.js
130
+ - spec/javascripts/support/jquery.js
131
+ - spec/javascripts/support/skull.js
132
+ - spec/javascripts/support/underscore.js
120
133
  - spec/spec_helper.rb
121
- homepage: http://github.com/devton/catarse_moip
134
+ - spec/support/payment_engines.rb
135
+ - test/dummy/README.rdoc
136
+ - test/dummy/Rakefile
137
+ - test/dummy/app/assets/javascripts/application.js
138
+ - test/dummy/app/assets/stylesheets/application.css
139
+ - test/dummy/app/controllers/application_controller.rb
140
+ - test/dummy/app/helpers/application_helper.rb
141
+ - test/dummy/app/mailers/.gitkeep
142
+ - test/dummy/app/models/.gitkeep
143
+ - test/dummy/app/views/layouts/application.html.erb
144
+ - test/dummy/config.ru
145
+ - test/dummy/config/application.rb
146
+ - test/dummy/config/boot.rb
147
+ - test/dummy/config/database.yml
148
+ - test/dummy/config/environment.rb
149
+ - test/dummy/config/environments/development.rb
150
+ - test/dummy/config/environments/production.rb
151
+ - test/dummy/config/environments/test.rb
152
+ - test/dummy/config/initializers/backtrace_silencers.rb
153
+ - test/dummy/config/initializers/inflections.rb
154
+ - test/dummy/config/initializers/mime_types.rb
155
+ - test/dummy/config/initializers/secret_token.rb
156
+ - test/dummy/config/initializers/session_store.rb
157
+ - test/dummy/config/initializers/wrap_parameters.rb
158
+ - test/dummy/config/locales/en.yml
159
+ - test/dummy/config/routes.rb
160
+ - test/dummy/lib/assets/.gitkeep
161
+ - test/dummy/log/.gitkeep
162
+ - test/dummy/public/404.html
163
+ - test/dummy/public/422.html
164
+ - test/dummy/public/500.html
165
+ - test/dummy/public/favicon.ico
166
+ - test/dummy/script/rails
167
+ homepage: http://github.com/catarse/catarse_moip
122
168
  licenses: []
169
+ metadata: {}
123
170
  post_install_message:
124
171
  rdoc_options: []
125
172
  require_paths:
126
173
  - lib
127
174
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
175
  requirements:
130
- - - ! '>='
176
+ - - '>='
131
177
  - !ruby/object:Gem::Version
132
178
  version: '0'
133
179
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
180
  requirements:
136
- - - ! '>='
181
+ - - '>='
137
182
  - !ruby/object:Gem::Version
138
183
  version: '0'
139
184
  requirements: []
140
185
  rubyforge_project:
141
- rubygems_version: 1.8.21
186
+ rubygems_version: 2.0.3
142
187
  signing_key:
143
- specification_version: 3
188
+ specification_version: 4
144
189
  summary: MoIP integration with Catarse
145
190
  test_files:
146
- - spec/controllers/catarse_moip/payment/moip_controller_spec.rb
191
+ - spec/controllers/catarse_moip/moip_controller_spec.rb
192
+ - spec/fixtures/ipn_data.txt
193
+ - spec/javascripts/moip_form_spec.js
194
+ - spec/javascripts/support/app.js
195
+ - spec/javascripts/support/backbone.js
196
+ - spec/javascripts/support/jquery.js
197
+ - spec/javascripts/support/skull.js
198
+ - spec/javascripts/support/underscore.js
147
199
  - spec/spec_helper.rb
200
+ - spec/support/payment_engines.rb
201
+ - test/dummy/README.rdoc
202
+ - test/dummy/Rakefile
203
+ - test/dummy/app/assets/javascripts/application.js
204
+ - test/dummy/app/assets/stylesheets/application.css
205
+ - test/dummy/app/controllers/application_controller.rb
206
+ - test/dummy/app/helpers/application_helper.rb
207
+ - test/dummy/app/mailers/.gitkeep
208
+ - test/dummy/app/models/.gitkeep
209
+ - test/dummy/app/views/layouts/application.html.erb
210
+ - test/dummy/config.ru
211
+ - test/dummy/config/application.rb
212
+ - test/dummy/config/boot.rb
213
+ - test/dummy/config/database.yml
214
+ - test/dummy/config/environment.rb
215
+ - test/dummy/config/environments/development.rb
216
+ - test/dummy/config/environments/production.rb
217
+ - test/dummy/config/environments/test.rb
218
+ - test/dummy/config/initializers/backtrace_silencers.rb
219
+ - test/dummy/config/initializers/inflections.rb
220
+ - test/dummy/config/initializers/mime_types.rb
221
+ - test/dummy/config/initializers/secret_token.rb
222
+ - test/dummy/config/initializers/session_store.rb
223
+ - test/dummy/config/initializers/wrap_parameters.rb
224
+ - test/dummy/config/locales/en.yml
225
+ - test/dummy/config/routes.rb
226
+ - test/dummy/lib/assets/.gitkeep
227
+ - test/dummy/log/.gitkeep
228
+ - test/dummy/public/404.html
229
+ - test/dummy/public/422.html
230
+ - test/dummy/public/500.html
231
+ - test/dummy/public/favicon.ico
232
+ - test/dummy/script/rails
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "test/dummy"]
2
- path = test/dummy
3
- url = git://github.com/danielweinmann/catarse.git
@@ -1,49 +0,0 @@
1
- module CatarseMoip::Payment
2
- class MoipController < ApplicationController
3
- def pay
4
- @backer = current_user.backs.not_confirmed.find params[:id]
5
- begin
6
- response = MoIP::Client.checkout(payment_info)
7
- @backer.update_attribute :payment_token, response["Token"]
8
- session[:_payment_token] = response["Token"]
9
-
10
- redirect_to MoIP::Client.moip_page(response["Token"])
11
- rescue Exception => e
12
- Airbrake.notify({ :error_class => "Checkout MOIP Error", :error_message => "MOIP Error: #{e.inspect}", :parameters => params}) rescue nil
13
- Rails.logger.info "-----> #{e.inspect}"
14
- flash[:failure] = t('projects.backers.checkout.moip_error')
15
- return redirect_to main_app.new_project_backer_path(@backer.project)
16
- end
17
- end
18
-
19
- protected
20
-
21
- def payer_info
22
- {
23
- nome: current_user.full_name,
24
- email: current_user.email,
25
- logradouro: current_user.address_street,
26
- numero: current_user.address_number,
27
- complemento: current_user.address_complement,
28
- bairro: current_user.address_neighbourhood,
29
- cidade: current_user.address_city,
30
- estado: current_user.address_state,
31
- pais: 'BRA',
32
- cep: current_user.address_zip_code,
33
- tel_fixo: current_user.phone_number
34
- }
35
- end
36
-
37
- def payment_info
38
- {
39
- valor: "%0.0f" % (@backer.value),
40
- id_proprio: @backer.key,
41
- razao: "Apoio para o projeto '#{@backer.project.name}'",
42
- forma: "BoletoBancario",
43
- dias_expiracao: 2,
44
- pagador: payer_info,
45
- url_retorno: main_app.thank_you_url
46
- }
47
- end
48
- end
49
- end
@@ -1,81 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CatarseMoip::Payment::MoipController do
4
- context 'after user submit the review form' do
5
- let(:current_user) { Factory(:user, :full_name => 'Lorem Ipsum',
6
- :email => 'lorem@lorem.com',
7
- :address_zip_code => '33600-999',
8
- :address_street => 'R. Ipsum',
9
- :address_number => '666',
10
- :address_complement => 'House',
11
- :address_city => 'Some City',
12
- :address_state => 'LP',
13
- :phone_number => '(90) 9999-9999') }
14
-
15
- context 'found some errors' do
16
- it 'should raise a error when current_user is not present' do
17
- lambda {
18
- post :pay, { id: 10, locale: 'en', use_route: 'catarse_moip' }
19
- }.should raise_exception
20
- end
21
-
22
- it 'when backer already confirmed, should raise a not found' do
23
- sign_in(current_user)
24
- backer = Factory(:backer, confirmed: true, user: current_user)
25
-
26
- lambda {
27
- post :pay, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
28
- }.should raise_exception ActiveRecord::RecordNotFound
29
- end
30
-
31
- it 'when backer not belongs to current_user, should raise a not found' do
32
- sign_in(current_user)
33
- backer = Factory(:backer)
34
-
35
- lambda {
36
- post :pay, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
37
- }.should raise_exception ActiveRecord::RecordNotFound
38
- end
39
- end
40
-
41
- context 'throught moip' do
42
- context 'when raise something' do
43
- before do
44
- MoIP::Client.stub(:checkout).and_raise(StandardError)
45
- end
46
-
47
- it 'should handle the error and redirect' do
48
- sign_in(current_user)
49
- backer = Factory(:backer, confirmed: false, user: current_user)
50
-
51
- post :pay, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
52
- backer.reload
53
-
54
- backer.payment_token.should be_nil
55
- flash[:failure].should == I18n.t('projects.backers.checkout.moip_error')
56
- response.should be_redirect
57
- end
58
- end
59
-
60
- context 'without error' do
61
- before do
62
- MoIP::Client.stub(:checkout).and_return({'Token' => 'ABCD'})
63
- end
64
-
65
- it 'should redirect to moip, setup session payment_token and update backer with token' do
66
- sign_in(current_user)
67
- backer = Factory(:backer, confirmed: false, user: current_user)
68
-
69
- post :pay, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
70
- backer.reload
71
-
72
- backer.payment_token.should == 'ABCD'
73
- session[:_payment_token].should == 'ABCD'
74
-
75
- response.should redirect_to("https://www.moip.com.br/Instrucao.do?token=ABCD")
76
- end
77
- end
78
- end
79
-
80
- end
81
- end