default_value_for icon indicating copy to clipboard operation
default_value_for copied to clipboard

Bug in blank attribute detection w/o column backing

Open chrisarcand opened this issue 7 years ago • 2 comments

https://github.com/FooBarWidget/default_value_for/blob/c52d291c0070c72896926c6dd9df9c6b90e81147/lib/default_value_for.rb#L159-L170

The above code has a few more edge cases that are missed, specifically with the second two cases in the outer conditional where the attribute is not backed by a database column. The next two cases must account for the same issue (attribute can either be a boolean where false is not 'blank', it's a set value, but false.nil? == true, or a collection that is empty via blank?).

This whole thing should be cleaned up, with perhaps a few comments explaining each case.

See https://github.com/FooBarWidget/default_value_for/commit/d155ba71776cb36308a4b73182b8068128b9fab8#commitcomment-30274475

cc/ @romaind

chrisarcand avatar Aug 24 '18 02:08 chrisarcand

@chrisarcand thanks a lot for taking what I mentionned into account. I'll do some thinking and try to come up with a solution in the upcoming week

romaind avatar Aug 27 '18 09:08 romaind

@chrisarcand currently working on that it seems you've not tested the false.nil? case as replacing nil? with blank? line 167 doesn't break tests I'll add that. Or maybe you did, but weird that the tests don't break then

romaind avatar Aug 29 '18 07:08 romaind