diff --git a/app/models/repository_cell.rb b/app/models/repository_cell.rb index 32ac210c6..93708f89d 100644 --- a/app/models/repository_cell.rb +++ b/app/models/repository_cell.rb @@ -80,7 +80,7 @@ class RepositoryCell < ApplicationRecord private def repository_column_data_type - if !repository_column || value_type != repository_column.data_type + if !repository_column || value.class.name != repository_column.data_type errors.add(:value_type, 'must match column data type') end end diff --git a/spec/factories/repository_date_time_values.rb b/spec/factories/repository_date_time_values.rb index b44c26c51..609ee1242 100644 --- a/spec/factories/repository_date_time_values.rb +++ b/spec/factories/repository_date_time_values.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true FactoryBot.define do - factory :repository_date_time_value do + factory :repository_date_time_value_base do created_by { create :user } last_modified_by { created_by } data { Time.zone.now } + end + factory :repository_date_time_value, parent: :repository_date_time_value_base, class: 'RepositoryDateTimeValue' do after(:build) do |value| value.repository_cell ||= build(:repository_cell, :date_time_value, repository_date_time_value: value) end diff --git a/spec/models/repository_date_time_value_spec.rb b/spec/models/repository_date_time_value_spec.rb index 607238209..3aadfeb48 100644 --- a/spec/models/repository_date_time_value_spec.rb +++ b/spec/models/repository_date_time_value_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe RepositoryDateTimeValue, type: :model do - let(:repository_date_time_value) { create :repository_date_time_value } + let(:repository_date_time_value) { build :repository_date_time_value } it 'is valid' do expect(repository_date_time_value).to be_valid