test/attributes_test.rb in gotime-cassandra_object-2.6.0 vs test/attributes_test.rb in gotime-cassandra_object-2.6.1

- old
+ new

@@ -6,13 +6,16 @@ class CustomCoder < CassandraObject::Types::BaseType end class TestIssue < CassandraObject::Base - self.column_family = 'Issue' + key :uuid + self.column_family = 'Issues' + attribute :custom_column, type: CustomType, coder: CustomCoder integer :price + json :orders end class TestChildIssue < TestIssue string :description end @@ -20,9 +23,17 @@ test 'custom attribute definer' do model_attribute = TestIssue.model_attributes[:custom_column] assert_kind_of CustomCoder, model_attribute.coder assert_equal CustomType, model_attribute.expected_type + end + + test 'json attribute' do + issue = TestIssue.create! orders: {'a' => 'b'} + + issue = TestIssue.find issue.id + + assert_equal({'a' => 'b'}, issue.orders) end test 'instantiate_attribute' do assert_equal 1, TestIssue.instantiate_attribute(TestIssue.new, 'price', 1) assert_equal 1, TestIssue.instantiate_attribute(TestIssue.new, :price, 1)