github
0 of 18 new or added lines in 4 files covered. (0.0%)
3922 existing lines in 105 files now uncovered.0 of 4086 relevant lines covered (0.0%)
0.0 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
|
|
UNCOV
3
|
module NonOverlappable |
× |
4 |
|
|
UNCOV
5
|
extend ActiveSupport::Concern |
× |
6 |
|
|
UNCOV
7
|
included do
|
× |
UNCOV
8
|
validate :assert_not_overlapping
|
× |
UNCOV
9
|
end
|
× |
10 |
|
|
UNCOV
11
|
private |
× |
12 |
|
|
UNCOV
13
|
def assert_not_overlapping |
× |
UNCOV
14
|
scope = self.class.within(started_at, finished_at)
|
× |
UNCOV
15
|
scope = scope.where.not(id: id) if persisted? |
× |
UNCOV
16
|
if scope.exists?
|
× |
UNCOV
17
|
errors.add(:started_at, :must_not_overlap) |
× |
UNCOV
18
|
throw :abort
|
× |
UNCOV
19
|
end
|
× |
UNCOV
20
|
end
|
× |
21 |
|
|
UNCOV
22
|
module ClassMethods |
× |
23 |
|
|
UNCOV
24
|
def within(start, finish) |
× |
UNCOV
25
|
where("#{table_name}.finished_at > ? AND #{table_name}.started_at < ?", start, finish)
|
× |
UNCOV
26
|
end
|
× |
27 |
|
|
UNCOV
28
|
end
|
× |
29 |
|
|
UNCOV
30
|
end
|
× |