Skip to content

Commit

Permalink
ChangeSet#multiple? returns false rather than nil.
Browse files Browse the repository at this point in the history
The rails tag helper interprets `required=>nil` as `"required"=>""`
which is a required field.
  • Loading branch information
jcoyne committed Oct 31, 2017
1 parent ec77913 commit fdb2516
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion valkyrie/lib/valkyrie/change_set.rb
Expand Up @@ -38,7 +38,7 @@ def multiple?(field)
# @param field [Symbol]
# @return [Boolean]
def required?(field)
self.class.definitions[field.to_s][:required]
self.class.definitions[field.to_s][:required] == true
end

# Quick setter for fields that should be in a changeset. Defaults to multiple,
Expand Down
3 changes: 2 additions & 1 deletion valkyrie/spec/valkyrie/change_set_spec.rb
Expand Up @@ -37,8 +37,9 @@ class ResourceChangeSet < Valkyrie::ChangeSet
it "is true when marked" do
expect(change_set.required?(:title)).to eq true
end

it "is false when not marked" do
expect(change_set.required?(:files)).not_to eq true
expect(change_set.required?(:files)).to eq false
end
end

Expand Down

0 comments on commit fdb2516

Please sign in to comment.