gitlab-org--gitlab-foss/spec/support/helpers/file_mover_helpers.rb
Mark Chao d72b1cd0b5 Check snippet attached file to be moved is within designated directory
Previously one could move any temp/ sub folder around.
2019-02-21 16:44:44 +08:00

12 lines
392 B
Ruby

# frozen_string_literal: true
module FileMoverHelpers
def stub_file_mover(file_path, stub_real_path: nil)
file_name = File.basename(file_path)
allow(Pathname).to receive(:new).and_call_original
expect_next_instance_of(Pathname, a_string_including(file_name)) do |pathname|
allow(pathname).to receive(:realpath) { stub_real_path || pathname.cleanpath }
end
end
end