acts_as_span 0.0.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -3
- data/.rspec +2 -0
- data/.tool-versions +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +0 -3
- data/README.rdoc +4 -16
- data/Rakefile +5 -1
- data/acts_as_span.gemspec +31 -14
- data/config/locales/en/acts_as_span.yml +15 -0
- data/lib/acts_as_span.rb +69 -98
- data/lib/acts_as_span/end_date_propagator.rb +198 -0
- data/lib/acts_as_span/no_overlap_validator.rb +86 -0
- data/lib/acts_as_span/span_instance.rb +24 -32
- data/lib/acts_as_span/span_instance/status.rb +12 -27
- data/lib/acts_as_span/span_instance/validations.rb +11 -53
- data/lib/acts_as_span/span_klass.rb +11 -19
- data/lib/acts_as_span/span_klass/status.rb +43 -12
- data/lib/acts_as_span/version.rb +6 -4
- data/lib/acts_as_span/within_parent_date_span_validator.rb +44 -0
- data/spec/lib/acts_as_span_spec.rb +38 -35
- data/spec/lib/delegation_spec.rb +45 -78
- data/spec/lib/end_date_propagator_spec.rb +319 -0
- data/spec/lib/no_overlap_validator_spec.rb +129 -0
- data/spec/lib/span_instance/named_scopes_on_spec.rb +193 -193
- data/spec/lib/span_instance/named_scopes_spec.rb +193 -191
- data/spec/lib/span_instance/overlap_spec.rb +193 -253
- data/spec/lib/span_instance/status_spec.rb +22 -35
- data/spec/lib/span_instance/validations_spec.rb +8 -44
- data/spec/lib/span_instance_spec.rb +17 -30
- data/spec/lib/span_klass/status_spec.rb +38 -0
- data/spec/lib/within_parent_date_span_validator_spec.rb +126 -0
- data/spec/spec_helper.rb +19 -6
- data/spec/spec_models.rb +226 -0
- metadata +167 -61
- data/Gemfile.lock +0 -47
- data/lib/acts_as_span/span_instance/overlap.rb +0 -17
- data/lib/acts_as_span/span_klass/overlap.rb +0 -21
- data/spec/lib/negative_spec.rb +0 -30
- data/spec/spec.opts +0 -1
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'has_siblings'
|
3
|
+
|
4
|
+
RSpec.describe ActsAsSpan::NoOverlapValidator do
|
5
|
+
let!(:brother) do
|
6
|
+
child_class.create(
|
7
|
+
start_date: brother_start_date,
|
8
|
+
end_date: brother_end_date,
|
9
|
+
mama: mama)
|
10
|
+
end
|
11
|
+
|
12
|
+
let!(:sister) do
|
13
|
+
child_class.create(
|
14
|
+
start_date: sister_start_date,
|
15
|
+
end_date: sister_end_date,
|
16
|
+
mama: mama)
|
17
|
+
end
|
18
|
+
|
19
|
+
let!(:brother_from_another_mother) do
|
20
|
+
child_class.create(
|
21
|
+
start_date: new_child_start_date,
|
22
|
+
end_date: new_child_end_date,
|
23
|
+
mama: other_mama)
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:new_child) do
|
27
|
+
child_class.new(
|
28
|
+
start_date: new_child_start_date,
|
29
|
+
end_date: new_child_end_date,
|
30
|
+
mama: mama)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:mama) { Mama.create }
|
34
|
+
let(:other_mama) { Mama.create }
|
35
|
+
let(:papa) { Papa.create }
|
36
|
+
|
37
|
+
let(:brother_start_date) { Date.current - 2 }
|
38
|
+
let(:brother_end_date) { Date.current - 1 }
|
39
|
+
|
40
|
+
let(:sister_start_date) { Date.current + 2 }
|
41
|
+
let(:sister_end_date) { Date.current + 3 }
|
42
|
+
|
43
|
+
let(:all_siblings) { [brother, sister, brother_from_another_mother] }
|
44
|
+
|
45
|
+
describe 'instance_scope' do
|
46
|
+
let(:child_class) { OneParentChild }
|
47
|
+
|
48
|
+
let(:new_child_start_date) { Date.current - 2 }
|
49
|
+
let(:new_child_end_date) { Date.current + 3 }
|
50
|
+
|
51
|
+
before { new_child.favorite = favorite }
|
52
|
+
|
53
|
+
context 'when instance_scope evaluates to false' do
|
54
|
+
let(:favorite) { false }
|
55
|
+
it 'skips validation on the record for which instance_scope is false' do
|
56
|
+
expect(new_child).to be_valid
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when instance_scope evaluates to true' do
|
61
|
+
let(:favorite) { true }
|
62
|
+
it 'validates normally' do
|
63
|
+
expect(new_child).not_to be_valid
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'an object with a single parent' do
|
69
|
+
let(:child_class) { OneParentChild }
|
70
|
+
|
71
|
+
context 'valid cases' do
|
72
|
+
let(:new_child_start_date) { Date.current }
|
73
|
+
let(:new_child_end_date) { Date.current + 1 }
|
74
|
+
|
75
|
+
it 'allows overlapping spans on for associated records with different parents' do
|
76
|
+
expect(new_child).to be_valid
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'invalid cases' do
|
81
|
+
let(:new_child_start_date) { Date.current - 2 }
|
82
|
+
let(:new_child_end_date) { Date.current + 3 }
|
83
|
+
|
84
|
+
it 'does not allow overlapping spans siblings with same parents' do
|
85
|
+
expect(new_child).not_to be_valid
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'an object with multiple parents' do
|
91
|
+
let(:child_class) { TwoParentChild }
|
92
|
+
|
93
|
+
before do
|
94
|
+
all_siblings.each do |sibling|
|
95
|
+
sibling.update(papa: papa)
|
96
|
+
end
|
97
|
+
|
98
|
+
new_child.papa = papa
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'valid cases' do
|
102
|
+
let(:new_child_start_date) { brother_end_date + 1 }
|
103
|
+
let(:new_child_end_date) { sister_start_date - 1 }
|
104
|
+
|
105
|
+
it 'allows overlapping spans on for associated records with different parents' do
|
106
|
+
expect(new_child).to be_valid
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'invalid cases' do
|
111
|
+
let(:new_child_start_date) { brother_start_date }
|
112
|
+
let(:new_child_end_date) { sister_end_date }
|
113
|
+
|
114
|
+
it 'does not allow overlapping spans siblings with same parents' do
|
115
|
+
expect(new_child).not_to be_valid
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'error messages' do
|
121
|
+
let(:child_class) { OneParentChildCustom }
|
122
|
+
let(:new_child_start_date) { sister_start_date }
|
123
|
+
let(:new_child_end_date) { sister_end_date }
|
124
|
+
it 'allows using custom error messages' do
|
125
|
+
expect(new_child).not_to be_valid
|
126
|
+
expect(new_child.errors.messages[:base]).to include('Custom error message')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -1,304 +1,304 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "a basic model using acts_as_span" do
|
4
|
-
before(:all) do
|
5
|
-
build_model :span_model do
|
6
|
-
string :description
|
7
|
-
date :start_date
|
8
|
-
date :end_date
|
9
|
-
|
10
|
-
acts_as_span
|
11
|
-
end
|
12
|
-
|
13
|
-
@query_date = Date.today + 1.month
|
14
|
-
end
|
15
|
-
|
3
|
+
RSpec.describe "a basic model using acts_as_span" do
|
16
4
|
context "named_scopes and current_on?, expired_on?, and future_on?" do
|
17
5
|
# -2 -1 Q +1 +2 C F E
|
18
6
|
# A |---| E
|
19
|
-
# B |-------| C
|
20
|
-
# C |--------------| C
|
21
|
-
# D | C
|
22
|
-
# E |------| C
|
23
|
-
# F |--| F
|
24
|
-
# G |-> C
|
25
|
-
# H |-> C
|
26
|
-
# I |-> F
|
7
|
+
# B |-------| C
|
8
|
+
# C |--------------| C
|
9
|
+
# D | C
|
10
|
+
# E |------| C
|
11
|
+
# F |--| F
|
12
|
+
# G |-> C
|
13
|
+
# H |-> C
|
14
|
+
# I |-> F
|
27
15
|
# J <-| E
|
28
|
-
# K <-| C
|
29
|
-
# L <-| C
|
30
|
-
# M <-> C
|
16
|
+
# K <-| C
|
17
|
+
# L <-| C
|
18
|
+
# M <-> C
|
19
|
+
let(:span_a) {[ - 2.days, - 1.day ]}
|
20
|
+
let(:span_b) {[ - 2.days, 0.days ]}
|
21
|
+
let(:span_c) {[ - 2.days, 2.days ]}
|
22
|
+
let(:span_d) {[ 0.days, 0.days ]}
|
23
|
+
let(:span_e) {[ 0.days, 2.days ]}
|
24
|
+
let(:span_f) {[ 1.day, 2.days ]}
|
25
|
+
let(:span_g) {[ - 2.days, nil ]}
|
26
|
+
let(:span_h) {[ 0.days, nil ]}
|
27
|
+
let(:span_i) {[ 1.day, nil ]}
|
28
|
+
let(:span_j) {[ nil, - 1.day ]}
|
29
|
+
let(:span_k) {[ nil, 0.days ]}
|
30
|
+
let(:span_l) {[ nil, 2.days ]}
|
31
|
+
let(:span_m) {[ nil, nil ]}
|
32
|
+
|
33
|
+
let(:query_date) { Date.current + (-24..24).to_a.sample.month }
|
34
|
+
|
35
|
+
let!(:span_model) do
|
36
|
+
current_start_date = start_date.nil? ? nil : query_date + start_date
|
37
|
+
current_end_date = end_date.nil? ? nil : query_date + end_date
|
38
|
+
|
39
|
+
SpanModel.create!(
|
40
|
+
start_date: current_start_date,
|
41
|
+
end_date: current_end_date)
|
42
|
+
end
|
43
|
+
|
31
44
|
context "A) start_date < query_date & end_date < query_date" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
45
|
+
let(:start_date) { span_a[0] }
|
46
|
+
let(:end_date) { span_a[1] }
|
47
|
+
|
36
48
|
it "should NOT be included in #current" do
|
37
|
-
SpanModel.current_on(
|
38
|
-
|
49
|
+
expect(SpanModel.current_on(query_date)).not_to include(span_model)
|
50
|
+
expect(span_model.current_on?(query_date)).to be_falsey
|
39
51
|
end
|
40
|
-
|
52
|
+
|
41
53
|
it "should NOT be included in #future" do
|
42
|
-
SpanModel.future_on(
|
43
|
-
|
54
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
55
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
44
56
|
end
|
45
|
-
|
57
|
+
|
46
58
|
it "should be included in #expired" do
|
47
|
-
SpanModel.expired_on(
|
48
|
-
|
59
|
+
expect(SpanModel.expired_on(query_date)).to include(span_model)
|
60
|
+
expect(span_model.expired_on?(query_date)).to be_truthy
|
49
61
|
end
|
50
62
|
end
|
51
|
-
|
63
|
+
|
52
64
|
context "B) start_date < query_date & end_date == query_date" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
65
|
+
let(:start_date) { span_b[0] }
|
66
|
+
let(:end_date) { span_b[1] }
|
67
|
+
|
57
68
|
it "should be included in #current" do
|
58
|
-
SpanModel.current_on(
|
59
|
-
|
69
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
70
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
60
71
|
end
|
61
|
-
|
72
|
+
|
62
73
|
it "should NOT be included in #future" do
|
63
|
-
SpanModel.future_on(
|
64
|
-
|
74
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
75
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
65
76
|
end
|
66
|
-
|
77
|
+
|
67
78
|
it "should NOT be included in #expired" do
|
68
|
-
SpanModel.expired_on(
|
69
|
-
|
79
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
80
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
70
81
|
end
|
71
82
|
end
|
72
|
-
|
83
|
+
|
73
84
|
context "C) start_date < query_date & end_date > query_date" do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
85
|
+
let(:start_date) { span_c[0] }
|
86
|
+
let(:end_date) { span_c[1] }
|
87
|
+
|
78
88
|
it "should be included in #current" do
|
79
|
-
SpanModel.current_on(
|
80
|
-
|
89
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
90
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
81
91
|
end
|
82
|
-
|
92
|
+
|
83
93
|
it "should NOT be included in #future" do
|
84
|
-
SpanModel.future_on(
|
85
|
-
|
94
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
95
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
86
96
|
end
|
87
|
-
|
97
|
+
|
88
98
|
it "should NOT be included in #expired" do
|
89
|
-
SpanModel.expired_on(
|
90
|
-
|
99
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
100
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
91
101
|
end
|
92
102
|
end
|
93
|
-
|
103
|
+
|
94
104
|
context "D) start_date == query_date & end_date == query_date" do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
105
|
+
let(:start_date) { span_d[0] }
|
106
|
+
let(:end_date) { span_d[1] }
|
107
|
+
|
99
108
|
it "should be included in #current" do
|
100
|
-
SpanModel.current_on(
|
101
|
-
|
109
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
110
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
102
111
|
end
|
103
|
-
|
112
|
+
|
104
113
|
it "should NOT be included in #future" do
|
105
|
-
SpanModel.future_on(
|
106
|
-
|
114
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
115
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
107
116
|
end
|
108
|
-
|
117
|
+
|
109
118
|
it "should NOT be included in #expired" do
|
110
|
-
SpanModel.expired_on(
|
111
|
-
|
119
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
120
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
112
121
|
end
|
113
122
|
end
|
114
|
-
|
123
|
+
|
115
124
|
context "E) start_date == query_date & end_date > query_date" do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
125
|
+
let(:start_date) { span_e[0] }
|
126
|
+
let(:end_date) { span_e[1] }
|
127
|
+
|
120
128
|
it "should be included in #current" do
|
121
|
-
SpanModel.current_on(
|
122
|
-
|
129
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
130
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
123
131
|
end
|
124
|
-
|
132
|
+
|
125
133
|
it "should NOT be included in #future" do
|
126
|
-
SpanModel.future_on(
|
127
|
-
|
134
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
135
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
128
136
|
end
|
129
|
-
|
137
|
+
|
130
138
|
it "should NOT be included in #expired" do
|
131
|
-
SpanModel.expired_on(
|
132
|
-
|
139
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
140
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
133
141
|
end
|
134
142
|
end
|
135
|
-
|
143
|
+
|
136
144
|
context "F) start_date > query_date & end_date > query_date" do
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
145
|
+
let(:start_date) { span_f[0] }
|
146
|
+
let(:end_date) { span_f[1] }
|
147
|
+
|
141
148
|
it "should NOT be included in #current" do
|
142
|
-
SpanModel.current_on(
|
143
|
-
|
149
|
+
expect(SpanModel.current_on(query_date)).not_to include(span_model)
|
150
|
+
expect(span_model.current_on?(query_date)).to be_falsey
|
144
151
|
end
|
145
|
-
|
152
|
+
|
146
153
|
it "should be included in #future" do
|
147
|
-
SpanModel.future_on(
|
148
|
-
|
154
|
+
expect(SpanModel.future_on(query_date)).to include(span_model)
|
155
|
+
expect(span_model.future_on?(query_date)).to be_truthy
|
149
156
|
end
|
150
|
-
|
157
|
+
|
151
158
|
it "should NOT be included in #expired" do
|
152
|
-
SpanModel.expired_on(
|
153
|
-
|
159
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
160
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
154
161
|
end
|
155
162
|
end
|
156
|
-
|
163
|
+
|
157
164
|
context "G) start_date < query_date & end_date == nil" do
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
165
|
+
let(:start_date) { span_g[0] }
|
166
|
+
let(:end_date) { span_g[1] }
|
167
|
+
|
162
168
|
it "should be included in #current" do
|
163
|
-
SpanModel.current_on(
|
164
|
-
|
169
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
170
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
165
171
|
end
|
166
|
-
|
172
|
+
|
167
173
|
it "should NOT be included in #future" do
|
168
|
-
SpanModel.future_on(
|
169
|
-
|
174
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
175
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
170
176
|
end
|
171
|
-
|
177
|
+
|
172
178
|
it "should NOT be included in #expired" do
|
173
|
-
SpanModel.expired_on(
|
174
|
-
|
179
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
180
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
175
181
|
end
|
176
182
|
end
|
177
|
-
|
183
|
+
|
178
184
|
context "H) start_date == query_date & end_date == nil" do
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
185
|
+
let(:start_date) { span_h[0] }
|
186
|
+
let(:end_date) { span_h[1] }
|
187
|
+
|
183
188
|
it "should be included in #current" do
|
184
|
-
SpanModel.current_on(
|
185
|
-
|
189
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
190
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
186
191
|
end
|
187
|
-
|
192
|
+
|
188
193
|
it "should NOT be included in #future" do
|
189
|
-
SpanModel.future_on(
|
190
|
-
|
194
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
195
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
191
196
|
end
|
192
|
-
|
197
|
+
|
193
198
|
it "should NOT be included in #expired" do
|
194
|
-
SpanModel.expired_on(
|
195
|
-
|
199
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
200
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
196
201
|
end
|
197
202
|
end
|
198
|
-
|
203
|
+
|
199
204
|
context "I) start_date > query_date & end_date == nil" do
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
205
|
+
let(:start_date) { span_i[0] }
|
206
|
+
let(:end_date) { span_i[1] }
|
207
|
+
|
204
208
|
it "should NOT be included in #current" do
|
205
|
-
SpanModel.current_on(
|
206
|
-
|
209
|
+
expect(SpanModel.current_on(query_date)).not_to include(span_model)
|
210
|
+
expect(span_model.current_on?(query_date)).to be_falsey
|
207
211
|
end
|
208
|
-
|
212
|
+
|
209
213
|
it "should be included in #future" do
|
210
|
-
SpanModel.future_on(
|
211
|
-
|
214
|
+
expect(SpanModel.future_on(query_date)).to include(span_model)
|
215
|
+
expect(span_model.future_on?(query_date)).to be_truthy
|
212
216
|
end
|
213
|
-
|
217
|
+
|
214
218
|
it "should NOT be included in #expired" do
|
215
|
-
SpanModel.expired_on(
|
216
|
-
|
219
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
220
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
217
221
|
end
|
218
222
|
end
|
219
|
-
|
223
|
+
|
220
224
|
context "J) start_date == nil & end_date < query_date" do
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
+
let(:start_date) { span_j[0] }
|
226
|
+
let(:end_date) { span_j[1] }
|
227
|
+
|
225
228
|
it "should NOT be included in #current" do
|
226
|
-
SpanModel.current_on(
|
227
|
-
|
229
|
+
expect(SpanModel.current_on(query_date)).not_to include(span_model)
|
230
|
+
expect(span_model.current_on?(query_date)).to be_falsey
|
228
231
|
end
|
229
|
-
|
232
|
+
|
230
233
|
it "should NOT be included in #future" do
|
231
|
-
SpanModel.future_on(
|
232
|
-
|
234
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
235
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
233
236
|
end
|
234
|
-
|
237
|
+
|
235
238
|
it "should be included in #expired" do
|
236
|
-
SpanModel.expired_on(
|
237
|
-
|
239
|
+
expect(SpanModel.expired_on(query_date)).to include(span_model)
|
240
|
+
expect(span_model.expired_on?(query_date)).to be_truthy
|
238
241
|
end
|
239
242
|
end
|
240
|
-
|
243
|
+
|
241
244
|
context "K) start_date == nil & end_date == query_date" do
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
245
|
+
let(:start_date) { span_k[0] }
|
246
|
+
let(:end_date) { span_k[1] }
|
247
|
+
|
246
248
|
it "should be included in #current" do
|
247
|
-
SpanModel.current_on(
|
248
|
-
|
249
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
250
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
249
251
|
end
|
250
|
-
|
252
|
+
|
251
253
|
it "should NOT be included in #future" do
|
252
|
-
SpanModel.future_on(
|
253
|
-
|
254
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
255
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
254
256
|
end
|
255
|
-
|
257
|
+
|
256
258
|
it "should NOT be included in #expired" do
|
257
|
-
SpanModel.expired_on(
|
258
|
-
|
259
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
260
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
259
261
|
end
|
260
262
|
end
|
261
|
-
|
263
|
+
|
262
264
|
context "L) start_date == nil & end_date > query_date" do
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
265
|
+
let(:start_date) { span_l[0] }
|
266
|
+
let(:end_date) { span_l[1] }
|
267
|
+
|
267
268
|
it "should be included in #current" do
|
268
|
-
SpanModel.current_on(
|
269
|
-
|
269
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
270
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
270
271
|
end
|
271
|
-
|
272
|
+
|
272
273
|
it "should NOT be included in #future" do
|
273
|
-
SpanModel.future_on(
|
274
|
-
|
274
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
275
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
275
276
|
end
|
276
|
-
|
277
|
+
|
277
278
|
it "should NOT be included in #expired" do
|
278
|
-
SpanModel.expired_on(
|
279
|
-
|
279
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
280
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
280
281
|
end
|
281
282
|
end
|
282
|
-
|
283
|
+
|
283
284
|
context "M) start_date == nil & end_date == nil" do
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
285
|
+
let(:start_date) { span_m[0] }
|
286
|
+
let(:end_date) { span_m[1] }
|
287
|
+
|
288
288
|
it "should be included in #current" do
|
289
|
-
SpanModel.current_on(
|
290
|
-
|
289
|
+
expect(SpanModel.current_on(query_date)).to include(span_model)
|
290
|
+
expect(span_model.current_on?(query_date)).to be_truthy
|
291
291
|
end
|
292
|
-
|
292
|
+
|
293
293
|
it "should NOT be included in #future" do
|
294
|
-
SpanModel.future_on(
|
295
|
-
|
294
|
+
expect(SpanModel.future_on(query_date)).not_to include(span_model)
|
295
|
+
expect(span_model.future_on?(query_date)).to be_falsey
|
296
296
|
end
|
297
|
-
|
297
|
+
|
298
298
|
it "should NOT be included in #expired" do
|
299
|
-
SpanModel.expired_on(
|
300
|
-
|
299
|
+
expect(SpanModel.expired_on(query_date)).not_to include(span_model)
|
300
|
+
expect(span_model.expired_on?(query_date)).to be_falsey
|
301
301
|
end
|
302
302
|
end
|
303
303
|
end
|
304
|
-
end
|
304
|
+
end
|