diff --git a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb index ad298b145..85cc81d2b 100644 --- a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +++ b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb @@ -820,7 +820,7 @@ def next_scalar_value_for(scope, previous_value) elsif previous_value.respond_to?(:next) previous_value.next elsif previous_value.respond_to?(:to_datetime) - previous_value.to_datetime.next + previous_value.to_datetime.in(60).next elsif boolean_value?(previous_value) !previous_value else 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 f39ef9575..95725c93f 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,11 @@ column_type: :datetime 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 + end + context 'when one of the scoped attributes is a datetime column (using Time)' do include_context 'it supports scoped attributes of a certain type', column_type: :datetime,