docbrown/spec/system/authentication/user_with_suspended_username_spec.rb
Jacob Herrington a5b2d109d5
Rename banned and comment_banned roles (#12270)
* Rename banned and comment_banned roles

* Add data update script to rename roles containing 'ban'

* Add named error for Suspended users

* Update unidiomatic method names

* Rename misc banned to suspended

* Apply suggestions from code review

Co-authored-by: Michael Kohl <me@citizen428.net>

* Add unit tests for suspended methods

This commit also adds TODO comments for removing banned and
comment_banned from the codebase after data update scripts have
successfully run on all of our Forems.

Co-authored-by: Michael Kohl <me@citizen428.net>
2021-04-06 10:12:14 -05:00

34 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "User with suspended username tried to sign up via OAuth" do
before do
omniauth_mock_twitter_payload
allow(SiteConfig)
.to receive(:authentication_providers)
.and_return(Authentication::Providers.available)
allow(ForemStatsClient).to receive(:increment)
end
context "when a user has been previously suspended", :aggregate_failures do
it "displays an error message" do
username = OmniAuth.config.mock_auth[:twitter].extra.raw_info.username
create(:suspended_username, username: username)
visit sign_up_path
click_on("Continue with Twitter", match: :first)
expect(page).to have_current_path(root_path)
expected_message = ::Authentication::Errors::PreviouslySuspended.new.message
expect(page).to have_content(expected_message)
expect(ForemStatsClient)
.to have_received(:increment)
.with("identity.errors",
tags: [
"error:Authentication::Errors::PreviouslySuspended",
"message:#{expected_message}",
])
end
end
end