Skip to content

Commit

Permalink
fix to handle viewing a data file with no content blob #2139
Browse files Browse the repository at this point in the history
also test for edit
  • Loading branch information
stuzart committed Feb 12, 2025
1 parent b847f06 commit 411f57b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/data_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def supports_spreadsheet_explore?

def zipped_folder?
return false if external_asset.is_a? OpenbisExternalAsset
content_blob.is_unzippable_datafile?
content_blob&.is_unzippable_datafile?
end

def matching_sample_type?
Expand Down
7 changes: 7 additions & 0 deletions test/factories/data_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
end
end
end

factory(:data_file_with_no_content_blob, parent: :data_file) do
after(:create) do |data_file|
data_file.content_blob = nil
data_file.save!
end
end

factory(:public_data_file, parent: :data_file) do
policy { FactoryBot.create(:downloadable_public_policy) }
Expand Down
16 changes: 16 additions & 0 deletions test/functional/data_files_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4415,4 +4415,20 @@ def register_content_blob(skip_provide_metadata:false)
assert flash[:error].include?('disabled')
end
end

test 'view data file with nil content blob' do
df = FactoryBot.create(:data_file_with_no_content_blob)
assert_nil df.content_blob
login_as(df.contributor)
get :show, params: { id: df }
assert_response :success
end

test 'edit data file with nil content blob' do
df = FactoryBot.create(:data_file_with_no_content_blob)
assert_nil df.content_blob
login_as(df.contributor)
get :edit, params: { id: df }
assert_response :success
end
end

0 comments on commit 411f57b

Please sign in to comment.