Skip to content

Commit c0f1f6a

Browse files
committed
fix
1 parent 6c5a5c2 commit c0f1f6a

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

lib/table_sync/utils/schema/validator/type.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def valid?(value)
2121
end
2222
end
2323

24-
class String < Type
24+
class Text < Type
2525
def valid?(value)
2626
return true if value.is_a?(::String)
2727
return true if value.is_a?(::Symbol)
@@ -41,10 +41,10 @@ def initialize(display_name)
4141
# @!method valid?
4242

4343
# rubocop:disable Layout/ClassStructure
44-
DECIMAL = Decimal.new("Decimal").freeze
45-
DATETIME = DateTime.new("DateTime").freeze
46-
BOOLEAN = Boolean.new("Boolean").freeze
47-
STRING = String.new("String").freeze
44+
DECIMAL = Decimal.new("Decimal")
45+
DATETIME = DateTime.new("DateTime")
46+
BOOLEAN = Boolean.new("Boolean")
47+
STRING = Text.new("String")
4848
# rubocop:enable Layout/ClassStructure
4949

5050
def validate(value)

spec/receiving/models_spec.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@
611611
end
612612

613613
context "Decimal" do
614-
["1.5", 1.5, 1, "-1.567", 1.5.to_d, Time.current].each do |value|
614+
values = ["1.5", 1.5, 1, "-1.567", BigDecimal("1.5"), Time.current]
615+
values.each do |value|
615616
it_behaves_like "returns success", :decimal, value
616617
end
617618

@@ -622,12 +623,13 @@
622623
end
623624

624625
context "DateTime" do
625-
[
626+
values = [
626627
"01.01.2010",
627628
Time.current, Date.current, DateTime.current,
628629
Sequel::SQLTime.new("2010-10-10 10:10:10"),
629-
123, 123.5, 123.5.to_d
630-
].each do |value|
630+
123, 123.5, BigDecimal("123.5")
631+
]
632+
values.each do |value|
631633
it_behaves_like "returns success", :datetime, value
632634
end
633635

@@ -640,11 +642,12 @@
640642
end
641643

642644
context "Boolean" do
643-
[
645+
values = [
644646
true, false,
645647
0, 1,
646648
"true", "false", "TRUE", "False", "tRuE", "t", "f", "on", "off", "0", "1"
647-
].each do |value|
649+
]
650+
values.each do |value|
648651
it_behaves_like "returns success", :boolean, value
649652
end
650653

@@ -658,12 +661,13 @@
658661
end
659662

660663
context "String" do
661-
[
664+
values = [
662665
true, false,
663666
"asfdnk", "1.5", "-1", "t", "f", :test,
664-
45435.to_d, 1, 1.5, -1, 0,
667+
BigDecimal(45435), 1, 1.5, -1, 0,
665668
Time.current, Sequel::SQLTime.new("2010-10-10 10:10:10")
666-
].each do |value|
669+
]
670+
values.each do |value|
667671
it_behaves_like "returns success", :string, value
668672
end
669673

0 commit comments

Comments
 (0)