Files
grecia/spec/system/documents_spec.rb
Javi Martín f93c85bd2e Don't check the database during system tests
As mentioned in commits like a586ba806, a7664ad81, 006128da5, b41fbfa52
and c480cdd91, accessing the database after starting the browser with
the `visit` method sometimes results in database corruption and failing
tests on our CI due to the process running the test accessing the
database after the process running the browser has started.

IMHO this is also a bad practice for system tests, since these tests
should be checking what users experience.

So, just like we did a few commits ago with tests that reloaded records,
we're modifying the tests to check the results of user interactions from
the point of view of the users.

Also note we aren't changing tests with the `:no_js` tag, since these
tests don't run a real browser in a separate process. In the future, we
should also change most of these tests so they don't access the database
and they use a real browser.

Finally, note that one of the tests we're changing in the shared
`notifiable_in_app` file did not check the database content, but we're
also changing it for consistency.
2025-04-01 14:53:27 +02:00

29 lines
1.0 KiB
Ruby

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