* 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>
38 lines
1.2 KiB
Ruby
38 lines
1.2 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe GithubRepoPolicy, type: :policy do
|
|
subject { described_class.new(user, github_repo) }
|
|
|
|
context "when user is not signed in" do
|
|
let(:user) { nil }
|
|
let(:github_repo) { build(:github_repo, user: user) }
|
|
|
|
it { within_block_is_expected.to raise_error(Pundit::NotAuthorizedError) }
|
|
end
|
|
|
|
context "when the user is not authenticated through GitHub" do
|
|
let(:user) { build(:user) }
|
|
let(:github_repo) { build(:github_repo, user: user) }
|
|
|
|
it { is_expected.to forbid_actions(%i[index update_or_create]) }
|
|
end
|
|
|
|
context "when the user is authenticated through GitHub" do
|
|
let(:user) { create(:user, :with_identity, identities: %i[github]) }
|
|
let(:github_repo) { build(:github_repo, user: user) }
|
|
|
|
before do
|
|
omniauth_mock_github_payload
|
|
allow(SiteConfig).to receive(:authentication_providers).and_return(Authentication::Providers.available)
|
|
end
|
|
|
|
it { is_expected.to permit_actions(%i[index update_or_create]) }
|
|
end
|
|
|
|
context "when user is suspended" do
|
|
let(:user) { build(:user, :suspended) }
|
|
let(:github_repo) { build(:github_repo, user: user) }
|
|
|
|
it { is_expected.to forbid_actions(%i[index update_or_create]) }
|
|
end
|
|
end
|