Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 623805f

Browse files
committedFeb 19, 2025··
add testcase
1 parent bec29c4 commit 623805f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎lib/attr_json/attribute_definition.rb

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def self.lookup_type(type)
132132
if type == :datetime || type == :time
133133
lookup_kwargs[:precision] = ActiveSupport::JSON::Encoding.time_precision
134134
end
135-
136135
type = ActiveRecord::Type.lookup(type, **lookup_kwargs)
137136
elsif !(type.is_a?(ActiveModel::Type::Value) || type.is_a?(ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter))
138137
raise ArgumentError, "Second argument (#{type}) must be a symbol or instance of an ActiveModel::Type::Value subclass"

‎spec/record_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,17 @@ def cast(value) ; value ; end
242242

243243
it "can define without triggering a db connection" do
244244
expect(ActiveRecord::Base).not_to receive(:connection)
245+
expect(ActiveRecord::Type).not_to receive(:adapter_name_from)
245246

246247
Class.new(ActiveRecord::Base) do
247248
include AttrJson::Record
248249

249250
self.table_name = "products"
250251
attr_json :value, :string
252+
attr_json :datetime_value, :datetime
253+
attr_json :time_value, :time
251254
end
255+
252256
end
253257

254258
it "has registered attributes on registry" do

0 commit comments

Comments
 (0)
Please sign in to comment.