diff --git a/lib/shoulda/matchers/util.rb b/lib/shoulda/matchers/util.rb index 46d512637..771fb1daa 100644 --- a/lib/shoulda/matchers/util.rb +++ b/lib/shoulda/matchers/util.rb @@ -94,7 +94,7 @@ def self.dummy_value_for(column_type, array: false) 0 when :date Date.new(2100, 1, 1) - when :datetime, :timestamp + when :datetime, :timestamp, :timestamptz DateTime.new(2100, 1, 1) when :time Time.new(2000, 1, 1) diff --git a/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb b/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb index 53746de42..68886a128 100644 --- a/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb +++ b/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb @@ -829,6 +829,16 @@ column_type: :datetime end + context 'when one of the scoped attributes is a timestamp column (using DateTime)' do + include_context 'it supports scoped attributes of a certain type', + column_type: :timestamp + end + + context 'when one of the scoped attributes is a timestamp with time zone column (using DateTime)' do + include_context 'it supports scoped attributes of a certain type', + column_type: :timestamptz + end + context 'when one of the scoped attributes is a time column (using Time)' do include_context 'it supports scoped attributes of a certain type', column_type: :time