mcfly 0.0.22 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/lib/mcfly/version.rb +1 -1
- data/mcfly.gemspec +1 -1
- data/spec/model_spec.rb +35 -34
- data/spec/no_trans_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +7 -8
- data/Gemfile.lock +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02aac542796dfd1f61656f5d67ab560e2ae25072aee47a0ea51b2dbc40346f6f
|
4
|
+
data.tar.gz: 91cc393fe3e61a3273efb3af5dcda3e2da944f4c7ac21b9d53f2597a46a8ed73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8380a467c4732615ac410e3f71861ad4a47d4dc8d831c6c030b7c8169d44437c9eb4b003464ea2ce904a1cfd41872254dac10bbfa9f3853fa5b9ebf26054fbd
|
7
|
+
data.tar.gz: ac15503f7d8d6f023df03fe0072c6ae149c3f0c774cee7e64eca0829f91acb8a66d07d4b539756a466e6daa58d4a01aab3a9015c079e62cdeedd6d1c50a234fb
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -4,5 +4,9 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :development, :test do
|
7
|
+
# gem 'delorean_lang', path: File.expand_path('../../delorean', __FILE__)
|
7
8
|
gem 'rspec-instafail', require: false
|
9
|
+
gem 'rubocop', require: false
|
10
|
+
gem 'pry-byebug'
|
11
|
+
gem 'pry-rails'
|
8
12
|
end
|
data/lib/mcfly/version.rb
CHANGED
data/mcfly.gemspec
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -69,28 +69,28 @@ describe "Mcfly" do
|
|
69
69
|
mp.save!
|
70
70
|
|
71
71
|
l = MarketPrice.where("group_id = ?", mp.id).order("obsoleted_dt").all
|
72
|
-
l.length.
|
72
|
+
expect(l.length).to eq(2)
|
73
73
|
|
74
|
-
l[1].obsoleted_dt.
|
75
|
-
l[0].obsoleted_dt.
|
74
|
+
expect(l[1].obsoleted_dt).to eq(Float::INFINITY)
|
75
|
+
expect(l[0].obsoleted_dt).to eq(mp.created_dt)
|
76
76
|
|
77
77
|
# Make sure that setting an old created_dt fails.
|
78
78
|
mp.price = mp.price + 123
|
79
79
|
mp.created_dt = mp.created_dt - 1.day
|
80
|
-
|
80
|
+
expect {
|
81
81
|
mp.save!
|
82
|
-
}.
|
82
|
+
}.to raise_error(ActiveRecord::StatementInvalid)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should make sure that append-only does not allow changes" do
|
86
86
|
si = SecurityInstrument.lookup('infinity', "FN Fix-30 MBS")
|
87
|
-
si.settlement_class.
|
87
|
+
expect(si.settlement_class).to eq("A")
|
88
88
|
|
89
89
|
si.name = "xyz"
|
90
90
|
|
91
|
-
|
91
|
+
expect {
|
92
92
|
si.save!
|
93
|
-
}.
|
93
|
+
}.to raise_error(ActiveRecord::StatementInvalid)
|
94
94
|
|
95
95
|
end
|
96
96
|
|
@@ -100,11 +100,11 @@ describe "Mcfly" do
|
|
100
100
|
|
101
101
|
osi = SecurityInstrument.find_by_name("FN Fix-30 MBS")
|
102
102
|
|
103
|
-
(osi.obsoleted_dt - DateTime.now).to_f.abs.
|
103
|
+
expect((osi.obsoleted_dt - DateTime.now).to_f.abs).to be < 100
|
104
104
|
|
105
|
-
|
105
|
+
expect {
|
106
106
|
osi.delete
|
107
|
-
}.
|
107
|
+
}.to raise_error(ActiveRecord::StatementInvalid)
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should be able to delete append-only items and create a new clone" do
|
@@ -118,20 +118,21 @@ describe "Mcfly" do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "should check basic versioning" do
|
121
|
-
SecurityInstrument.lookup_all('infinity').count.
|
121
|
+
expect(SecurityInstrument.lookup_all('infinity').count).to eq(@sis.count)
|
122
122
|
|
123
123
|
@dts.each_with_index { |pt, i|
|
124
|
-
SecurityInstrument.lookup_all(pt + " 12:00 PST8PDT").count.
|
125
|
-
|
124
|
+
expect(SecurityInstrument.lookup_all(pt + " 12:00 PST8PDT").count).to eq(
|
125
|
+
(i + 1) * @sis.count/@dts.length
|
126
|
+
)
|
126
127
|
}
|
127
128
|
|
128
|
-
SecurityInstrument.lookup_all(@old).count.
|
129
|
-
SecurityInstrument.lookup(@old, "FN Fix-30 MBS").
|
129
|
+
expect(SecurityInstrument.lookup_all(@old).count).to eq(0)
|
130
|
+
expect(SecurityInstrument.lookup(@old, "FN Fix-30 MBS")).to eq(nil)
|
130
131
|
|
131
132
|
# all versions
|
132
133
|
MarketPrice.count == @sis.length * (@vers+1)
|
133
134
|
|
134
|
-
MarketPrice.lookup_all('infinity').count.
|
135
|
+
expect(MarketPrice.lookup_all('infinity').count).to eq(@sis.count)
|
135
136
|
|
136
137
|
si = SecurityInstrument.first
|
137
138
|
|
@@ -142,7 +143,7 @@ describe "Mcfly" do
|
|
142
143
|
# previous version of mp
|
143
144
|
omp = MarketPrice.lookup_si(odate, si)
|
144
145
|
|
145
|
-
mp.price.
|
146
|
+
expect(mp.price).to eq(omp.price + 1)
|
146
147
|
end
|
147
148
|
|
148
149
|
it "should test mcfly uniqueness validations" do
|
@@ -166,9 +167,9 @@ describe "Mcfly" do
|
|
166
167
|
mp2 = new_mp(mp.price + 100)
|
167
168
|
|
168
169
|
mp2.created_dt = si.created_dt + 1.day
|
169
|
-
|
170
|
+
expect {
|
170
171
|
mp2.save!
|
171
|
-
}.
|
172
|
+
}.to raise_error(ActiveRecord::RecordInvalid)
|
172
173
|
|
173
174
|
# now change mp's settlement_mm
|
174
175
|
mp.settlement_mm += 1
|
@@ -185,22 +186,22 @@ describe "Mcfly" do
|
|
185
186
|
dt = '2010-01-01 08:00 PST8PDT'
|
186
187
|
|
187
188
|
mp = MarketPrice.lookup_si(dt, si)
|
188
|
-
mp.obsoleted_dt.
|
189
|
+
expect(mp.obsoleted_dt).to eq(Float::INFINITY)
|
189
190
|
|
190
191
|
sleep 1.seconds
|
191
192
|
|
192
193
|
mp.delete
|
193
194
|
|
194
|
-
MarketPrice.lookup_si('infinity', si).
|
195
|
+
expect(MarketPrice.lookup_si('infinity', si)).to eq(nil)
|
195
196
|
|
196
197
|
omp = MarketPrice.lookup_si(dt, si)
|
197
|
-
omp.
|
198
|
-
omp.obsoleted_dt.
|
198
|
+
expect(omp).not_to eq(nil)
|
199
|
+
expect(omp.obsoleted_dt).not_to eq(Float::INFINITY)
|
199
200
|
|
200
201
|
omp.price = 1010
|
201
|
-
|
202
|
+
expect {
|
202
203
|
omp.save!
|
203
|
-
}.
|
204
|
+
}.to raise_error(ActiveRecord::StatementInvalid)
|
204
205
|
end
|
205
206
|
|
206
207
|
it "whodunnit should set user/o_user on CRUD" do
|
@@ -212,32 +213,32 @@ describe "Mcfly" do
|
|
212
213
|
sleep 1.seconds
|
213
214
|
|
214
215
|
mp = MarketPrice.lookup_si(dt, si)
|
215
|
-
mp.user_id.
|
216
|
+
expect(mp.user_id).to eq(10)
|
216
217
|
|
217
218
|
mp.price = 123
|
218
219
|
mp.save!
|
219
220
|
|
220
221
|
# old version should still have original creator user
|
221
222
|
mp = MarketPrice.lookup_si(dt, si)
|
222
|
-
mp.user_id.
|
223
|
-
mp.o_user_id.
|
223
|
+
expect(mp.user_id).to eq(10)
|
224
|
+
expect(mp.o_user_id).to eq(20)
|
224
225
|
|
225
226
|
# new version should have new creator
|
226
227
|
mp = MarketPrice.lookup_si('infinity', si)
|
227
|
-
mp.user_id.
|
228
|
-
mp.o_user_id.
|
228
|
+
expect(mp.user_id).to eq(20)
|
229
|
+
expect(mp.o_user_id).to eq(nil)
|
229
230
|
end
|
230
231
|
|
231
232
|
it "should set o_user on delete" do
|
232
233
|
si = SecurityInstrument.find_by_name("FN Fix-15 HB MBS")
|
233
234
|
mp = MarketPrice.lookup_si('infinity', si)
|
234
|
-
mp.obsoleted_dt.
|
235
|
-
mp.o_user_id.
|
235
|
+
expect(mp.obsoleted_dt).to eq(Float::INFINITY)
|
236
|
+
expect(mp.o_user_id).to eq(nil)
|
236
237
|
|
237
238
|
rid = mp.id
|
238
239
|
Mcfly.whodunnit = {id: 30}
|
239
240
|
mp.delete
|
240
241
|
mp = MarketPrice.find(rid)
|
241
|
-
mp.o_user_id.
|
242
|
+
expect(mp.o_user_id).to eq(30)
|
242
243
|
end
|
243
244
|
end
|
data/spec/no_trans_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -3,12 +3,12 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
3
3
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
4
|
|
5
5
|
require 'rspec/rails'
|
6
|
-
require '
|
6
|
+
require 'pry'
|
7
7
|
|
8
8
|
Rails.backtrace_cleaner.remove_silencers!
|
9
9
|
|
10
10
|
# Run any available migration
|
11
|
-
ActiveRecord::
|
11
|
+
ActiveRecord::Migration.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
12
12
|
|
13
13
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
14
14
|
# in spec/support/ and its subdirectories.
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcfly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: delorean_lang
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
64
|
- Gemfile
|
65
|
-
- Gemfile.lock
|
66
65
|
- MIT-LICENSE
|
67
66
|
- README.md
|
68
67
|
- Rakefile
|
@@ -140,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
139
|
version: '0'
|
141
140
|
requirements: []
|
142
141
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.7.8
|
144
143
|
signing_key:
|
145
144
|
specification_version: 4
|
146
145
|
summary: A database table versioning system.
|
data/Gemfile.lock
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mcfly (0.0.21)
|
5
|
-
delorean_lang
|
6
|
-
pg (~> 0.17)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionpack (5.1.4)
|
12
|
-
actionview (= 5.1.4)
|
13
|
-
activesupport (= 5.1.4)
|
14
|
-
rack (~> 2.0)
|
15
|
-
rack-test (>= 0.6.3)
|
16
|
-
rails-dom-testing (~> 2.0)
|
17
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
18
|
-
actionview (5.1.4)
|
19
|
-
activesupport (= 5.1.4)
|
20
|
-
builder (~> 3.1)
|
21
|
-
erubi (~> 1.4)
|
22
|
-
rails-dom-testing (~> 2.0)
|
23
|
-
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
24
|
-
activemodel (5.1.4)
|
25
|
-
activesupport (= 5.1.4)
|
26
|
-
activerecord (5.1.4)
|
27
|
-
activemodel (= 5.1.4)
|
28
|
-
activesupport (= 5.1.4)
|
29
|
-
arel (~> 8.0)
|
30
|
-
activesupport (5.1.4)
|
31
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
-
i18n (~> 0.7)
|
33
|
-
minitest (~> 5.1)
|
34
|
-
tzinfo (~> 1.1)
|
35
|
-
arel (8.0.0)
|
36
|
-
builder (3.2.3)
|
37
|
-
concurrent-ruby (1.1.4)
|
38
|
-
crass (1.0.3)
|
39
|
-
delorean_lang (0.5.1)
|
40
|
-
activerecord (>= 3.2)
|
41
|
-
treetop (~> 1.5)
|
42
|
-
diff-lcs (1.3)
|
43
|
-
erubi (1.7.0)
|
44
|
-
i18n (0.9.5)
|
45
|
-
concurrent-ruby (~> 1.0)
|
46
|
-
loofah (2.1.1)
|
47
|
-
crass (~> 1.0.2)
|
48
|
-
nokogiri (>= 1.5.9)
|
49
|
-
method_source (0.9.0)
|
50
|
-
mini_portile2 (2.3.0)
|
51
|
-
minitest (5.11.3)
|
52
|
-
nokogiri (1.8.1)
|
53
|
-
mini_portile2 (~> 2.3.0)
|
54
|
-
pg (0.21.0)
|
55
|
-
polyglot (0.3.5)
|
56
|
-
rack (2.0.3)
|
57
|
-
rack-test (0.8.2)
|
58
|
-
rack (>= 1.0, < 3)
|
59
|
-
rails-dom-testing (2.0.3)
|
60
|
-
activesupport (>= 4.2.0)
|
61
|
-
nokogiri (>= 1.6)
|
62
|
-
rails-html-sanitizer (1.0.3)
|
63
|
-
loofah (~> 2.0)
|
64
|
-
railties (5.1.4)
|
65
|
-
actionpack (= 5.1.4)
|
66
|
-
activesupport (= 5.1.4)
|
67
|
-
method_source
|
68
|
-
rake (>= 0.8.7)
|
69
|
-
thor (>= 0.18.1, < 2.0)
|
70
|
-
rake (12.3.0)
|
71
|
-
rspec (3.7.0)
|
72
|
-
rspec-core (~> 3.7.0)
|
73
|
-
rspec-expectations (~> 3.7.0)
|
74
|
-
rspec-mocks (~> 3.7.0)
|
75
|
-
rspec-core (3.7.1)
|
76
|
-
rspec-support (~> 3.7.0)
|
77
|
-
rspec-expectations (3.7.0)
|
78
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
-
rspec-support (~> 3.7.0)
|
80
|
-
rspec-instafail (1.0.0)
|
81
|
-
rspec
|
82
|
-
rspec-mocks (3.7.0)
|
83
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
-
rspec-support (~> 3.7.0)
|
85
|
-
rspec-rails (3.7.2)
|
86
|
-
actionpack (>= 3.0)
|
87
|
-
activesupport (>= 3.0)
|
88
|
-
railties (>= 3.0)
|
89
|
-
rspec-core (~> 3.7.0)
|
90
|
-
rspec-expectations (~> 3.7.0)
|
91
|
-
rspec-mocks (~> 3.7.0)
|
92
|
-
rspec-support (~> 3.7.0)
|
93
|
-
rspec-support (3.7.0)
|
94
|
-
thor (0.20.0)
|
95
|
-
thread_safe (0.3.6)
|
96
|
-
treetop (1.6.10)
|
97
|
-
polyglot (~> 0.3)
|
98
|
-
tzinfo (1.2.5)
|
99
|
-
thread_safe (~> 0.1)
|
100
|
-
|
101
|
-
PLATFORMS
|
102
|
-
ruby
|
103
|
-
|
104
|
-
DEPENDENCIES
|
105
|
-
mcfly!
|
106
|
-
rspec-instafail
|
107
|
-
rspec-rails (~> 3.0)
|
108
|
-
|
109
|
-
BUNDLED WITH
|
110
|
-
2.0.1
|