transactionable 0.1.0

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 (101) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/javascripts/transactionable/add_bank_account.js +45 -0
  6. data/app/assets/javascripts/transactionable/add_credit_card.js +87 -0
  7. data/app/assets/javascripts/transactionable/application.js +12 -0
  8. data/app/assets/stylesheets/transactionable/application.css +13 -0
  9. data/app/controllers/transactionable/application_controller.rb +4 -0
  10. data/app/helpers/transactionable/application_helper.rb +4 -0
  11. data/app/models/transactionable/bank_account.rb +35 -0
  12. data/app/models/transactionable/credit.rb +28 -0
  13. data/app/models/transactionable/credit_card.rb +39 -0
  14. data/app/models/transactionable/debit.rb +28 -0
  15. data/app/models/transactionable/refund.rb +5 -0
  16. data/app/models/transactionable/remote_bank_account.rb +4 -0
  17. data/app/models/transactionable/remote_credit_card.rb +7 -0
  18. data/app/models/transactionable/remote_customer.rb +39 -0
  19. data/app/models/transactionable/remote_entity.rb +42 -0
  20. data/app/models/transactionable/remote_transaction.rb +4 -0
  21. data/app/models/transactionable/reversal.rb +5 -0
  22. data/app/models/transactionable/transaction.rb +25 -0
  23. data/app/views/layouts/transactionable/application.html.erb +14 -0
  24. data/config/routes.rb +2 -0
  25. data/db/migrate/20140108145608_create_transactionable_remote_entities.rb +14 -0
  26. data/db/migrate/20140108182203_create_transactionable_credit_cards.rb +17 -0
  27. data/db/migrate/20140108190511_create_transactionable_transactions.rb +18 -0
  28. data/db/migrate/20140108213120_create_transactionable_bank_accounts.rb +17 -0
  29. data/lib/tasks/transactionable_tasks.rake +4 -0
  30. data/lib/transactionable.rb +9 -0
  31. data/lib/transactionable/acts_as_transactionable.rb +17 -0
  32. data/lib/transactionable/balanced_customer.rb +23 -0
  33. data/lib/transactionable/bank_account_transactionable.rb +23 -0
  34. data/lib/transactionable/credit_card_transactionable.rb +23 -0
  35. data/lib/transactionable/engine.rb +12 -0
  36. data/lib/transactionable/exceptions.rb +6 -0
  37. data/lib/transactionable/version.rb +3 -0
  38. data/spec/dummy/README.rdoc +28 -0
  39. data/spec/dummy/Rakefile +6 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  41. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  42. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  43. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  44. data/spec/dummy/app/models/user.rb +4 -0
  45. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  46. data/spec/dummy/bin/bundle +3 -0
  47. data/spec/dummy/bin/rails +4 -0
  48. data/spec/dummy/bin/rake +4 -0
  49. data/spec/dummy/config.ru +4 -0
  50. data/spec/dummy/config/application.rb +28 -0
  51. data/spec/dummy/config/boot.rb +5 -0
  52. data/spec/dummy/config/database.yml +25 -0
  53. data/spec/dummy/config/environment.rb +5 -0
  54. data/spec/dummy/config/environments/development.rb +29 -0
  55. data/spec/dummy/config/environments/production.rb +80 -0
  56. data/spec/dummy/config/environments/test.rb +36 -0
  57. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  59. data/spec/dummy/config/initializers/inflections.rb +16 -0
  60. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  61. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  62. data/spec/dummy/config/initializers/session_store.rb +3 -0
  63. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  64. data/spec/dummy/config/locales/en.yml +23 -0
  65. data/spec/dummy/config/routes.rb +4 -0
  66. data/spec/dummy/db/development.sqlite3 +0 -0
  67. data/spec/dummy/db/migrate/20140108162102_create_users.rb +8 -0
  68. data/spec/dummy/db/schema.rb +76 -0
  69. data/spec/dummy/db/test.sqlite3 +0 -0
  70. data/spec/dummy/log/development.log +471 -0
  71. data/spec/dummy/log/test.log +2875 -0
  72. data/spec/dummy/public/404.html +58 -0
  73. data/spec/dummy/public/422.html +58 -0
  74. data/spec/dummy/public/500.html +57 -0
  75. data/spec/dummy/public/favicon.ico +0 -0
  76. data/spec/factories/transactionable_credit_cards.rb +15 -0
  77. data/spec/factories/transactionable_debits.rb +6 -0
  78. data/spec/factories/transactionable_refunds.rb +6 -0
  79. data/spec/factories/transactionable_remote_credit_cards.rb +6 -0
  80. data/spec/factories/transactionable_remote_customers.rb +6 -0
  81. data/spec/factories/transactionable_remote_transactions.rb +6 -0
  82. data/spec/integration/acts_as_bank_account_transactionable_spec.rb +24 -0
  83. data/spec/integration/acts_as_credit_card_transactionable_spec.rb +46 -0
  84. data/spec/integration/models/bank_account_spec.rb +0 -0
  85. data/spec/integration/models/credit_card_spec.rb +28 -0
  86. data/spec/integration/models/credit_spec.rb +0 -0
  87. data/spec/integration/models/debit_spec.rb +0 -0
  88. data/spec/lib/transactionable_spec.rb +6 -0
  89. data/spec/models/transactionable/bank_account_spec.rb +7 -0
  90. data/spec/models/transactionable/credit_card_spec.rb +7 -0
  91. data/spec/models/transactionable/credit_spec.rb +7 -0
  92. data/spec/models/transactionable/debit_spec.rb +7 -0
  93. data/spec/models/transactionable/refund_spec.rb +7 -0
  94. data/spec/models/transactionable/remote_bank_account_spec.rb +7 -0
  95. data/spec/models/transactionable/remote_credit_card_spec.rb +7 -0
  96. data/spec/models/transactionable/remote_customer_spec.rb +7 -0
  97. data/spec/models/transactionable/remote_transaction_spec.rb +7 -0
  98. data/spec/models/transactionable/reversal_spec.rb +7 -0
  99. data/spec/models/transactionable/transaction_spec.rb +7 -0
  100. data/spec/spec_helper.rb +40 -0
  101. metadata +319 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,15 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_credit_card, :class => 'CreditCard' do
5
+ credit_cardable_id 1
6
+ credit_cardable_type "MyString"
7
+ name "MyString"
8
+ description "MyString"
9
+ last_four 1
10
+ brand "MyString"
11
+ expiration_month 1
12
+ expiration_year 1
13
+ expiration_date "2014-01-08"
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_debit, :class => 'Debit' do
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_refund, :class => 'Refund' do
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_remote_credit_card, :class => 'RemoteCreditCard' do
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_remote_customer, :class => 'RemoteCustomer' do
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # Read about factories at https://github.com/thoughtbot/factory_girl
2
+
3
+ FactoryGirl.define do
4
+ factory :transactionable_remote_transaction, :class => 'RemoteTransaction' do
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe "#acts_as_bank_account_transactionable" do
4
+ before(:each) { @user = User.create }
5
+
6
+ specify { @user.class.should respond_to :acts_as_bank_account_transactionable }
7
+
8
+ describe "#add_bank_account", :vcr, :marketplace do
9
+ before(:each) do
10
+ @user = User.create
11
+ @balanced_bank_account = Balanced::BankAccount.new(
12
+ name: "Mario",
13
+ account_number: "9900000002",
14
+ routing_number: "021000021",
15
+ type: "checking").save
16
+ @user.add_bank_account(@balanced_bank_account.uri)
17
+ @bank_account = @user.bank_accounts.first
18
+ end
19
+
20
+ specify { @user.bank_accounts.should_not be_blank }
21
+ specify { @bank_account.remote_bank_account.uri.should_not be_blank }
22
+ specify { @bank_account.description.should include "0002" }
23
+ end
24
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe "#acts_as_credit_card_transactionable" do
4
+ before(:each) { @user = User.create }
5
+
6
+ specify { @user.class.should respond_to :acts_as_credit_card_transactionable }
7
+
8
+ describe "#sync_customer", :vcr, :marketplace do
9
+ before(:each) do
10
+ @user = User.create
11
+ @user.sync_customer
12
+ @user.reload
13
+ end
14
+
15
+ specify { @user.remote_customer.should_not be_blank }
16
+ specify { @user.remote_customer.uri.should_not be_blank }
17
+ end
18
+
19
+ describe "#remote", :vcr, :marketplace do
20
+ before(:each) do
21
+ @user = User.create
22
+ @user.sync_customer
23
+ @user.reload
24
+ @remote_customer = @user.remote_customer.fetch
25
+ end
26
+
27
+ specify { @user.remote.should be_instance_of Balanced::Customer }
28
+ specify { @user.remote.attributes.should eql @remote_customer.attributes }
29
+ end
30
+
31
+ describe "#add_credit_card", :vcr, :marketplace do
32
+ before(:each) do
33
+ @user = User.create
34
+ @balanced_card = Balanced::Card.new(
35
+ card_number: '4111111111111111',
36
+ expiration_year: (Date.today+2.years).year,
37
+ expiration_month: '12').save
38
+ @user.add_credit_card(@balanced_card.uri)
39
+ @credit_card = @user.credit_cards.first
40
+ end
41
+
42
+ specify { @user.credit_cards.should_not be_blank }
43
+ specify { @credit_card.remote_credit_card.uri.should_not be_blank }
44
+ specify { @credit_card.last_four.should eql 1111 }
45
+ end
46
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ def setup_user_with_credit_card
4
+ @user = User.create
5
+ @balanced_card = Balanced::Card.new(
6
+ card_number: '4111111111111111',
7
+ expiration_year: (Date.today+2.years).year,
8
+ expiration_month: '12').save
9
+ @user.add_credit_card(@balanced_card.uri)
10
+ end
11
+
12
+ describe "Transactionable::CreditCard" do
13
+ describe "#debit!", :vcr, :marketplace do
14
+ before do
15
+ setup_user_with_credit_card
16
+ @credit_card = @user.credit_cards.first
17
+ @credit_card.debit!(13.37)
18
+ @transaction = @credit_card.transactions.first
19
+ @remote_transaction = @transaction.remote
20
+ end
21
+
22
+ specify { @credit_card.debits.should_not be_blank }
23
+ specify { @credit_card.debits.first.should eql @transaction }
24
+ specify { @transaction.should be_instance_of Transactionable::Debit }
25
+ specify { @remote_transaction.should be_instance_of Balanced::Debit }
26
+ specify { (@transaction.amount*100).should eql @remote_transaction.amount }
27
+ end
28
+ end
File without changes
File without changes
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe Transactionable do
4
+ specify { ActiveRecord::Base.should respond_to(:acts_as_credit_card_transactionable) }
5
+ specify { ActiveRecord::Base.should respond_to(:acts_as_bank_account_transactionable) }
6
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe BankAccount do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe CreditCard do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe Credit do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe Debit do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe Refund do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe RemoteBankAccount do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe RemoteCreditCard do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe RemoteCustomer do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe RemoteTransaction do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe Reversal do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module Transactionable
4
+ describe Transaction do
5
+ pending "add some examples to (or delete) #{__FILE__}"
6
+ end
7
+ end