class Shoulda::Matchers::ActiveModel::ValidateUniquenessOfMatcher
def validate_after_scope_change?
to a value that's already taken. An alternative implementation
TODO: There is a chance that we could change the scoped field
def validate_after_scope_change? if @options[:scopes].blank? true else @options[:scopes].all? do |scope| previous_value = existing.send(scope) # Assume the scope is a foreign key if the field is nil previous_value ||= correct_type_for_column(@subject.class.columns_hash[scope.to_s]) next_value = if previous_value.respond_to?(:next) previous_value.next else previous_value.to_s.next end @subject.send("#{scope}=", next_value) if allows_value_of(existing_value, @expected_message) @subject.send("#{scope}=", previous_value) @failure_message_for_should_not << " (with different value of #{scope})" true else @failure_message_for_should << " (with different value of #{scope})" false end end end end