Skip to content

Swap #empty? with #blank? and add tests#10045

Merged
jmhooper merged 3 commits intomainfrom
jmhooper-add-back-12039
Feb 6, 2024
Merged

Swap #empty? with #blank? and add tests#10045
jmhooper merged 3 commits intomainfrom
jmhooper-add-back-12039

Conversation

@jmhooper
Copy link
Contributor

@jmhooper jmhooper commented Feb 6, 2024

The commit on here that was un-reverted was problematic because of a NoMethodError when calling empty? on nil here:

validates :acr_values, presence: true, if: ->(form) { form.vtr.empty? }

This commit replaces #empty? with #blank? which will work on nil. Additionally the #parse_vtr method was modified to consistently return nil if either a vtr param is not provided or the vtr param is not enabled.

Tests were added to cover this case.

The commit that was un-reverted was problematic because of a `NoMethodError` when calling `empty?` on `nil` here:

```ruby
validates :acr_values, presence: true, if: ->(form) { form.vtr.empty? }
```

This commit replaces `#empty?` with `#blank?` which will work on nil. Additionally the `#parse_vtr` method was modified to consistently return `nil` if either a `vtr` param is not provided or the `vtr` param is not enabled.

Tests were added to cover this case.

[skip changelog]
@jmhooper jmhooper requested review from a team, mitchellhenke and zachmargolis February 6, 2024 17:53
@jmhooper jmhooper merged commit c9ef961 into main Feb 6, 2024
@jmhooper jmhooper deleted the jmhooper-add-back-12039 branch February 6, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants