Skip to content

Commit 32c2496

Browse files
committed
fix: add back downloads specs
That was a sinatra disposition header issue, not chrome that was opening pdf extension. The header was not set because public folder was handled by rack static and file was returned to chrome without disposition header making chrome extension to intercept pdf request.
1 parent ab4b95b commit 32c2496

3 files changed

Lines changed: 9 additions & 19 deletions

File tree

spec/downloads_spec.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@
44
let(:filename) { "attachment.pdf" }
55
let(:save_path) { "/tmp/ferrum" }
66

7-
def skip_browser_bug
8-
# Also https://github.com/puppeteer/puppeteer/issues/10161
9-
skip "https://bugs.chromium.org/p/chromium/issues/detail?id=1444729"
10-
end
11-
127
describe "#files" do
138
it "saves an attachment" do
14-
skip_browser_bug
15-
169
page.downloads.set_behavior(save_path: save_path)
1710
page.go_to("/#{filename}")
1811
page.downloads.wait
@@ -50,8 +43,6 @@ def skip_browser_bug
5043
describe "#set_behavior" do
5144
context "with absolute path" do
5245
it "saves an attachment" do
53-
skip_browser_bug
54-
5546
page.downloads.set_behavior(save_path: save_path)
5647
page.go_to("/#{filename}")
5748
page.downloads.wait
@@ -62,18 +53,14 @@ def skip_browser_bug
6253
end
6354

6455
it "saves no attachment when behavior is deny" do
65-
skip_browser_bug
66-
6756
page.downloads.set_behavior(save_path: save_path, behavior: :deny)
6857
page.downloads.wait { page.go_to("/#{filename}") }
6958

7059
expect(File.exist?("#{save_path}/#{filename}")).to be false
7160
end
7261

7362
it "saves an attachment on click" do
74-
skip_browser_bug
75-
76-
page.downloads.set_behavior(save_path: save_path)
63+
§ page.downloads.set_behavior(save_path: save_path)
7764
page.go_to("/attachment")
7865
page.downloads.wait { page.at_css("#download").click }
7966

spec/support/application.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
module Ferrum
66
class Application < Sinatra::Base
77
configure { set :protection, except: :frame_options }
8-
FERRUM_VIEWS = "#{File.dirname(__FILE__)}/views".freeze
9-
FERRUM_PUBLIC = "#{File.dirname(__FILE__)}/public".freeze
108

11-
set :root, File.dirname(__FILE__)
9+
FERRUM_APP = File.dirname(__FILE__)
10+
FERRUM_VIEWS = "#{FERRUM_APP}/views".freeze
11+
FERRUM_PUBLIC = "#{FERRUM_APP}/public".freeze
12+
13+
set :root, FERRUM_APP
1214
set :static, true
1315
set :raise_errors, true
1416
set :show_exceptions, false
@@ -65,8 +67,9 @@ def authorized?(login, password)
6567
end
6668

6769
get "/attachment.pdf" do
68-
attachment("attachment.pdf")
69-
send_file("attachment.pdf")
70+
send_file File.join(FERRUM_APP, "static", "attachment.pdf"),
71+
disposition: :attachment,
72+
filename: "attachment.pdf"
7073
end
7174

7275
get "/foo" do

0 commit comments

Comments
 (0)