bitcoin_active_record 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +45 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.md +121 -0
  6. data/Rakefile +4 -0
  7. data/bitcoin_active_record.gemspec +15 -0
  8. data/lib/bitcoin_active_record/client.rb +128 -0
  9. data/lib/bitcoin_active_record/models/btc_address.rb +12 -0
  10. data/lib/bitcoin_active_record/models/payment.rb +18 -0
  11. data/lib/bitcoin_active_record/models/received_payment.rb +11 -0
  12. data/lib/bitcoin_active_record/models/sent_payment.rb +10 -0
  13. data/lib/bitcoin_active_record/models.rb +9 -0
  14. data/lib/bitcoin_active_record.rb +24 -0
  15. data/lib/generators/bitcoin_active_record/install_generator.rb +26 -0
  16. data/lib/generators/templates/create_bitcoin_active_record_models.rb +32 -0
  17. data/lib/generators/templates/models/btc_address.rb +3 -0
  18. data/lib/generators/templates/models/payment.rb +3 -0
  19. data/lib/generators/templates/models/received_payment.rb +3 -0
  20. data/lib/generators/templates/models/sent_payment.rb +3 -0
  21. data/test/.gitignore +18 -0
  22. data/test/Gemfile +20 -0
  23. data/test/Gemfile.lock +146 -0
  24. data/test/README.rdoc +28 -0
  25. data/test/Rakefile +6 -0
  26. data/test/app/assets/images/.keep +0 -0
  27. data/test/app/assets/javascripts/application.js +16 -0
  28. data/test/app/assets/stylesheets/application.css +13 -0
  29. data/test/app/controllers/application_controller.rb +5 -0
  30. data/test/app/controllers/concerns/.keep +0 -0
  31. data/test/app/helpers/application_helper.rb +2 -0
  32. data/test/app/mailers/.keep +0 -0
  33. data/test/app/models/.keep +0 -0
  34. data/test/app/models/btc_address.rb +3 -0
  35. data/test/app/models/concerns/.keep +0 -0
  36. data/test/app/models/payment.rb +3 -0
  37. data/test/app/models/received_payment.rb +3 -0
  38. data/test/app/models/sent_payment.rb +3 -0
  39. data/test/app/views/layouts/application.html.erb +14 -0
  40. data/test/bin/bundle +3 -0
  41. data/test/bin/rails +8 -0
  42. data/test/bin/rake +8 -0
  43. data/test/bin/spring +15 -0
  44. data/test/bin/testunit +7 -0
  45. data/test/config/application.rb +23 -0
  46. data/test/config/boot.rb +4 -0
  47. data/test/config/database.yml +25 -0
  48. data/test/config/environment.rb +5 -0
  49. data/test/config/environments/development.rb +29 -0
  50. data/test/config/environments/production.rb +80 -0
  51. data/test/config/environments/test.rb +38 -0
  52. data/test/config/initializers/backtrace_silencers.rb +7 -0
  53. data/test/config/initializers/bitcoin_active_record.rb.example +5 -0
  54. data/test/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/test/config/initializers/inflections.rb +16 -0
  56. data/test/config/initializers/mime_types.rb +5 -0
  57. data/test/config/initializers/secret_token.rb +12 -0
  58. data/test/config/initializers/session_store.rb +3 -0
  59. data/test/config/initializers/wrap_parameters.rb +14 -0
  60. data/test/config/locales/en.yml +23 -0
  61. data/test/config/routes.rb +56 -0
  62. data/test/config.ru +4 -0
  63. data/test/db/migrate/20150425185338_create_bitcoin_active_record_models.rb +32 -0
  64. data/test/db/schema.rb +53 -0
  65. data/test/db/seeds.rb +7 -0
  66. data/test/lib/assets/.keep +0 -0
  67. data/test/lib/tasks/.keep +0 -0
  68. data/test/log/.keep +0 -0
  69. data/test/public/404.html +58 -0
  70. data/test/public/422.html +58 -0
  71. data/test/public/500.html +57 -0
  72. data/test/public/favicon.ico +0 -0
  73. data/test/public/robots.txt +5 -0
  74. data/test/test/controllers/.keep +0 -0
  75. data/test/test/fixtures/.keep +0 -0
  76. data/test/test/helpers/.keep +0 -0
  77. data/test/test/integration/.keep +0 -0
  78. data/test/test/integration/bitcoin_payments/client_test.rb +118 -0
  79. data/test/test/integration/bitcoin_payments/generators_test.rb +39 -0
  80. data/test/test/mailers/.keep +0 -0
  81. data/test/test/models/.keep +0 -0
  82. data/test/test/test_helper.rb +18 -0
  83. data/test/vendor/assets/javascripts/.keep +0 -0
  84. data/test/vendor/assets/stylesheets/.keep +0 -0
  85. metadata +230 -0
@@ -0,0 +1,56 @@
1
+ BitcoinActiveRecordApp::Application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
data/test/config.ru ADDED
@@ -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 Rails.application
@@ -0,0 +1,32 @@
1
+ class CreateBitcoinActiveRecordModels < ActiveRecord::Migration
2
+ def change
3
+ create_table "payments" do |t|
4
+ t.integer "btc_address_id", null: false
5
+ t.decimal "amount", null: false
6
+ t.string "txid", null: false
7
+ t.timestamps
8
+ end
9
+ add_index "payments", ["btc_address_id"]
10
+ add_index "payments", ["txid"], unique: true
11
+
12
+ create_table "btc_addresses" do |t|
13
+ t.string "public_key", null: false
14
+ t.timestamps
15
+ end
16
+ add_index "btc_addresses", ["public_key"], unique: true
17
+
18
+ create_table "received_payments" do |t|
19
+ t.integer "payment_id", null: false
20
+ t.integer "btc_address_id", null: false
21
+ t.timestamps
22
+ end
23
+ add_index "received_payments", ["payment_id"], unique: true
24
+ add_index :received_payments, :btc_address_id
25
+
26
+ create_table "sent_payments" do |t|
27
+ t.integer "payment_id", null: false
28
+ t.timestamps
29
+ end
30
+ add_index "sent_payments", ["payment_id"], unique: true
31
+ end
32
+ end
data/test/db/schema.rb ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20150425185338) do
15
+
16
+ create_table "btc_addresses", force: :cascade do |t|
17
+ t.string "public_key", null: false
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ end
21
+
22
+ add_index "btc_addresses", ["public_key"], name: "index_btc_addresses_on_public_key", unique: true
23
+
24
+ create_table "payments", force: :cascade do |t|
25
+ t.integer "btc_address_id", null: false
26
+ t.decimal "amount", null: false
27
+ t.string "txid", null: false
28
+ t.datetime "created_at"
29
+ t.datetime "updated_at"
30
+ end
31
+
32
+ add_index "payments", ["btc_address_id"], name: "index_payments_on_btc_address_id"
33
+ add_index "payments", ["txid"], name: "index_payments_on_txid", unique: true
34
+
35
+ create_table "received_payments", force: :cascade do |t|
36
+ t.integer "payment_id", null: false
37
+ t.integer "btc_address_id", null: false
38
+ t.datetime "created_at"
39
+ t.datetime "updated_at"
40
+ end
41
+
42
+ add_index "received_payments", ["btc_address_id"], name: "index_received_payments_on_btc_address_id"
43
+ add_index "received_payments", ["payment_id"], name: "index_received_payments_on_payment_id", unique: true
44
+
45
+ create_table "sent_payments", force: :cascade do |t|
46
+ t.integer "payment_id", null: false
47
+ t.datetime "created_at"
48
+ t.datetime "updated_at"
49
+ end
50
+
51
+ add_index "sent_payments", ["payment_id"], name: "index_sent_payments_on_payment_id", unique: true
52
+
53
+ end
data/test/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
data/test/log/.keep ADDED
File without changes
@@ -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,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,118 @@
1
+ require 'test_helper'
2
+
3
+ class BitcoinActiveRecordClientTest < ActiveSupport::TestCase
4
+ def setup
5
+ super
6
+ @client = BitcoinActiveRecord::Client.new(
7
+ server: $bitcoin_server_info,
8
+ account: :primary,
9
+ )
10
+ raise 'bitcoin client config error' if @client.request(:getinfo).nil?
11
+ end
12
+
13
+ def assert_one_transaction(txid, transaction_args: {})
14
+ set_default_transaction_count(1)
15
+ transactions = @client.send(:get_received_transactions, transaction_args)
16
+
17
+ assert_equal(txid, transactions[0]['txid'])
18
+ assert_equal(1, transactions.size)
19
+ end
20
+
21
+ def set_default_transaction_count(count)
22
+ @client.instance_variable_set(:@default_transaction_count, count)
23
+ end
24
+
25
+ def test_create_received_payments
26
+ set_default_transaction_count(2)
27
+ @client.account = :test
28
+
29
+ @client.create_received_payments
30
+ received_payments = ReceivedPayment.all.to_a
31
+ assert_equal(3, received_payments.size)
32
+
33
+ [
34
+ {
35
+ sender_key: '15fRQywgNeF2JDVADbMQTE4sftxLAnGfhn',
36
+ amount: '0.001',
37
+ txid: 'e9c55c74670dd51530989fb39d020a9a39c4b3af75dcc6efc770151b680c8366',
38
+ receiver_key: '1AC8jNajH7zYikxRzRKT3otNW72B9qVDFa',
39
+ },
40
+ {
41
+ sender_key: '12rARqgZBz1hHeESvknLn2Wt2cJc9ddp1y',
42
+ amount: '0.001',
43
+ txid: 'ade4cf44b718b4c338f6962f2501a01dd7e203aa2e2df1bdab6383c1599e0aa6',
44
+ receiver_key: '1AC8jNajH7zYikxRzRKT3otNW72B9qVDFa',
45
+ },
46
+ {
47
+ sender_key: '1G1ravYqGnpM68CUhp2ckD9PXkvtYit23f',
48
+ amount: '0.001',
49
+ txid: '1ae4096365baa4164b8a6f19ff32b7bc0761bde1793e50d9949cec753585c696',
50
+ receiver_key: '1AC8jNajH7zYikxRzRKT3otNW72B9qVDFa',
51
+ },
52
+ ].each_with_index do |expected_values, i|
53
+ received_payment = received_payments[i]
54
+ payment = received_payment.payment
55
+
56
+ assert_equal(expected_values[:sender_key], payment.btc_address.public_key)
57
+ assert_equal(BigDecimal.new(expected_values[:amount]), payment.amount)
58
+ assert_equal(expected_values[:txid], payment.txid)
59
+ assert_equal(expected_values[:receiver_key], received_payment.btc_address.public_key)
60
+ end
61
+
62
+ # running again shouldnt do anything
63
+ @client.create_received_payments
64
+ assert_equal(3, ReceivedPayment.count)
65
+ end
66
+
67
+ def test_get_received_transactions
68
+ @client.account = :test
69
+ @client.minimum_amount = BigDecimal.new('0.001')
70
+ # test right order
71
+ transactions = @client.send(:get_received_transactions)
72
+
73
+ assert_equal('e9c55c74670dd51530989fb39d020a9a39c4b3af75dcc6efc770151b680c8366', transactions[0]['txid'])
74
+ assert_equal('ade4cf44b718b4c338f6962f2501a01dd7e203aa2e2df1bdab6383c1599e0aa6', transactions[1]['txid'])
75
+ # if you get one transaction then it should give you the latest first
76
+ assert_one_transaction('e9c55c74670dd51530989fb39d020a9a39c4b3af75dcc6efc770151b680c8366')
77
+ # test pagination
78
+ assert_one_transaction('ade4cf44b718b4c338f6962f2501a01dd7e203aa2e2df1bdab6383c1599e0aa6', transaction_args: { page: 1 })
79
+
80
+ # setting minimum amount should work
81
+ @client.minimum_amount = BigDecimal.new('0.002')
82
+ assert_equal([], @client.send(:get_received_transactions))
83
+ end
84
+
85
+ def test_get_sender_address
86
+ address = @client.get_sender_address('889c90a43a198ea1c851b621172861736007bc5e526024631eb05062a808b81d')
87
+ assert_equal('1DdqT5jdq8smJMS7uoGZL84d566pLAvxsr', address)
88
+ end
89
+
90
+ def test_invalid_request
91
+ exception = assert_raise(BitcoinActiveRecord::ApiError) { @client.request('dog') }
92
+ assert_equal(true, exception.message.include?('Method not found'))
93
+ end
94
+
95
+ def test_payments_disabled_in_test
96
+ exception = assert_raise(RuntimeError) { @client.request('sendtoaddress', 'abcd') }
97
+ assert_equal('payments disabled in test/development', exception.message)
98
+ end
99
+
100
+ def test_pay
101
+ public_key = 'abcd12423324'
102
+ amount = BigDecimal.new(1)
103
+ comment = 'foo'
104
+ txid = 'kjdksfjlk2323'
105
+ @client.expects(:request).with(:sendtoaddress, public_key, amount, comment).returns(txid)
106
+
107
+ sent_payment = @client.pay(public_key: public_key, amount: amount, comment: comment) do |sent_payment|
108
+ assert_equal(false, sent_payment.persisted?)
109
+ end
110
+
111
+ payment = sent_payment.payment
112
+
113
+ assert_equal(true, sent_payment.persisted?)
114
+ assert_equal(public_key, payment.btc_address.public_key)
115
+ assert_equal(amount, payment.amount)
116
+ assert_equal(txid, payment.txid)
117
+ end
118
+ end
@@ -0,0 +1,39 @@
1
+ require 'test_helper'
2
+
3
+ class BitcoinActiveRecordGeneratorsTest < ActiveSupport::TestCase
4
+ def setup
5
+ # backup old files
6
+ @model_files = `ls app/models/*.rb`.split("\n")
7
+ @model_files.each do |filename|
8
+ system("mv #{filename} #{filename}.bak")
9
+ end
10
+
11
+ # run generator
12
+ system('bin/rails g bitcoin_active_record:install')
13
+
14
+ @migration_file = 'db/migrate/' + `ls db/migrate`.split("\n").find_all do |filename|
15
+ filename.include?('create_bitcoin_active_record_models')
16
+ end[0]
17
+ end
18
+
19
+ def test_install_generator
20
+ lambda do
21
+ migration_file_text = "class CreateBitcoinActiveRecordModels < ActiveRecord::Migration\n def change\n create_table \"payments\" do |t|\n t.integer \"btc_address_id\", null: false\n t.decimal \"amount\", null: false\n t.string \"txid\", null: false\n t.timestamps\n end\n add_index \"payments\", [\"btc_address_id\"]\n add_index \"payments\", [\"txid\"], unique: true\n\n create_table \"btc_addresses\" do |t|\n t.string \"public_key\", null: false\n t.timestamps\n end\n add_index \"btc_addresses\", [\"public_key\"], unique: true\n\n create_table \"received_payments\" do |t|\n t.integer \"payment_id\", null: false\n t.integer \"btc_address_id\", null: false\n t.timestamps\n end\n add_index \"received_payments\", [\"payment_id\"], unique: true\n add_index :received_payments, :btc_address_id\n\n create_table \"sent_payments\" do |t|\n t.integer \"payment_id\", null: false\n t.timestamps\n end\n add_index \"sent_payments\", [\"payment_id\"], unique: true\n end\nend\n"
22
+ assert_equal(migration_file_text, File.read(@migration_file))
23
+ end.()
24
+
25
+ %w(btc_address payment received_payment sent_payment).each do |model_name|
26
+ camel_case_model_name = model_name.camelize
27
+ filename = "app/models/#{model_name}.rb"
28
+
29
+ assert_equal("class #{camel_case_model_name} < ActiveRecord::Base\n bitcoin_active_record_model\nend\n", File.read(filename))
30
+ end
31
+ end
32
+
33
+ def teardown
34
+ @model_files.each do |filename|
35
+ system("rm #{filename}") if File.exists?(filename)
36
+ system("mv #{filename}.bak #{filename}")
37
+ end
38
+ end
39
+ end
File without changes
File without changes
@@ -0,0 +1,18 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+ require 'mocha/mini_test'
5
+ require "minitest/reporters"
6
+ Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
7
+
8
+ class ActiveSupport::TestCase
9
+ ActiveRecord::Migration.check_pending!
10
+
11
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
12
+ #
13
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
14
+ # -- they do not yet inherit this setting
15
+ fixtures :all
16
+
17
+ # Add more helper methods to be used by all tests here...
18
+ end
File without changes
File without changes