Fix PDF title PR and add test case for PDF titles (#833)
This commit is contained in:
parent
3a1815a19f
commit
63d73ab80d
|
@ -976,7 +976,7 @@ class Story < ApplicationRecord
|
|||
end
|
||||
|
||||
def fetched_attributes_pdf
|
||||
return @fetched_attributes = {} if @fetched_response.body >= 5.megabytes
|
||||
return @fetched_attributes = {} if @fetched_response.body.length >= 5.megabytes
|
||||
|
||||
# pdf-reader only accepts a stream or filename
|
||||
pdf_stream = StringIO.new(@fetched_response.body)
|
||||
|
|
Binary file not shown.
|
@ -161,6 +161,14 @@ describe Story do
|
|||
return res
|
||||
end
|
||||
|
||||
it "can fetch PDF titles properly" do
|
||||
content = File.read(story_directory + "titled.pdf")
|
||||
res = fake_response(content, "application/pdf")
|
||||
s = build(:story)
|
||||
s.fetched_response = res
|
||||
expect(s.fetched_attributes[:title]).to eq("Taking a Long Look at QUIC")
|
||||
end
|
||||
|
||||
it "can fetch its title properly" do
|
||||
content = File.read(story_directory + "title_ampersand.html")
|
||||
res = fake_response(content, "text/html")
|
||||
|
|
Loading…
Reference in New Issue