amountable 0.0.4 → 0.0.5
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/lib/amountable.rb +1 -1
- data/lib/amountable/version.rb +1 -1
- data/spec/internal/db/schema.rb +11 -12
- data/spec/support/database.rb +25 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18e0c969e86b2011d96f0c829de6aa1ce588a29b
|
4
|
+
data.tar.gz: 38d69abcf37a7789e0d72396aceb122b72d23824
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ccb174724df2e606d57df8a53f904a00ad6f322ade69f2f9f341a246e01211f8ae819099f888573e8421ed603d58b88e992ab5f8850d8cd6ae8a9844a412738
|
7
|
+
data.tar.gz: 87c7982c3af2ebbdf9509d1243eccd7235cbce196a9d8511dac8ab40f6615971b33eff08635b5b889e92fa932982a0fa06ec6cbcc7fe7d69d929d7319c43705f
|
data/lib/amountable.rb
CHANGED
@@ -108,7 +108,7 @@ module Amountable
|
|
108
108
|
amounts.delete(amount)
|
109
109
|
all_amounts.delete(amount)
|
110
110
|
@amounts_by_name.delete(name)
|
111
|
-
amount.destroy
|
111
|
+
amount.destroy if amount.persisted?
|
112
112
|
else
|
113
113
|
all_amounts << amount if amount.new_record?
|
114
114
|
(@amounts_by_name ||= {})[name.to_sym] = amount
|
data/lib/amountable/version.rb
CHANGED
data/spec/internal/db/schema.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
# Copyright 2015, Instacart
|
2
2
|
|
3
|
-
ActiveRecord::Schema.define
|
3
|
+
ActiveRecord::Schema.define do
|
4
4
|
|
5
5
|
create_table "amounts", force: :cascade do |t|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
add_index "amounts", ["amountable_id", "amountable_type"], name: "index_amounts_on_amountable_id_and_amountable_type", using: :btree
|
6
|
+
t.integer "amountable_id", null: false
|
7
|
+
t.string "amountable_type", null: false
|
8
|
+
t.datetime "created_at"
|
9
|
+
t.string "name", null: false
|
10
|
+
t.datetime "updated_at"
|
11
|
+
t.integer "value_cents", default: 0, null: false
|
12
|
+
t.string "value_currency", default: "USD", null: false
|
13
|
+
end
|
14
|
+
add_index "amounts", ["amountable_id", "amountable_type"], name: "index_amounts_on_amountable_id_and_amountable_type", using: :btree
|
16
15
|
|
17
|
-
create_table "orders" do |t|
|
16
|
+
create_table "orders", force: :cascade do |t|
|
18
17
|
t.datetime "created_at"
|
19
18
|
t.datetime "updated_at"
|
20
19
|
end
|
data/spec/support/database.rb
CHANGED
@@ -1,36 +1,34 @@
|
|
1
1
|
# Copyright 2015, Instacart
|
2
2
|
|
3
3
|
db_name = ENV['DB'] || 'postgresql'
|
4
|
-
|
4
|
+
spec_dir = Pathname.new(File.dirname(__FILE__)) / '..'
|
5
|
+
database_yml = spec_dir.join('internal/config/database.yml')
|
5
6
|
|
6
|
-
|
7
|
+
fail "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample" unless File.exist?(database_yml)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
ActiveRecord::Migration.verbose = false
|
10
|
+
ActiveRecord::Base.default_timezone = :utc
|
11
|
+
ActiveRecord::Base.configurations = YAML.load_file(database_yml)
|
12
|
+
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), '../debug.log'))
|
13
|
+
ActiveRecord::Base.logger.level = ENV['TRAVIS'] ? ::Logger::ERROR : ::Logger::DEBUG
|
14
|
+
config = ActiveRecord::Base.configurations[db_name]
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
ActiveRecord::Base.establish_connection(config)
|
16
|
+
begin
|
17
|
+
ActiveRecord::Base.establish_connection(db_name.to_sym)
|
18
|
+
ActiveRecord::Base.connection
|
19
|
+
rescue
|
20
|
+
case db_name
|
21
|
+
when /mysql/
|
22
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
23
|
+
ActiveRecord::Base.connection.create_database(config['database'], {charset: 'utf8', collation: 'utf8_unicode_ci'})
|
24
|
+
when 'postgresql'
|
25
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
26
|
+
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => 'utf8'))
|
29
27
|
end
|
30
28
|
|
31
|
-
|
32
|
-
load(File.dirname(__FILE__) + '/../internal/app/models/order.rb')
|
33
|
-
|
34
|
-
else
|
35
|
-
fail "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample"
|
29
|
+
ActiveRecord::Base.establish_connection(config)
|
36
30
|
end
|
31
|
+
|
32
|
+
require_relative '../internal/db/schema'
|
33
|
+
|
34
|
+
Dir[spec_dir.join('internal/app/models/*.rb')].each { |file| require_relative file }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amountable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Turlay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|