From 11f09c281cb552687fcee2bc14815e74a17f53ed Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 19 May 2025 09:55:05 +0200 Subject: [PATCH] Move test for check metadata to nested documentable system --- spec/system/documents_spec.rb | 28 ------------------------- spec/system/nested_documentable_spec.rb | 24 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 spec/system/documents_spec.rb diff --git a/spec/system/documents_spec.rb b/spec/system/documents_spec.rb deleted file mode 100644 index b1abac580..000000000 --- a/spec/system/documents_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -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_new_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" - - expect(page).to have_content "Proposal created successfully" - - io = URI.parse(find_link(text: "PDF")[:href]).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 diff --git a/spec/system/nested_documentable_spec.rb b/spec/system/nested_documentable_spec.rb index f21b28440..193ad26c6 100644 --- a/spec/system/nested_documentable_spec.rb +++ b/spec/system/nested_documentable_spec.rb @@ -205,6 +205,30 @@ describe "Nested documentable" do expect(page).to have_link text: "logo.pdf" end end + + describe "Metadata" do + let(:factory) { (factories - [:dashboard_action]).sample } + + scenario "download document without metadata" do + do_login_for(user, management: management_section?(path)) + visit path + + fill_in_required_fields(factory, path) + documentable_attach_new_file(file_fixture("logo_with_metadata.pdf")) + click_button submit_button_text + + expect(page).to have_content notice_text + + io = URI.parse(find_link(text: "PDF")[:href]).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 describe "Only for edit path" do