Skip to content

Commit

Permalink
Handle old data in assumed_us_public_domain?
Browse files Browse the repository at this point in the history
`KittenData` used to store the `data` field as `false` when it didn’t
have any data to store, it now assumes it will be a {}.
  • Loading branch information
pkqk committed Oct 22, 2015
1 parent 2ca0517 commit 256a23a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/kitten_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def source_extras
end

def assumed_us_public_domain?
data.fetch(:assumptions, []).include?(:us_public_domain)
data.fetch(:assumptions, []).include?(:us_public_domain) if data
end

def distributions
Expand Down
6 changes: 6 additions & 0 deletions test/unit/kitten_data_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ def kitten_data
refute kitten_data.assumed_us_public_domain?
end

test 'assumed_us_public_domain does not crash on old kitten data instances' do
#kitten_data = KittenData.new(url: 'http://catalog.data.gov/some_data')
kitten_data.data = false # old versions stored false instead of {}
refute kitten_data.assumed_us_public_domain?
end

%w[us-pd other-pd notspecified].each do |license_id|
test "data.gov assumptions are set for federal organizations with #{license_id} license" do
set_us_data
Expand Down

0 comments on commit 256a23a

Please sign in to comment.