money-rails 0.6.0 → 0.7.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +7 -1
- data/config/locales/money.en.yml +5 -0
- data/config/locales/money.es.yml +5 -0
- data/lib/money-rails.rb +1 -0
- data/lib/money-rails/active_model/validator.rb +57 -0
- data/lib/money-rails/active_record/monetizable.rb +35 -3
- data/lib/money-rails/engine.rb +4 -0
- data/lib/money-rails/hooks.rb +1 -0
- data/lib/money-rails/mongoid/three.rb +13 -6
- data/lib/money-rails/mongoid/two.rb +10 -6
- data/lib/money-rails/version.rb +1 -1
- data/money-rails.gemspec +2 -4
- data/spec/active_record/monetizable_spec.rb +85 -2
- data/spec/dummy/log/development.log +44 -186
- data/spec/dummy/log/test.log +2605 -48025
- data/spec/helpers/form_helper_spec.rb +19 -0
- data/spec/mongoid/three_spec.rb +17 -1
- data/spec/mongoid/two_spec.rb +16 -0
- metadata +103 -159
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.7.0 (coming soon)
|
4
|
+
- Added custom validator for Money fields (GH-36)
|
5
|
+
TODO: decouple validator from active_record
|
6
|
+
- Added mongodb service test support for travis CI
|
7
|
+
- Fixed issue with current value assignment in text_field tags (GH-37)
|
8
|
+
- Fixed issue related to symbolized keys in Mongoid (GH-40)
|
9
|
+
|
3
10
|
## 0.6.0
|
4
11
|
- Added basic support for Mongoid >= 3.0.
|
5
12
|
- Allow class methods to be monetized (ActiveRecord only - GH-34)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RubyMoney - Money-Rails
|
1
|
+
# RubyMoney - Money-Rails [![endorse](http://api.coderwall.com/alup/endorsecount.png)](http://coderwall.com/alup)
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/RubyMoney/money-rails.png?branch=master)](http://travis-ci.org/RubyMoney/money-rails)
|
4
4
|
[![Dependency Status](https://gemnasium.com/RubyMoney/money-rails.png)](https://gemnasium.com/RubyMoney/money-rails)
|
@@ -342,6 +342,12 @@ without the cents part.
|
|
342
342
|
* ActiveRecord (>= 3.x)
|
343
343
|
* Mongoid (2.x, 3.x)
|
344
344
|
|
345
|
+
## Supported Ruby interpreters
|
346
|
+
|
347
|
+
* MRI Ruby >= 1.9.2
|
348
|
+
|
349
|
+
You can see a full list of the currently supported interpreters in [travis.yml](http://github.com/RubyMoney/money-rails/blob/master/.travis.yml)
|
350
|
+
|
345
351
|
## Maintainers
|
346
352
|
|
347
353
|
* Andreas Loupasakis (https://github.com/alup)
|
data/lib/money-rails.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
module MoneyRails
|
2
|
+
module ActiveModel
|
3
|
+
class MoneyValidator < ::ActiveModel::Validations::NumericalityValidator
|
4
|
+
def validate_each(record, attr, value)
|
5
|
+
|
6
|
+
# If subunit is not set then no need to validate as it is an
|
7
|
+
# indicator that no assignment has been done onto the virtual
|
8
|
+
# money field.
|
9
|
+
subunit_attr = record.class.monetized_attributes[attr.to_sym]
|
10
|
+
return unless record.changed_attributes.keys.include? subunit_attr
|
11
|
+
|
12
|
+
# WARNING: Currently this is only defined in ActiveRecord extension!
|
13
|
+
before_type_cast = "#{attr}_money_before_type_cast"
|
14
|
+
raw_value = record.send(before_type_cast) if record.respond_to?(before_type_cast.to_sym)
|
15
|
+
|
16
|
+
# Skip it if raw_value is already a Money object
|
17
|
+
return if raw_value.is_a?(Money) || raw_value.nil?
|
18
|
+
|
19
|
+
if !raw_value.blank?
|
20
|
+
# remove currency symbol, and negative sign
|
21
|
+
currency = record.send("currency_for_#{attr}")
|
22
|
+
raw_value = raw_value.to_s.gsub(currency.symbol, "").gsub(/^-/, "")
|
23
|
+
|
24
|
+
decimal_pieces = raw_value.split(currency.decimal_mark)
|
25
|
+
|
26
|
+
# check for numbers like 12.23.45
|
27
|
+
if decimal_pieces.length > 2
|
28
|
+
record.errors.add(attr, I18n.t('errors.messages.invalid_currencym',
|
29
|
+
{ :thousands => currency.thousands_separator,
|
30
|
+
:decimal => currency.decimal_mark }))
|
31
|
+
end
|
32
|
+
|
33
|
+
pieces = decimal_pieces[0].split(currency.thousands_separator)
|
34
|
+
|
35
|
+
# check for valid thousands separation
|
36
|
+
if pieces.length > 1
|
37
|
+
record.errors.add(attr, I18n.t('errors.messages.invalid_currencym',
|
38
|
+
{ :thousands => currency.thousands_separator,
|
39
|
+
:decimal => currency.decimal_mark })) if pieces[0].length > 3
|
40
|
+
(1..pieces.length-1).each do |index|
|
41
|
+
record.errors.add(attr, I18n.t('errors.messages.invalid_currencym',
|
42
|
+
{ :thousands => currency.thousands_separator,
|
43
|
+
:decimal => currency.decimal_mark })) if pieces[index].length != 3
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# remove thousands separators
|
48
|
+
raw_value = raw_value.to_s.gsub(currency.thousands_separator, '')
|
49
|
+
|
50
|
+
# normalize decimal mark
|
51
|
+
raw_value = raw_value.to_s.gsub(currency.decimal_mark, '.')
|
52
|
+
end
|
53
|
+
super(record, attr, raw_value)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -43,11 +43,25 @@ module MoneyRails
|
|
43
43
|
name = subunit_name.sub(/_cents$/, "")
|
44
44
|
else
|
45
45
|
# FIXME: provide a better default
|
46
|
-
name = subunit_name
|
46
|
+
name = [subunit_name, "money"].join("_")
|
47
47
|
end
|
48
48
|
|
49
|
+
# Create a reverse mapping of the monetized attributes
|
50
|
+
@monetized_attributes ||= {}
|
51
|
+
@monetized_attributes[name.to_sym] = subunit_name
|
52
|
+
class << self
|
53
|
+
def monetized_attributes
|
54
|
+
@monetized_attributes || superclass.monetized_attributes
|
55
|
+
end
|
56
|
+
end unless respond_to? :monetized_attributes
|
57
|
+
|
49
58
|
# Include numericality validation if needed
|
50
|
-
|
59
|
+
if MoneyRails.include_validations
|
60
|
+
validates_numericality_of subunit_name, :allow_nil => options[:allow_nil]
|
61
|
+
|
62
|
+
# Allow only Money objects or Numeric values!
|
63
|
+
validates name.to_sym, 'money_rails/active_model/money' => { :allow_nil => options[:allow_nil] }
|
64
|
+
end
|
51
65
|
|
52
66
|
define_method name do |*args|
|
53
67
|
amount = send(subunit_name, *args)
|
@@ -64,10 +78,18 @@ module MoneyRails
|
|
64
78
|
end
|
65
79
|
|
66
80
|
define_method "#{name}=" do |value|
|
81
|
+
|
82
|
+
# Lets keep the before_type_cast value
|
83
|
+
instance_variable_set "@#{name}_money_before_type_cast", value
|
84
|
+
|
67
85
|
if options[:allow_nil] && value.blank?
|
68
86
|
money = nil
|
69
87
|
else
|
70
|
-
|
88
|
+
begin
|
89
|
+
money = value.is_a?(Money) ? value : value.to_money(send("currency_for_#{name}"))
|
90
|
+
rescue NoMethodError
|
91
|
+
return nil
|
92
|
+
end
|
71
93
|
end
|
72
94
|
|
73
95
|
send("#{subunit_name}=", money.try(:cents))
|
@@ -87,6 +109,16 @@ module MoneyRails
|
|
87
109
|
Money.default_currency
|
88
110
|
end
|
89
111
|
end
|
112
|
+
|
113
|
+
define_method "#{name}_money_before_type_cast" do
|
114
|
+
instance_variable_get "@#{name}_money_before_type_cast"
|
115
|
+
end
|
116
|
+
|
117
|
+
# Hook to ensure the reset of before_type_cast attr
|
118
|
+
# TODO: think of a better way to avoid this
|
119
|
+
after_validation do
|
120
|
+
instance_variable_set "@#{name}_money_before_type_cast", nil
|
121
|
+
end
|
90
122
|
end
|
91
123
|
|
92
124
|
def register_currency(currency_name)
|
data/lib/money-rails/hooks.rb
CHANGED
@@ -3,6 +3,7 @@ module MoneyRails
|
|
3
3
|
def self.init
|
4
4
|
# For Active Record
|
5
5
|
ActiveSupport.on_load(:active_record) do
|
6
|
+
require 'money-rails/active_model/validator'
|
6
7
|
require 'money-rails/active_record/monetizable'
|
7
8
|
::ActiveRecord::Base.send :include, MoneyRails::ActiveRecord::Monetizable
|
8
9
|
end
|
@@ -13,17 +13,24 @@ class Money
|
|
13
13
|
# Get the object as it was stored in the database, and instantiate
|
14
14
|
# this custom class from it.
|
15
15
|
def demongoize(object)
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
if object.is_a?(Hash)
|
17
|
+
object = object.symbolize_keys
|
18
|
+
object.has_key?(:cents) ? ::Money.new(object[:cents], object[:currency_iso]) : nil
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
19
22
|
end
|
20
23
|
|
21
24
|
# Takes any possible object and converts it to how it would be
|
22
25
|
# stored in the database.
|
23
26
|
def mongoize(object)
|
24
|
-
case
|
25
|
-
when Money then object.mongoize
|
26
|
-
when Hash then
|
27
|
+
case
|
28
|
+
when object.is_a?(Money) then object.mongoize
|
29
|
+
when object.is_a?(Hash) then
|
30
|
+
object.symbolize_keys!
|
31
|
+
::Money.new(object[:cents], object[:currency]).mongoize
|
32
|
+
when object.respond_to?(:to_money) then
|
33
|
+
object.to_money.mongoize
|
27
34
|
else object
|
28
35
|
end
|
29
36
|
end
|
@@ -15,11 +15,15 @@ class Money
|
|
15
15
|
|
16
16
|
# Money -> Mongo friendly
|
17
17
|
def serialize(object)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
case
|
19
|
+
when object.is_a?(Money)
|
20
|
+
{
|
21
|
+
:cents => object.cents,
|
22
|
+
:currency_iso => object.currency.iso_code
|
23
|
+
}
|
24
|
+
when object.respond_to?(:to_money)
|
25
|
+
serialize(object.to_money)
|
26
|
+
else nil
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
data/lib/money-rails/version.rb
CHANGED
data/money-rails.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = "Money gem integration with Rails"
|
13
13
|
s.homepage = "https://github.com/RubyMoney/money-rails"
|
14
14
|
|
15
|
-
s.files = Dir.glob("{lib,spec}/**/*")
|
15
|
+
s.files = Dir.glob("{lib,spec,config}/**/*")
|
16
16
|
s.files += %w(CHANGELOG.md LICENSE README.md)
|
17
17
|
s.files += %w(Rakefile money-rails.gemspec)
|
18
18
|
|
@@ -20,13 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.require_path = "lib"
|
22
22
|
|
23
|
-
s.add_dependency "money", "~> 5.
|
23
|
+
s.add_dependency "money", "~> 5.1.0"
|
24
24
|
s.add_dependency "activesupport", "~> 3.0"
|
25
25
|
s.add_dependency "railties", "~> 3.0"
|
26
26
|
|
27
27
|
s.add_development_dependency "rails", "~> 3.0"
|
28
|
-
s.add_development_dependency "rspec", "~> 2.10"
|
29
28
|
s.add_development_dependency "rspec-rails", "~> 2.10"
|
30
|
-
s.add_development_dependency "guard-rspec", "~> 1.1"
|
31
29
|
s.add_development_dependency 'database_cleaner', ['>= 0.8.0']
|
32
30
|
end
|
@@ -1,15 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class Sub < Product; end
|
4
|
+
|
3
5
|
if defined? ActiveRecord
|
4
6
|
describe MoneyRails::ActiveRecord::Monetizable do
|
5
|
-
|
6
7
|
describe "monetize" do
|
7
8
|
before :each do
|
8
9
|
@product = Product.create(:price_cents => 3000, :discount => 150,
|
9
|
-
:bonus_cents => 200, :optional_price => 100
|
10
|
+
:bonus_cents => 200, :optional_price => 100,
|
11
|
+
:sale_price_amount => 1200)
|
10
12
|
@service = Service.create(:charge_cents => 2000, :discount_cents => 120)
|
11
13
|
end
|
12
14
|
|
15
|
+
it "should be inherited by subclasses" do
|
16
|
+
Sub.monetized_attributes.should == Product.monetized_attributes
|
17
|
+
end
|
18
|
+
|
13
19
|
it "attaches a Money object to model field" do
|
14
20
|
@product.price.should be_an_instance_of(Money)
|
15
21
|
@product.discount_value.should be_an_instance_of(Money)
|
@@ -26,6 +32,18 @@ if defined? ActiveRecord
|
|
26
32
|
@product.price_cents.should == 3210
|
27
33
|
end
|
28
34
|
|
35
|
+
it "assigns the correct value from a Money object using create" do
|
36
|
+
@product = Product.create(:price => Money.new(3210, "USD"), :discount => 150,
|
37
|
+
:bonus_cents => 200, :optional_price => 100)
|
38
|
+
@product.valid?.should be_true
|
39
|
+
@product.price_cents.should == 3210
|
40
|
+
end
|
41
|
+
|
42
|
+
it "updates correctly from a Money object using update_attributes" do
|
43
|
+
@product.update_attributes(:price => Money.new(215, "USD")).should be_true
|
44
|
+
@product.price_cents.should == 215
|
45
|
+
end
|
46
|
+
|
29
47
|
it "respects :as argument" do
|
30
48
|
@product.discount_value.should == Money.new(150, "USD")
|
31
49
|
end
|
@@ -38,6 +56,45 @@ if defined? ActiveRecord
|
|
38
56
|
@product.save.should be_true
|
39
57
|
end
|
40
58
|
|
59
|
+
it "respects numericality validation when using update_attributes" do
|
60
|
+
@product.update_attributes(:price_cents => "some text").should be_false
|
61
|
+
@product.update_attributes(:price_cents => 2000).should be_true
|
62
|
+
end
|
63
|
+
|
64
|
+
it "uses numericality validation on money attribute" do
|
65
|
+
@product.price = "some text"
|
66
|
+
@product.save.should be_false
|
67
|
+
|
68
|
+
@product.price = Money.new(320, "USD")
|
69
|
+
@product.save.should be_true
|
70
|
+
|
71
|
+
@product.sale_price = "12,34"
|
72
|
+
@product.sale_price_currency_code = 'EUR'
|
73
|
+
@product.valid?.should be_true
|
74
|
+
end
|
75
|
+
|
76
|
+
it "fails validation with the proper error message if money value is invalid decimal" do
|
77
|
+
@product.price = "12.23.24"
|
78
|
+
@product.save.should be_false
|
79
|
+
@product.errors[:price].first.should match(/Must be a valid/)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "fails validation with the proper error message if money value has invalid thousands part" do
|
83
|
+
@product.price = "12,23.24"
|
84
|
+
@product.save.should be_false
|
85
|
+
@product.errors[:price].first.should match(/Must be a valid/)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "passes validation if money value has correct format" do
|
89
|
+
@product.price = "12,230.24"
|
90
|
+
@product.save.should be_true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "respects numericality validation when using update_attributes on money attribute" do
|
94
|
+
@product.update_attributes(:price => "some text").should be_false
|
95
|
+
@product.update_attributes(:price => Money.new(320, 'USD')).should be_true
|
96
|
+
end
|
97
|
+
|
41
98
|
it "doesn't allow nil by default" do
|
42
99
|
@product.price_cents = nil
|
43
100
|
@product.save.should be_false
|
@@ -49,6 +106,32 @@ if defined? ActiveRecord
|
|
49
106
|
@product.optional_price.should be_nil
|
50
107
|
end
|
51
108
|
|
109
|
+
it "doesn't raise exception if validation is used and nil is not allowed" do
|
110
|
+
expect { @product.price = nil }.to_not raise_error
|
111
|
+
end
|
112
|
+
|
113
|
+
it "doesn't save nil values if validation is used and nil is not allowed" do
|
114
|
+
@product.price = nil
|
115
|
+
@product.save
|
116
|
+
@product.price_cents.should_not be_nil
|
117
|
+
end
|
118
|
+
|
119
|
+
it "resets money_before_type_cast attr every time a save operation occurs" do
|
120
|
+
v = Money.new(100, :usd)
|
121
|
+
@product.price = v
|
122
|
+
@product.price_money_before_type_cast.should == v
|
123
|
+
@product.save
|
124
|
+
@product.price_money_before_type_cast.should be_nil
|
125
|
+
@product.price = 10
|
126
|
+
@product.price_money_before_type_cast.should == 10
|
127
|
+
@product.save
|
128
|
+
@product.price_money_before_type_cast.should be_nil
|
129
|
+
@product.bonus = ""
|
130
|
+
@product.bonus_money_before_type_cast.should == ""
|
131
|
+
@product.save.should be_false
|
132
|
+
@product.bonus_money_before_type_cast.should be_nil
|
133
|
+
end
|
134
|
+
|
52
135
|
it "uses Money default currency if :with_currency has not been used" do
|
53
136
|
@service.discount.currency.should == Money::Currency.find(:eur)
|
54
137
|
end
|
@@ -1,210 +1,68 @@
|
|
1
|
-
[1m[36m (0.
|
2
|
-
[1m[35m (123.9ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
3
|
-
[1m[36m (0.1ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
4
|
-
[1m[35m (83.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
5
|
-
[1m[36m (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
6
|
-
Migrating to CreateProducts (20120331190108)
|
7
|
-
[1m[35m (0.1ms)[0m begin transaction
|
8
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
9
|
-
[1m[35m (0.3ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20120331190108')
|
10
|
-
[1m[36m (176.2ms)[0m [1mcommit transaction[0m
|
11
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
12
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
13
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
14
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
15
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
16
|
-
[1m[36m (127.2ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
17
|
-
[1m[35m (113.4ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
18
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
19
|
-
[1m[35m (133.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
20
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
21
|
-
[1m[35m (115.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
|
22
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
1
|
+
[1m[36m (0.0ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
23
2
|
Migrating to CreateProducts (20120331190108)
|
24
3
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
25
|
-
|
26
|
-
Migrating to CreateServices (20120524052716)
|
27
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
4
|
+
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
28
5
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
29
|
-
[1m[35m (0.
|
30
|
-
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('
|
31
|
-
[1m[35m (
|
32
|
-
|
6
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "bonus_cents" integer
|
7
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')[0m
|
8
|
+
[1m[35m (90.4ms)[0m commit transaction
|
9
|
+
Migrating to AddCurrencyToProduct (20120402080614)
|
10
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
11
|
+
[1m[35m (0.4ms)[0m ALTER TABLE "products" ADD "currency" varchar(255)
|
12
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')[0m
|
13
|
+
[1m[35m (69.9ms)[0m commit transaction
|
14
|
+
[1m[36m (0.2ms)[0m [1mselect sqlite_version(*)[0m
|
33
15
|
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
34
16
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
35
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("services")
|
36
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
37
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
38
|
-
[1m[36m (156.5ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer, "currency" varchar(255)) [0m
|
39
|
-
[1m[35m (95.7ms)[0m CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
40
|
-
[1m[36m (127.9ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
41
|
-
[1m[35m (0.1ms)[0m PRAGMA index_list("schema_migrations")
|
42
|
-
[1m[36m (103.8ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
43
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
44
|
-
[1m[36m (87.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
45
|
-
[1m[35m (88.5ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
46
|
-
[1m[36m (110.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120402080614')[0m
|
47
|
-
[1m[35m (99.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120331190108')
|
48
|
-
[1m[36m (0.3ms)[0m [1mSELECT version FROM schema_migrations[0m
|
49
17
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
50
|
-
[1m[35m (0.
|
51
|
-
Migrating to CreateServices (20120524052716)
|
52
|
-
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
53
|
-
[1m[35m (0.0ms)[0m begin transaction
|
54
|
-
[1m[36m (0.5ms)[0m [1mDROP TABLE "services"[0m
|
55
|
-
[1m[35m (0.1ms)[0m DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120524052716'
|
56
|
-
[1m[36m (113.5ms)[0m [1mcommit transaction[0m
|
57
|
-
[1m[35m (0.7ms)[0m select sqlite_version(*)
|
58
|
-
[1m[36m (0.2ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
59
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
60
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
61
|
-
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
18
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
62
19
|
Migrating to AddCurrencyToProduct (20120402080614)
|
63
20
|
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
64
21
|
[1m[35m (0.0ms)[0m begin transaction
|
65
|
-
[1m[36m (0.
|
22
|
+
[1m[36m (0.3ms)[0m [1mCREATE TEMPORARY TABLE "altered_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer, "currency" varchar(255)) [0m
|
66
23
|
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
67
24
|
[1m[36m (0.1ms)[0m [1mSELECT * FROM "products"[0m
|
68
|
-
[1m[35m (0.
|
69
|
-
[1m[36m (0.
|
25
|
+
[1m[35m (0.1ms)[0m DROP TABLE "products"
|
26
|
+
[1m[36m (0.1ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
70
27
|
[1m[35m (0.0ms)[0m PRAGMA index_list("altered_products")
|
71
|
-
[1m[36m (0.
|
72
|
-
[1m[35m (0.
|
28
|
+
[1m[36m (0.0ms)[0m [1mSELECT * FROM "altered_products"[0m
|
29
|
+
[1m[35m (0.1ms)[0m DROP TABLE "altered_products"
|
73
30
|
[1m[36m (0.1ms)[0m [1mDELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080614'[0m
|
74
|
-
[1m[35m (
|
31
|
+
[1m[35m (147.4ms)[0m commit transaction
|
75
32
|
[1m[36m (0.3ms)[0m [1mselect sqlite_version(*)[0m
|
76
33
|
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
77
34
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
78
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM schema_migrations[0m
|
79
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM schema_migrations[0m
|
80
35
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
81
|
-
|
36
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
82
37
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
83
|
-
|
84
|
-
[1m[35m (0.0ms)[0m
|
85
|
-
[1m[36m (0.
|
86
|
-
[1m[35m (0.
|
87
|
-
[1m[36m (0.
|
88
|
-
[1m[35m (
|
89
|
-
[1m[36m (0.
|
90
|
-
[1m[35m (0.
|
91
|
-
[1m[36m (0.
|
92
|
-
[1m[35m (0.1ms)[0m
|
93
|
-
[1m[36m (0.1ms)[0m [
|
94
|
-
[1m[35m (
|
95
|
-
[1m[36m (
|
96
|
-
[1m[35m (
|
97
|
-
[1m[36m (127.8ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
98
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("schema_migrations")
|
99
|
-
[1m[36m (82.5ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
100
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
101
|
-
[1m[36m (76.3ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
102
|
-
[1m[35m (88.6ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
103
|
-
[1m[36m (77.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
104
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
105
|
-
Migrating to CreateProducts (20120331190108)
|
106
|
-
Migrating to AddBonusCentsToProduct (20120402080348)
|
107
|
-
Migrating to CreateServices (20120524052716)
|
108
|
-
Migrating to CreateTransactions (20120528181002)
|
109
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
110
|
-
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
111
|
-
[1m[35m (0.6ms)[0m CREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
112
|
-
[1m[36m (0.2ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120528181002')[0m
|
113
|
-
[1m[35m (167.5ms)[0m commit transaction
|
114
|
-
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
115
|
-
[1m[35m (0.1ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
38
|
+
[1m[36m (0.0ms)[0m [1mselect sqlite_version(*)[0m
|
39
|
+
[1m[35m (0.0ms)[0m begin transaction
|
40
|
+
[1m[36m (0.3ms)[0m [1mCREATE TEMPORARY TABLE "altered_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
41
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("products")
|
42
|
+
[1m[36m (0.1ms)[0m [1mSELECT * FROM "products"[0m
|
43
|
+
[1m[35m (0.1ms)[0m DROP TABLE "products"
|
44
|
+
[1m[36m (0.1ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
45
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("altered_products")
|
46
|
+
[1m[36m (0.0ms)[0m [1mSELECT * FROM "altered_products"[0m
|
47
|
+
[1m[35m (0.1ms)[0m DROP TABLE "altered_products"
|
48
|
+
[1m[36m (0.1ms)[0m [1mDELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20120402080348'[0m
|
49
|
+
[1m[35m (114.1ms)[0m commit transaction
|
50
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
51
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
116
52
|
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|
117
|
-
[1m[35m (0.0ms)[0m PRAGMA index_list("services")
|
118
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("transactions")[0m
|
119
|
-
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
120
|
-
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
121
|
-
[1m[36m (165.3ms)[0m [1mCREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer) [0m
|
122
|
-
[1m[35m (91.6ms)[0m CREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
123
|
-
[1m[36m (119.4ms)[0m [1mCREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
124
|
-
[1m[35m (90.7ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
125
|
-
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
126
|
-
[1m[35m (134.6ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
127
|
-
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
128
|
-
[1m[35m (97.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
|
129
|
-
[1m[36m (88.6ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120524052716')[0m
|
130
|
-
[1m[35m (88.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120402080348')
|
131
|
-
[1m[36m (110.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
132
53
|
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
133
54
|
Migrating to CreateProducts (20120331190108)
|
134
55
|
Migrating to AddBonusCentsToProduct (20120402080348)
|
135
|
-
Migrating to CreateServices (20120524052716)
|
136
|
-
Migrating to CreateTransactions (20120528181002)
|
137
|
-
Migrating to CreateDummyProducts (20120528210103)
|
138
56
|
[1m[35m (0.0ms)[0m select sqlite_version(*)
|
139
57
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
140
|
-
[1m[35m (0.
|
141
|
-
[1m[36m (0.
|
142
|
-
[1m[35m (
|
143
|
-
|
144
|
-
[1m[
|
145
|
-
[1m[
|
146
|
-
[1m[
|
147
|
-
[1m[
|
148
|
-
[1m[
|
149
|
-
[1m[
|
150
|
-
[1m[
|
151
|
-
[1m[36m (157.0ms)[0m [1mCREATE TABLE "dummy_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "currency" varchar(255), "price_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
152
|
-
[1m[35m (122.6ms)[0m CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "price_cents" integer, "discount" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "bonus_cents" integer)
|
153
|
-
[1m[36m (123.4ms)[0m [1mCREATE TABLE "services" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "charge_cents" integer, "discount_cents" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
154
|
-
[1m[35m (95.8ms)[0m CREATE TABLE "transactions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "amount_cents" integer, "tax_cents" integer, "currency" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
155
|
-
[1m[36m (128.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
156
|
-
[1m[35m (0.1ms)[0m PRAGMA index_list("schema_migrations")
|
157
|
-
[1m[36m (102.3ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
158
|
-
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
159
|
-
[1m[36m (109.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120528210103')[0m
|
160
|
-
[1m[35m (110.8ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120524052716')
|
161
|
-
[1m[36m (121.9ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120402080348')[0m
|
162
|
-
[1m[35m (99.7ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120528181002')
|
163
|
-
[1m[36m (99.5ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20120331190108')[0m
|
164
|
-
Connecting to database specified by database.yml
|
165
|
-
Connecting to database specified by database.yml
|
166
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
167
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
168
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
169
|
-
Connecting to database specified by database.yml
|
170
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
171
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
172
|
-
Connecting to database specified by database.yml
|
173
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
174
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
175
|
-
Connecting to database specified by database.yml
|
176
|
-
MONGODB (0ms) dummy_development['system.namespaces'].find({})
|
177
|
-
MONGODB (36ms) dummy_development['$cmd'].find({:create=>"priceables"}).limit(-1)
|
178
|
-
MONGODB (0ms) dummy_development['priceables'].insert([{"_id"=>BSON::ObjectId('4fe8d4c2eac0741caf000001'), "price"=>{:cents=>100, :currency_iso=>"EUR"}}])
|
179
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
180
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
181
|
-
Connecting to database specified by database.yml
|
182
|
-
MONGODB (60ms) dummy_development['system.namespaces'].find({})
|
183
|
-
MONGODB (0ms) dummy_development['$cmd'].find({"count"=>"priceables", "query"=>{}, "fields"=>nil}).limit(-1)
|
184
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
185
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
186
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
187
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
188
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
189
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
190
|
-
MONGODB (0ms) dummy_development['priceables'].find({}).limit(-1).sort([[:_id, :asc]])
|
191
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
192
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
193
|
-
Connecting to database specified by database.yml
|
194
|
-
MONGODB (0ms) dummy_development['system.namespaces'].find({})
|
195
|
-
MONGODB (0ms) dummy_development['$cmd'].find({"count"=>"priceables", "query"=>{}, "fields"=>nil}).limit(-1)
|
196
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
197
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
198
|
-
Connecting to database specified by database.yml
|
199
|
-
MONGODB (7ms) dummy_development['system.namespaces'].find({})
|
200
|
-
MONGODB (0ms) dummy_development['$cmd'].find({"count"=>"priceables", "query"=>{}, "fields"=>nil}).limit(-1)
|
201
|
-
MONGODB (0ms) dummy_development['priceables'].insert([{"_id"=>BSON::ObjectId('4feb6f8feac07427a9000001'), "price"=>{:cents=>245, :currency_iso=>"EUR"}}])
|
202
|
-
MONGODB (0ms) dummy_development['$cmd'].find({"count"=>"priceables", "query"=>{}, "fields"=>nil}).limit(-1)
|
203
|
-
MONGODB [DEBUG] Logging level is currently :debug which could negatively impact client-side performance. You should set your logging level no lower than :info in production.
|
204
|
-
MONGODB (0ms) admin['$cmd'].find({:ismaster=>1}).limit(-1)
|
205
|
-
Connecting to database specified by database.yml
|
206
|
-
MONGODB (0ms) dummy_development['system.namespaces'].find({})
|
207
|
-
MONGODB (0ms) dummy_development['$cmd'].find({"count"=>"priceables", "query"=>{}, "fields"=>nil}).limit(-1)
|
208
|
-
Connecting to database specified by database.yml
|
209
|
-
Connecting to database specified by database.yml
|
210
|
-
Connecting to database specified by database.yml
|
58
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "bonus_cents" integer
|
59
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080348')[0m
|
60
|
+
[1m[35m (108.4ms)[0m commit transaction
|
61
|
+
Migrating to AddCurrencyToProduct (20120402080614)
|
62
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
63
|
+
[1m[35m (0.2ms)[0m ALTER TABLE "products" ADD "currency" varchar(255)
|
64
|
+
[1m[36m (0.1ms)[0m [1mINSERT INTO "schema_migrations" ("version") VALUES ('20120402080614')[0m
|
65
|
+
[1m[35m (76.9ms)[0m commit transaction
|
66
|
+
[1m[36m (0.4ms)[0m [1mselect sqlite_version(*)[0m
|
67
|
+
[1m[35m (0.0ms)[0m SELECT "schema_migrations"."version" FROM "schema_migrations"
|
68
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("products")[0m
|