Skip to content

Commit

Permalink
Merge branch 'seek-1.16'
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Feb 14, 2025
2 parents fa05419 + cc69005 commit 36a384f
Show file tree
Hide file tree
Showing 3 changed files with 34 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
26 changes: 26 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,30 @@ 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

test 'update data file with nil content blob' do
df = FactoryBot.create(:data_file_with_no_content_blob, title: 'old title')
assert_nil df.content_blob
login_as(df.contributor)
put :update, params: { id: df, data_file: { title: 'new title' } }
assert_response :redirect
df.reload
assert_equal 'new title', df.title
end
end

0 comments on commit 36a384f

Please sign in to comment.