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 58689da4b..d1b458aba 100644 --- a/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb +++ b/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb @@ -830,7 +830,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 c165b394c..221cf44f3 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 @@ -830,6 +830,11 @@ include_context 'it supports scoped attributes of a certain type', 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',