Move tests related with attached documents from documentable shared specs to nested documentable file

Note that we moved some system tests to component tests, since they don't involve user interaction and can
be fully covered at the component level.
This commit is contained in:
taitus
2025-05-19 11:21:10 +02:00
parent 7a317ef9c1
commit 472e244103
5 changed files with 68 additions and 81 deletions

View File

@@ -0,0 +1,37 @@
require "rails_helper"
describe Documents::DocumentComponent do
let(:user) { create(:user) }
let(:proposal) { create(:proposal, author: user) }
let(:document) { create(:document, documentable: proposal) }
let(:component) { Documents::DocumentComponent.new(document, show_destroy_link: true) }
describe "Delete document button" do
it "is not shown when no user is logged in" do
render_inline component
expect(page).not_to have_button "Delete document"
end
it "is shown when the author is logged in" do
sign_in(user)
render_inline component
expect(page).to have_button "Delete document"
end
it "is not shown when an administrator that isn't the author is logged in", :admin do
render_inline component
expect(page).not_to have_button "Delete document"
end
it "is not shown when a user that isn't the author is logged in" do
login_as(create(:user))
render_inline component
expect(page).not_to have_button "Delete document"
end
end
end