Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix downloadable? to account for other file types #3718

Merged
merged 7 commits into from
Aug 29, 2024

Conversation

johrstrom
Copy link
Contributor

fix downloadable? to account for other file types to work on #3026.

apps/dashboard/app/models/posix_file.rb Outdated Show resolved Hide resolved
apps/dashboard/app/models/posix_file.rb Outdated Show resolved Hide resolved
Comment on lines -6 to +7
delegate :basename, :descend, :parent, :join, :to_s, :read, :write, :mkdir, :directory?, :realpath, :pipe?, :readable?, to: :path
delegate :basename, :descend, :parent, :join, :to_s, :read, :write, :mkdir, to: :path
delegate :directory?, :realpath, :readable?, :file?, to: :path
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, this removes pipe? while adding file? and putting them on 2 lines.

@Oglopf
Copy link
Contributor

Oglopf commented Aug 28, 2024

This looks good but do we want to add a test for this? I didn't see anything for it in the test/models/files_test.rb file but wrote this and the change works as expected:

  test "cannot download files that are not downloadable?" do
    Dir.mktmpdir do |dir|
      file = File.join(dir, 'foo.text')
      FileUtils.touch(file)
      # make sure file is not readable, a condition of PosixFile#downloadable?
      FileUtils.chmod(0333, file)

      refute PosixFile.new(file).downloadable?
    end
  end

Unless the test is happening somewhere else that I missed.

@CSC-swesters
Copy link
Contributor

 test "cannot download files that are not downloadable?" do

@Oglopf Looks like a good test, but I'd change the title of it to cannot download files that are not readable, so that it's more descriptive.

@johrstrom
Copy link
Contributor Author

There's this system test:

test 'files that are not downloadable' do
that I can add to and add some unit tests too.

@Oglopf
Copy link
Contributor

Oglopf commented Aug 29, 2024

@johrstrom ah, I missed the systems test. I think that with a unit test in the files_test.rb would be good coverage for this. Makes me wonder if other posix_file coverage is lacking in testing.

Copy link
Contributor

@Oglopf Oglopf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@johrstrom johrstrom merged commit 8923ab8 into master Aug 29, 2024
26 checks passed
@johrstrom johrstrom deleted the fix-downloadable-files branch August 29, 2024 17:24
johrstrom added a commit that referenced this pull request Sep 5, 2024
Fix downloadable? to account for other file types like block devices.
johrstrom added a commit that referenced this pull request Sep 5, 2024
Fix downloadable? to account for other file types like block devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants