docbrown/spec/system/admin/admin_invites_user_spec.rb
Daniel Uber 1bf350c321
Fix broken email settings documentation link (#16792)
* Fix broken documentation link

When sending an invitation, and smtp isn't configured, we show a link
to the old smtp-settings page, which has been renamed
email-server-settings in the admin documentation site.

* Remove explicit link target, assert link text is present

This spec failed when I changed the link target to match the
documentation. Rather than moving the target, I'm just asserting we
show a link to the docs (not where the docs are located).
2022-03-07 10:45:35 -06:00

61 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe "Admin invites user", type: :system do
let(:admin) { create(:user, :super_admin) }
before do
sign_in admin
end
context "when SMTP is not configured" do
before do
allow(ForemInstance).to receive(:smtp_enabled?).and_return(false)
visit new_admin_invitation_path
end
it "shows a header" do
header = "Setup SMTP to invite users"
expect(page).to have_content(header)
end
it "shows a banner" do
message = "SMTP settings are required so that your Forem can send emails. If you wish to send invites, "\
"email digests and activity notifications you will need to specify which email host will relay those "\
"messages for you."
expect(page).to have_content(message)
end
it "contains a link to the documentation" do
expect(page).to have_link("read more about SMTP Settings in our admin guide")
end
it "contains a link to configure SMTP settings" do
expect(page).to have_link("Configure your SMTP Settings", href: admin_config_path(anchor: "smtp-section"))
end
it "does not contain any for fields" do
expect(page).not_to have_field "Email"
expect(page).not_to have_field "Name"
end
it "does not contain any submit buttons" do
expect(page).not_to have_button "Invite User"
end
end
context "when SMTP is configured" do
before do
allow(ForemInstance).to receive(:smtp_enabled?).and_return(true)
visit new_admin_invitation_path
end
it "shows the input fields" do
expect(page).to have_field "Email"
expect(page).to have_field "Name"
end
it "shows the submit button" do
expect(page).to have_button "Invite User"
end
end
end