1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

truncate screenshot filenames to avoid error

This commit is contained in:
Josi McClellan 2019-04-18 15:20:22 -05:00
parent 0f39a7488e
commit 51cb5d4a20
2 changed files with 10 additions and 1 deletions

View file

@ -39,7 +39,8 @@ module ActionDispatch
private private
def image_name def image_name
failed? ? "failures_#{method_name}" : method_name name = method_name[0...225]
failed? ? "failures_#{name}" : name
end end
def image_path def image_path

View file

@ -36,6 +36,14 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
end end
end end
test "image name truncates names over 225 characters" do
new_test = DrivenBySeleniumWithChrome.new("x" * 400)
Rails.stub :root, Pathname.getwd do
assert_equal Rails.root.join("tmp/screenshots/#{"x" * 225}.png").to_s, new_test.send(:image_path)
end
end
test "defaults to simple output for the screenshot" do test "defaults to simple output for the screenshot" do
new_test = DrivenBySeleniumWithChrome.new("x") new_test = DrivenBySeleniumWithChrome.new("x")
assert_equal "simple", new_test.send(:output_type) assert_equal "simple", new_test.send(:output_type)