Allow testing remove metadata from PDF
In order to test that we remove metadata from PDF we need add "pdf-reader" gem. With this gem we can check the info from the PDF and ensure that this info is removed.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -86,6 +86,7 @@ group :test do
|
|||||||
gem "capybara", "~> 3.39.2"
|
gem "capybara", "~> 3.39.2"
|
||||||
gem "capybara-webmock", "~> 0.7.0"
|
gem "capybara-webmock", "~> 0.7.0"
|
||||||
gem "email_spec", "~> 2.2.2"
|
gem "email_spec", "~> 2.2.2"
|
||||||
|
gem "pdf-reader"
|
||||||
gem "rspec-rails", "~> 5.1.2"
|
gem "rspec-rails", "~> 5.1.2"
|
||||||
gem "selenium-webdriver", "~> 4.13.1"
|
gem "selenium-webdriver", "~> 4.13.1"
|
||||||
gem "simplecov", "~> 0.22.0", require: false
|
gem "simplecov", "~> 0.22.0", require: false
|
||||||
|
|||||||
12
Gemfile.lock
12
Gemfile.lock
@@ -6,6 +6,7 @@ GEM
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
Ascii85 (1.1.0)
|
||||||
actioncable (6.1.7.6)
|
actioncable (6.1.7.6)
|
||||||
actionpack (= 6.1.7.6)
|
actionpack (= 6.1.7.6)
|
||||||
activesupport (= 6.1.7.6)
|
activesupport (= 6.1.7.6)
|
||||||
@@ -70,6 +71,7 @@ GEM
|
|||||||
acts_as_votable (0.14.0)
|
acts_as_votable (0.14.0)
|
||||||
addressable (2.8.5)
|
addressable (2.8.5)
|
||||||
public_suffix (>= 2.0.2, < 6.0)
|
public_suffix (>= 2.0.2, < 6.0)
|
||||||
|
afm (0.2.2)
|
||||||
ahoy_matey (4.2.1)
|
ahoy_matey (4.2.1)
|
||||||
activesupport (>= 5.2)
|
activesupport (>= 5.2)
|
||||||
device_detector
|
device_detector
|
||||||
@@ -259,6 +261,7 @@ GEM
|
|||||||
gyoku (1.4.0)
|
gyoku (1.4.0)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
rexml (~> 3.0)
|
rexml (~> 3.0)
|
||||||
|
hashery (2.1.2)
|
||||||
hashie (5.0.0)
|
hashie (5.0.0)
|
||||||
highline (2.0.3)
|
highline (2.0.3)
|
||||||
htmlentities (4.3.4)
|
htmlentities (4.3.4)
|
||||||
@@ -412,6 +415,12 @@ GEM
|
|||||||
parser (3.2.2.3)
|
parser (3.2.2.3)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
|
pdf-reader (2.11.0)
|
||||||
|
Ascii85 (~> 1.0)
|
||||||
|
afm (~> 0.2.1)
|
||||||
|
hashery (~> 2.0)
|
||||||
|
ruby-rc4
|
||||||
|
ttfunk
|
||||||
pg (1.4.3)
|
pg (1.4.3)
|
||||||
pg_search (2.3.6)
|
pg_search (2.3.6)
|
||||||
activerecord (>= 5.2)
|
activerecord (>= 5.2)
|
||||||
@@ -549,6 +558,7 @@ GEM
|
|||||||
rubocop-capybara (~> 2.17)
|
rubocop-capybara (~> 2.17)
|
||||||
rubocop-factory_bot (~> 2.22)
|
rubocop-factory_bot (~> 2.22)
|
||||||
ruby-progressbar (1.13.0)
|
ruby-progressbar (1.13.0)
|
||||||
|
ruby-rc4 (0.1.5)
|
||||||
ruby-vips (2.1.4)
|
ruby-vips (2.1.4)
|
||||||
ffi (~> 1.12)
|
ffi (~> 1.12)
|
||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
@@ -630,6 +640,7 @@ GEM
|
|||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
timeout (0.4.1)
|
timeout (0.4.1)
|
||||||
tomlrb (2.0.3)
|
tomlrb (2.0.3)
|
||||||
|
ttfunk (1.7.0)
|
||||||
turbolinks (5.2.1)
|
turbolinks (5.2.1)
|
||||||
turbolinks-source (~> 5.2)
|
turbolinks-source (~> 5.2)
|
||||||
turbolinks-source (5.2.0)
|
turbolinks-source (5.2.0)
|
||||||
@@ -739,6 +750,7 @@ DEPENDENCIES
|
|||||||
omniauth-rails_csrf_protection (~> 1.0.1)
|
omniauth-rails_csrf_protection (~> 1.0.1)
|
||||||
omniauth-twitter (~> 1.4.0)
|
omniauth-twitter (~> 1.4.0)
|
||||||
paranoia (~> 2.6.2)
|
paranoia (~> 2.6.2)
|
||||||
|
pdf-reader
|
||||||
pg (~> 1.4.3)
|
pg (~> 1.4.3)
|
||||||
pg_search (~> 2.3.6)
|
pg_search (~> 2.3.6)
|
||||||
pronto (~> 0.11.1)
|
pronto (~> 0.11.1)
|
||||||
|
|||||||
BIN
spec/fixtures/files/logo_with_metadata.pdf
vendored
Normal file
BIN
spec/fixtures/files/logo_with_metadata.pdf
vendored
Normal file
Binary file not shown.
27
spec/system/documents_spec.rb
Normal file
27
spec/system/documents_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe "Documents" do
|
||||||
|
describe "Metadata" do
|
||||||
|
scenario "download document without metadata" do
|
||||||
|
login_as(create(:user))
|
||||||
|
visit new_proposal_path
|
||||||
|
|
||||||
|
fill_in "Proposal title", with: "debate"
|
||||||
|
fill_in "Proposal summary", with: "In summary, what we want is..."
|
||||||
|
fill_in "Full name of the person submitting the proposal", with: "Isabel Garcia"
|
||||||
|
documentable_attach_new_file(file_fixture("logo_with_metadata.pdf"))
|
||||||
|
check "I agree to the Privacy Policy and the Terms and conditions of use"
|
||||||
|
|
||||||
|
click_button "Create proposal"
|
||||||
|
|
||||||
|
io = URI.parse("#{app_host}#{polymorphic_path(Document.last.attachment)}").open
|
||||||
|
reader = PDF::Reader.new(io)
|
||||||
|
|
||||||
|
expect(reader.info[:Keywords]).not_to eq "Test Metadata"
|
||||||
|
expect(reader.info[:Author]).not_to eq "Test Developer"
|
||||||
|
expect(reader.info[:Title]).not_to eq "logo_with_metadata.pdf"
|
||||||
|
expect(reader.info[:Producer]).not_to eq "Test Producer"
|
||||||
|
expect(reader.info).to eq({})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user