samvera / active_fedora

A Rails interface to the Fedora repository, akin to ActiveModel
Other
54 stars 63 forks source link

Fix `#blank?` and `#present?` #1361

Closed no-reply closed 6 years ago

no-reply commented 6 years ago

Rails' Object#blank? and Object#present? return true for empty Enumerable objects. This is because they don't implement #empty?.

Our prior effort to optimize these methods for Relation by delegating them to #each broke them for this reason, always returning true. Instead, we delegate #any? which does exist, and implement Relation#empty? directly as its inverse. Rails provides the #blank? and #present? implementations.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.02%) to 89.59% when pulling 34ba358d993d4a9debcfbea6b0bc3617b3d46b7a on fix-blank-present into 0e2356dd19e012f642b70e5f55d418cda0748f64 on master.