A platform for community discussion. Free, open, simple.
DEV: Add plugin_file_from_fixtures helper (#26359)
Martin Brennan0bbca318f270
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex f99d5fd898e..5be28c50b80 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -804,12 +804,16 @@ def unfreeze_timeTrackTimeStub.unstub(:stubbed)end-def file_from_fixtures(filename, directory = "images")+def file_from_fixtures(filename, directory = "images", root_path = "#{Rails.root}/spec/fixtures")tmp_file_path = File.join(concurrency_safe_tmp_dir, SecureRandom.hex << filename)- FileUtils.cp("#{Rails.root}/spec/fixtures/#{directory}/#{filename}", tmp_file_path)+ FileUtils.cp("#{root_path}/#{directory}/#{filename}", tmp_file_path)File.new(tmp_file_path)end+def plugin_file_from_fixtures(plugin_directory, filename, directory = "images")+ file_from_fixtures(filename, directory, "#{Rails.root}/plugins/#{plugin_directory}/spec/fixtures")+end+def file_from_contents(contents, filename, directory = "images")tmp_file_path = File.join(concurrency_safe_tmp_dir, SecureRandom.hex << filename)File.write(tmp_file_path, contents)