acts_as_span 0.0.5 → 0.0.6
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 +7 -0
- data/.gitignore +11 -3
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +0 -3
- data/README.rdoc +4 -16
- data/Rakefile +5 -1
- data/acts_as_span.gemspec +21 -5
- data/lib/acts_as_span.rb +55 -98
- data/lib/acts_as_span/no_overlap_validator.rb +51 -0
- data/lib/acts_as_span/span_instance.rb +17 -33
- data/lib/acts_as_span/span_instance/status.rb +12 -27
- data/lib/acts_as_span/span_instance/validations.rb +5 -53
- data/lib/acts_as_span/span_klass.rb +11 -19
- data/lib/acts_as_span/span_klass/status.rb +33 -12
- data/lib/acts_as_span/version.rb +2 -2
- data/lib/acts_as_span/within_parent_date_span_validator.rb +42 -0
- data/spec/lib/acts_as_span_spec.rb +18 -36
- data/spec/lib/delegation_spec.rb +45 -78
- data/spec/lib/no_overlap_validator_spec.rb +96 -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 +5 -30
- data/spec/lib/within_parent_date_span_validator_spec.rb +115 -0
- data/spec/spec_helper.rb +19 -6
- data/spec/spec_models.rb +69 -0
- metadata +158 -58
- 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,96 @@
|
|
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 'an object with a single parent' do
|
46
|
+
let(:child_class) { OneParentChild }
|
47
|
+
|
48
|
+
context 'valid cases' do
|
49
|
+
let(:new_child_start_date) { Date.current }
|
50
|
+
let(:new_child_end_date) { Date.current + 1 }
|
51
|
+
|
52
|
+
it 'allows overlapping spans on for associated records with different parents' do
|
53
|
+
expect(new_child).to be_valid
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'invalid cases' do
|
58
|
+
let(:new_child_start_date) { Date.current - 2 }
|
59
|
+
let(:new_child_end_date) { Date.current + 3 }
|
60
|
+
|
61
|
+
it 'does not allow overlapping spans siblings with same parents' do
|
62
|
+
expect(new_child).not_to be_valid
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'an object with multiple parents' do
|
68
|
+
let(:child_class) { TwoParentChild }
|
69
|
+
|
70
|
+
before do
|
71
|
+
all_siblings.each do |sibling|
|
72
|
+
sibling.update_attributes(papa: papa)
|
73
|
+
end
|
74
|
+
|
75
|
+
new_child.papa = papa
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'valid cases' do
|
79
|
+
let(:new_child_start_date) { brother_end_date + 1 }
|
80
|
+
let(:new_child_end_date) { sister_start_date - 1 }
|
81
|
+
|
82
|
+
it 'allows overlapping spans on for associated records with different parents' do
|
83
|
+
expect(new_child).to be_valid
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'invalid cases' do
|
88
|
+
let(:new_child_start_date) { brother_start_date }
|
89
|
+
let(:new_child_end_date) { sister_end_date }
|
90
|
+
|
91
|
+
it 'does not allow overlapping spans siblings with same parents' do
|
92
|
+
expect(new_child).not_to be_valid
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
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
|