Files
grecia/spec/components/documents/document_component_spec.rb
taitus 472e244103 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.
2025-06-09 17:32:41 +02:00

38 lines
1.0 KiB
Ruby

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