money-rails 1.15.0 → 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -6
- data/LICENSE +1 -1
- data/README.md +121 -102
- data/config/locales/money.pt.yml +4 -0
- data/lib/money-rails/active_job/money_serializer.rb +19 -0
- data/lib/money-rails/active_record/monetizable.rb +17 -7
- data/lib/money-rails/configuration.rb +2 -2
- data/lib/money-rails/helpers/action_view_extension.rb +1 -1
- data/lib/money-rails/hooks.rb +11 -0
- data/lib/money-rails/version.rb +3 -1
- data/money-rails.gemspec +13 -26
- metadata +16 -225
- data/Rakefile +0 -84
- data/spec/active_record/migration_extensions/schema_statements_spec.rb +0 -101
- data/spec/active_record/migration_extensions/table_spec.rb +0 -104
- data/spec/active_record/monetizable_spec.rb +0 -1062
- data/spec/configuration_spec.rb +0 -147
- data/spec/dummy/README.rdoc +0 -261
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -15
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/controllers/application_controller.rb +0 -3
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/dummy_product.rb +0 -8
- data/spec/dummy/app/models/priceable.rb +0 -8
- data/spec/dummy/app/models/product.rb +0 -59
- data/spec/dummy/app/models/service.rb +0 -5
- data/spec/dummy/app/models/transaction.rb +0 -13
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -66
- data/spec/dummy/config/boot.rb +0 -13
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -30
- data/spec/dummy/config/environments/production.rb +0 -69
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/money.rb +0 -31
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en-GB.yml +0 -11
- data/spec/dummy/config/locales/en-US.yml +0 -5
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/locales/it.yml +0 -11
- data/spec/dummy/config/mongoid.yml +0 -29
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20120331190108_create_products.rb +0 -10
- data/spec/dummy/db/migrate/20120402080348_add_bonus_cents_to_product.rb +0 -6
- data/spec/dummy/db/migrate/20120524052716_create_services.rb +0 -10
- data/spec/dummy/db/migrate/20120528181002_create_transactions.rb +0 -11
- data/spec/dummy/db/migrate/20120528210103_create_dummy_products.rb +0 -10
- data/spec/dummy/db/migrate/20120607210247_add_column_that_allows_nil.rb +0 -5
- data/spec/dummy/db/migrate/20120712202655_add_sale_price_cents_to_product.rb +0 -7
- data/spec/dummy/db/migrate/20130124023419_add_price_in_a_range_cents_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20140110194016_add_validates_method_amount_cents_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20141005075025_add_aliased_attr_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20150107061030_add_delivery_fee_cents_and_restock_fee_cents_to_product.rb +0 -6
- data/spec/dummy/db/migrate/20150126231442_add_reduced_price_to_products.rb +0 -6
- data/spec/dummy/db/migrate/20150213234410_add_special_price_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20150217222612_add_lambda_price_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20150303222230_add_skip_validation_price_cents_to_products.rb +0 -5
- data/spec/dummy/db/migrate/20151026220420_add_optional_amount_to_transactions.rb +0 -5
- data/spec/dummy/db/schema.rb +0 -59
- data/spec/dummy/db/structure.sql +0 -21
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -25
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +0 -6
- data/spec/helpers/action_view_extension_spec.rb +0 -189
- data/spec/helpers/form_helper_spec.rb +0 -19
- data/spec/money_spec.rb +0 -40
- data/spec/mongoid/mongoid_spec.rb +0 -130
- data/spec/mongoid/two_spec.rb +0 -80
- data/spec/spec_helper.rb +0 -23
- data/spec/support/database_cleaner.rb +0 -14
- data/spec/test_helpers_spec.rb +0 -72
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
class Item < ActiveRecord::Base; end
|
|
4
|
-
|
|
5
|
-
if defined? ActiveRecord
|
|
6
|
-
describe MoneyRails::ActiveRecord::MigrationExtensions::SchemaStatements do
|
|
7
|
-
before :all do
|
|
8
|
-
@connection = ActiveRecord::Base.connection
|
|
9
|
-
@connection.send :extend, MoneyRails::ActiveRecord::MigrationExtensions::SchemaStatements
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe 'money' do
|
|
13
|
-
before do
|
|
14
|
-
@connection.drop_table :items if @connection.table_exists? :items
|
|
15
|
-
@connection.create_table :items do |t|
|
|
16
|
-
t.money :price
|
|
17
|
-
t.money :price_without_currency, currency: { present: false }
|
|
18
|
-
t.money :price_with_full_options, amount: {
|
|
19
|
-
prefix: :prefix_,
|
|
20
|
-
postfix: :_postfix,
|
|
21
|
-
type: :decimal,
|
|
22
|
-
precision: 4,
|
|
23
|
-
scale: 2,
|
|
24
|
-
default: 1,
|
|
25
|
-
null: true
|
|
26
|
-
}, currency: {
|
|
27
|
-
prefix: :currency_prefix,
|
|
28
|
-
postfix: :currency_postfix,
|
|
29
|
-
column_name: :currency
|
|
30
|
-
}
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
Item.reset_column_information
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'default options' do
|
|
37
|
-
describe 'amount' do
|
|
38
|
-
subject { Item.columns_hash['price_cents'] }
|
|
39
|
-
|
|
40
|
-
it { expect(subject.default.to_i).to eq(0) }
|
|
41
|
-
it { expect(Item.new.public_send(subject.name)).to eq(0) }
|
|
42
|
-
it { expect(subject.null).to be(false) }
|
|
43
|
-
it { expect(subject.type).to eq(:integer) }
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
describe 'currency' do
|
|
47
|
-
subject { Item.columns_hash['price_currency'] }
|
|
48
|
-
|
|
49
|
-
# set in spec/dummy/config/initializers/money.rb
|
|
50
|
-
it { expect(subject.default).to eq('EUR') }
|
|
51
|
-
|
|
52
|
-
it { expect(subject.null).to be(false) }
|
|
53
|
-
it { expect(subject.type).to eq(:string) }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context 'without currency column' do
|
|
58
|
-
it { expect(Item.columns_hash['price_without_currency_cents']).not_to be nil }
|
|
59
|
-
it { expect(Item.columns_hash['price_without_currency_currency']).to be nil }
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context 'full options' do
|
|
63
|
-
describe 'amount' do
|
|
64
|
-
subject { Item.columns_hash['prefix_price_with_full_options_postfix'] }
|
|
65
|
-
|
|
66
|
-
it { expect(subject.default.to_i).to eq(1) }
|
|
67
|
-
it { expect(Item.new.public_send(subject.name)).to eq(1) }
|
|
68
|
-
it { expect(subject.null).to be(true) }
|
|
69
|
-
it { expect(subject.type).to eq(:decimal) }
|
|
70
|
-
it { expect(subject.precision).to eq(4) }
|
|
71
|
-
it { expect(subject.scale).to eq(2) }
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe 'currency' do
|
|
75
|
-
it { expect(Item.columns_hash['currency']).not_to be nil }
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
describe 'remove_money' do
|
|
81
|
-
before do
|
|
82
|
-
@connection.change_table :items do |t|
|
|
83
|
-
t.money :price
|
|
84
|
-
t.money :price_without_currency, currency: { present: false }
|
|
85
|
-
t.money :price_with_full_options, amount: { prefix: :prefix_, postfix: :_postfix }, currency: { column_name: :currency }
|
|
86
|
-
|
|
87
|
-
t.remove_money :price
|
|
88
|
-
t.remove_money :price_without_currency, currency: { present: false }
|
|
89
|
-
t.remove_money :price_with_full_options, amount: { prefix: :prefix_, postfix: :_postfix }, currency: { column_name: :currency }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
Item.reset_column_information
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it { expect(Item.columns_hash['price_cents']).to be nil }
|
|
96
|
-
it { expect(Item.columns_hash['price_currency']).to be nil }
|
|
97
|
-
|
|
98
|
-
it { expect(Item.columns_hash['price_without_currency_cents']).to be nil }
|
|
99
|
-
|
|
100
|
-
it { expect(Item.columns_hash['prefix_price_with_full_options_postfix']).to be nil }
|
|
101
|
-
it { expect(Item.columns_hash['currency']).to be nil }
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|