Skip to content

Commit 82a3ca8

Browse files
authored
Bump to 4.1.5 (#73)
* bump to 4.1.5 * avoid warnings and activesupport null ref * add test
1 parent 0bf4537 commit 82a3ca8

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/subroutine.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

33
require "active_model"
4+
require "active_support"
45
require "active_support/concern"
56
require "active_support/core_ext/hash/indifferent_access"
67
require "active_support/core_ext/module/redefine_method"
@@ -38,7 +39,9 @@ def self.preserve_time_precision=(bool)
3839
end
3940

4041
def self.preserve_time_precision?
41-
!!@preserve_time_precision
42+
return !!@preserve_time_precision if defined?(@preserve_time_precision)
43+
44+
false
4245
end
4346

4447
end

lib/subroutine/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Subroutine
44

55
MAJOR = 4
66
MINOR = 1
7-
PATCH = 4
7+
PATCH = 5
88
PRE = nil
99

1010
VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")

test/subroutine/type_caster_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,20 @@ def test_time_inputs__with_seconds_precision
344344
assert_equal 0, op.time_input.usec
345345
end
346346

347+
def test_time_inputs__with_preserve_time_precision
348+
Subroutine.stubs(:preserve_time_precision?).returns(true)
349+
350+
time = Time.at(1678741605.123456).utc
351+
op.time_input = time
352+
assert_equal 2023, op.time_input.year
353+
assert_equal 3, op.time_input.month
354+
assert_equal 13, op.time_input.day
355+
assert_equal 21, op.time_input.hour
356+
assert_equal 6, op.time_input.min
357+
assert_equal 45, op.time_input.sec
358+
assert_equal 123456, op.time_input.usec
359+
end
360+
347361
def test_time_inputs__with_high_precision
348362
op.precise_time_input = nil
349363
assert_nil op.precise_time_input

0 commit comments

Comments
 (0)