Skip to content

Commit

Permalink
Prevent initializing nil attributes to []
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Aug 2, 2022
1 parent 4926e8d commit 352304d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/tess/api/material.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def initialize(params = {})
# TODO: Check if this is really necessary:
[:scientific_topic_names, :operation_names, :collection_ids, :keywords, :contributors,
:authors, :target_audience, :node_ids, :external_resources_attributes].each do |attr|
next unless params.key?(attr)
params[attr] = [params[attr]].flatten.compact
end

Expand Down
2 changes: 1 addition & 1 deletion tess_api_client.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'tess_api_client'
s.version = '0.4.1'
s.version = '0.4.2'
s.date = '2022-07-28'
s.summary = 'Libraries for uploading files to https://github.com/ElixirTeSS/TeSS'
s.description = 'Uses the a Custom RoR API on https://tess.elixir-europe.org to upload data in the format being used by the TeSS project.'
Expand Down
5 changes: 5 additions & 0 deletions test/material_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,9 @@ class MaterialTest < Test::Unit::TestCase
assert_include mat.errors.keys, 'url'
end
end

test 'do not convert missing attributes to empty arrays' do
material = Tess::API::Material.new
assert_nil material.keywords
end
end

0 comments on commit 352304d

Please sign in to comment.