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:
37
spec/components/documents/document_component_spec.rb
Normal file
37
spec/components/documents/document_component_spec.rb
Normal 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
|
||||
Reference in New Issue
Block a user