catarse_credits 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 (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +112 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +3 -0
  7. data/Rakefile +40 -0
  8. data/app/assets/images/catarse_credits/.gitkeep +0 -0
  9. data/app/assets/javascripts/catarse_credits/application.js +15 -0
  10. data/app/assets/stylesheets/catarse_credits/application.css +13 -0
  11. data/app/controllers/catarse_credits/credits_controller.rb +36 -0
  12. data/app/helpers/catarse_credits/application_helper.rb +4 -0
  13. data/app/views/catarse_credits/credits/review.html.slim +16 -0
  14. data/app/views/layouts/catarse_credits/application.html.erb +14 -0
  15. data/catarse_credits.gemspec +25 -0
  16. data/config/initializers/register.rb +6 -0
  17. data/config/routes.rb +8 -0
  18. data/lib/catarse_credits.rb +5 -0
  19. data/lib/catarse_credits/engine.rb +5 -0
  20. data/lib/catarse_credits/payment_engine.rb +22 -0
  21. data/lib/catarse_credits/version.rb +3 -0
  22. data/lib/tasks/catarse_credits_tasks.rake +4 -0
  23. data/script/rails +8 -0
  24. data/spec/controllers/catarse_credits/credits_controller_spec.rb +68 -0
  25. data/spec/dummy/.gitignore +16 -0
  26. data/spec/dummy/Gemfile +40 -0
  27. data/spec/dummy/README.rdoc +28 -0
  28. data/spec/dummy/Rakefile +6 -0
  29. data/spec/dummy/app/assets/images/.keep +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  31. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  32. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  33. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  34. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  35. data/spec/dummy/app/mailers/.keep +0 -0
  36. data/spec/dummy/app/models/.keep +0 -0
  37. data/spec/dummy/app/models/concerns/.keep +0 -0
  38. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  39. data/spec/dummy/bin/bundle +3 -0
  40. data/spec/dummy/bin/rails +4 -0
  41. data/spec/dummy/bin/rake +4 -0
  42. data/spec/dummy/config.ru +4 -0
  43. data/spec/dummy/config/application.rb +23 -0
  44. data/spec/dummy/config/boot.rb +4 -0
  45. data/spec/dummy/config/database.yml +54 -0
  46. data/spec/dummy/config/environment.rb +5 -0
  47. data/spec/dummy/config/environments/development.rb +37 -0
  48. data/spec/dummy/config/environments/production.rb +82 -0
  49. data/spec/dummy/config/environments/test.rb +39 -0
  50. data/spec/dummy/config/initializers/assets.rb +8 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  53. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  54. data/spec/dummy/config/initializers/inflections.rb +16 -0
  55. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  56. data/spec/dummy/config/initializers/session_store.rb +3 -0
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  58. data/spec/dummy/config/locales/en.yml +23 -0
  59. data/spec/dummy/config/routes.rb +57 -0
  60. data/spec/dummy/config/secrets.yml +22 -0
  61. data/spec/dummy/db/seeds.rb +7 -0
  62. data/spec/dummy/lib/assets/.keep +0 -0
  63. data/spec/dummy/lib/tasks/.keep +0 -0
  64. data/spec/dummy/log/.keep +0 -0
  65. data/spec/dummy/public/404.html +67 -0
  66. data/spec/dummy/public/422.html +67 -0
  67. data/spec/dummy/public/500.html +66 -0
  68. data/spec/dummy/public/favicon.ico +0 -0
  69. data/spec/dummy/public/robots.txt +5 -0
  70. data/spec/dummy/test/controllers/.keep +0 -0
  71. data/spec/dummy/test/fixtures/.keep +0 -0
  72. data/spec/dummy/test/helpers/.keep +0 -0
  73. data/spec/dummy/test/integration/.keep +0 -0
  74. data/spec/dummy/test/mailers/.keep +0 -0
  75. data/spec/dummy/test/models/.keep +0 -0
  76. data/spec/dummy/test/test_helper.rb +10 -0
  77. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  78. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  79. data/spec/spec_helper.rb +34 -0
  80. data/spec/support/category.rb +2 -0
  81. data/spec/support/contribution.rb +15 -0
  82. data/spec/support/factories.rb +56 -0
  83. data/spec/support/payment_engines.rb +2 -0
  84. data/spec/support/project.rb +5 -0
  85. data/spec/support/user.rb +9 -0
  86. data/spec/support/user_total.rb +3 -0
  87. metadata +249 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a82c8f4664ad26461b19833160057e42503cf604
4
+ data.tar.gz: 7475489c1a3d18b6aceacc3a38ac51f5625d3752
5
+ SHA512:
6
+ metadata.gz: 6ee24c3d0e98608db84670e127973735cf13222309dc0d9360c5a638bdf7bde262ea8056e11f5d24a3ed6ab005615428d7cc7bfabb1f0b8e488d0ba41dfce76b
7
+ data.tar.gz: ac8bd4afca3b9e25ab04a56dfad276c62304abd6223de6c723d1e824a07fbe8752b4627916f30b6ce5906cf25bf4177ba7e12311f05e44bc6e45d909b2d236db
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ test/dummy/.sass-cache
8
+ spec/dummy/config/database.yml
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ catarse_credits (0.0.1)
5
+ rails (>= 4.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.4)
11
+ actionpack (= 4.1.4)
12
+ actionview (= 4.1.4)
13
+ mail (~> 2.5.4)
14
+ actionpack (4.1.4)
15
+ actionview (= 4.1.4)
16
+ activesupport (= 4.1.4)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.4)
20
+ activesupport (= 4.1.4)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.4)
24
+ activesupport (= 4.1.4)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.4)
27
+ activemodel (= 4.1.4)
28
+ activesupport (= 4.1.4)
29
+ arel (~> 5.0.0)
30
+ activesupport (4.1.4)
31
+ i18n (~> 0.6, >= 0.6.9)
32
+ json (~> 1.7, >= 1.7.7)
33
+ minitest (~> 5.1)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 1.1)
36
+ arel (5.0.1.20140414130214)
37
+ builder (3.2.2)
38
+ diff-lcs (1.2.5)
39
+ erubis (2.7.0)
40
+ factory_girl (4.4.0)
41
+ activesupport (>= 3.0.0)
42
+ factory_girl_rails (4.4.1)
43
+ factory_girl (~> 4.4.0)
44
+ railties (>= 3.0.0)
45
+ hike (1.2.3)
46
+ i18n (0.6.9)
47
+ json (1.8.1)
48
+ mail (2.5.4)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.25.1)
52
+ minitest (5.3.5)
53
+ multi_json (1.10.1)
54
+ pg (0.17.1)
55
+ polyglot (0.3.5)
56
+ rack (1.5.2)
57
+ rack-test (0.6.2)
58
+ rack (>= 1.0)
59
+ rails (4.1.4)
60
+ actionmailer (= 4.1.4)
61
+ actionpack (= 4.1.4)
62
+ actionview (= 4.1.4)
63
+ activemodel (= 4.1.4)
64
+ activerecord (= 4.1.4)
65
+ activesupport (= 4.1.4)
66
+ bundler (>= 1.3.0, < 2.0)
67
+ railties (= 4.1.4)
68
+ sprockets-rails (~> 2.0)
69
+ railties (4.1.4)
70
+ actionpack (= 4.1.4)
71
+ activesupport (= 4.1.4)
72
+ rake (>= 0.8.7)
73
+ thor (>= 0.18.1, < 2.0)
74
+ rake (10.3.2)
75
+ rspec-core (2.14.8)
76
+ rspec-expectations (2.14.5)
77
+ diff-lcs (>= 1.1.3, < 2.0)
78
+ rspec-mocks (2.14.6)
79
+ rspec-rails (2.14.2)
80
+ actionpack (>= 3.0)
81
+ activemodel (>= 3.0)
82
+ activesupport (>= 3.0)
83
+ railties (>= 3.0)
84
+ rspec-core (~> 2.14.0)
85
+ rspec-expectations (~> 2.14.0)
86
+ rspec-mocks (~> 2.14.0)
87
+ sprockets (2.12.1)
88
+ hike (~> 1.2)
89
+ multi_json (~> 1.0)
90
+ rack (~> 1.0)
91
+ tilt (~> 1.1, != 1.3.0)
92
+ sprockets-rails (2.1.3)
93
+ actionpack (>= 3.0)
94
+ activesupport (>= 3.0)
95
+ sprockets (~> 2.8)
96
+ thor (0.19.1)
97
+ thread_safe (0.3.4)
98
+ tilt (1.4.1)
99
+ treetop (1.4.15)
100
+ polyglot
101
+ polyglot (>= 0.3.1)
102
+ tzinfo (1.2.1)
103
+ thread_safe (~> 0.1)
104
+
105
+ PLATFORMS
106
+ ruby
107
+
108
+ DEPENDENCIES
109
+ catarse_credits!
110
+ factory_girl_rails
111
+ pg
112
+ rspec-rails (~> 2.14.0)
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = CatarseCredits
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'CatarseCredits'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
File without changes
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,36 @@
1
+ class CatarseCredits::CreditsController < ApplicationController
2
+ layout :false
3
+ before_action :contribution
4
+
5
+ def review
6
+ end
7
+
8
+ def pay
9
+ if current_user && current_user == contribution.user
10
+ if current_user.credits < contribution.value
11
+ return failed_contribution
12
+ end
13
+
14
+ unless contribution.confirmed?
15
+ contribution.update_attributes({ credits: true, payment_method: 'Credits' })
16
+ contribution.update_current_billing_info
17
+ contribution.confirm!
18
+ end
19
+
20
+ flash[:success] = t('projects.contributions.checkout.success')
21
+ return redirect_to main_app.project_contribution_path(project_id: contribution.project.id, id: contribution.id)
22
+ else
23
+ failed_contribution
24
+ end
25
+ end
26
+
27
+ protected
28
+ def failed_contribution
29
+ flash[:failure] = t('projects.contributions.checkout.no_credits')
30
+ redirect_to main_app.new_project_contribution_path(contribution.project)
31
+ end
32
+
33
+ def contribution
34
+ @contribution ||= PaymentEngines.find_payment(id: params['id'])
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+ module CatarseCredits
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ - if current_user.credits < @contribution.value
2
+ #contribute_with_credits
3
+ .bootstrap-alert
4
+ .alert
5
+ #credits_notice= "Seus creditos não são suficientes para completar esse apoio, por favor escolha outro meio de pagamento."
6
+ - else
7
+ h3 Pagar utilizando creditos
8
+ br/
9
+ p= t('projects.contributions.edit.credits_notice_html', credits: number_to_currency((current_user.credits - @contribution.value), unit: 'R$', precision: 0, delimiter: '.'))
10
+ br/
11
+ .clearfix
12
+ #catarse_credits_form
13
+ = form_tag pay_credit_path(params[:id]) do
14
+ .clearfix
15
+ .bootstrap-twitter
16
+ = submit_tag 'Pagar com creditos', :class => 'btn btn'
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CatarseCredits</title>
5
+ <%= stylesheet_link_tag "catarse_credits/application", :media => "all" %>
6
+ <%= javascript_include_tag "catarse_credits/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "catarse_credits/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "catarse_credits"
9
+ s.version = CatarseCredits::VERSION
10
+ s.authors = ["Antônio Roberto Silva", "Diogo Biazus"]
11
+ s.email = ["forevertonny@gmail.com", "diogob@gmail.com"]
12
+ s.homepage = "http://github.com/catarse/catarse_credits"
13
+ s.summary = "Credits System for catarse"
14
+ s.description = "Credits integration for catarse"
15
+
16
+ s.files = `git ls-files`.split($\)
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ s.add_dependency "rails", ">= 4.0"
20
+
21
+ s.add_development_dependency "rspec-rails", "~> 2.14.0"
22
+ s.add_development_dependency "factory_girl_rails"
23
+ s.add_development_dependency "pg"
24
+
25
+ end
@@ -0,0 +1,6 @@
1
+ begin
2
+ PaymentEngines.register(CatarseCredits::PaymentEngine.new)
3
+ rescue Exception => e
4
+ puts "Error while registering payment engine: #{e}"
5
+ end
6
+
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ CatarseCredits::Engine.routes.draw do
2
+ resources :credits, only: [], path: 'payment/credits' do
3
+ member do
4
+ get :review
5
+ post :pay
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ require "catarse_credits/engine"
2
+ require "catarse_credits/payment_engine"
3
+
4
+ module CatarseCredits
5
+ end
@@ -0,0 +1,5 @@
1
+ module CatarseCredits
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CatarseCredits
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ module CatarseCredits
2
+ class PaymentEngine
3
+
4
+ def name
5
+ 'Credits'
6
+ end
7
+
8
+ def review_path contribution
9
+ CatarseCredits::Engine.routes.url_helpers.review_credit_path(contribution)
10
+ end
11
+
12
+ def can_do_refund?
13
+ false
14
+ end
15
+
16
+ def locale
17
+ 'pt'
18
+ end
19
+
20
+ end
21
+ end
22
+
@@ -0,0 +1,3 @@
1
+ module CatarseCredits
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :catarse_credits do
3
+ # # Task goes here
4
+ # end
data/script/rails ADDED
@@ -0,0 +1,8 @@
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
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/catarse_credits/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe CatarseCredits::CreditsController do
4
+ describe "PUT pay" do
5
+ let(:project) { create(:project) }
6
+ let(:contribution){ create(:contribution, value: 10.00, credits: true, project: project, state: 'pending') }
7
+ let(:user){ nil }
8
+ let(:contribution_info){ { address_city: 'Porto Alegre', address_complement: '24', address_neighbourhood: 'Rio Branco', address_number: '1004', address_phone_number: '(51)2112-8397', address_state: 'RS', address_street: 'Rua Mariante', address_zip_code: '90430-180', payer_email: 'diogo@biazus.me', payer_name: 'Diogo de Oliveira Biazus' } }
9
+ let(:failed_project) { create(:project, state: 'online') }
10
+ let(:main_app) { double() }
11
+
12
+ before do
13
+ PaymentEngines.stub(:find_payment).and_return(contribution)
14
+ controller.stub(:current_user).and_return(user)
15
+ controller.stub(:main_app).and_return(main_app)
16
+ main_app.stub(:new_project_contribution_path).and_return('new_project_contribution_path')
17
+ main_app.stub(:project_contribution_path).and_return('project_contribution_path')
18
+ main_app.stub(:project_contribution_path).and_return('project_contribution_path')
19
+ end
20
+
21
+ context "without user" do
22
+ before do
23
+ post :pay, { locale: :pt, project_id: project.id, id: contribution.id, use_route: 'catarse_credits'}
24
+ end
25
+ it{ should redirect_to(main_app.new_project_contribution_path) }
26
+ end
27
+
28
+ context "when contribution don't exist in current_user" do
29
+ before do
30
+ post :pay, { locale: :pt, project_id: project.id, id: contribution.id, use_route: 'catarse_credits'}
31
+ end
32
+ let(:user){ create(:user) }
33
+ it{ should redirect_to(main_app.new_project_contribution_path) }
34
+ it('should set flash failure'){ expect(controller.flash[:failure]).to be_an_instance_of(String) }
35
+ end
36
+
37
+ context "with correct user but insufficient credits" do
38
+ let(:user){ contribution.user }
39
+
40
+ before do
41
+ contribution.should_not_receive(:confirm!)
42
+ post :pay, { locale: :pt, project_id: project.id, id: contribution.id, use_route: 'catarse_credits'}
43
+ end
44
+
45
+ it('should set flash failure'){ expect(controller.flash[:failure]).to be_an_instance_of(String) }
46
+ it{ should redirect_to(main_app.new_project_contribution_path(project)) }
47
+ end
48
+
49
+ context "with correct user and sufficient credits" do
50
+ let(:user) do
51
+ create(:contribution, value: 10.00, credits: false, state: 'confirmed', user: contribution.user, project: failed_project)
52
+ failed_project.update_attributes state: 'failed'
53
+ contribution.user.reload
54
+ contribution.user
55
+ end
56
+
57
+ before do
58
+ contribution.should_receive(:confirm!)
59
+ contribution.should_receive(:update_attributes).with({credits: true, payment_method: 'Credits'})
60
+ contribution.should_receive(:update_current_billing_info)
61
+ post :pay, { locale: :pt, project_id: project.id, id: contribution.id, use_route: 'catarse_credits'}
62
+ end
63
+
64
+ it('should set flash success'){ expect(controller.flash[:success]).to be_an_instance_of(String) }
65
+ it{ should redirect_to(main_app.project_contribution_path(project_id: project.id, id: contribution.id)) }
66
+ end
67
+ end
68
+ end