* Split Settings::Authentication from SiteConfig * Move specs * Sort fields * Update settings usages * Update recaptcha usages * Add data update script * Update spec * Rename SiteConfigParams concern * Fixes, new route, new controller * Controller and service refactoring * More controller and service updates * Spec updates * More spec fixes * Move file * Fix FeedbackMessagesController * Update admin/configs_spec * Fix remaining specs in admin/configs_spec * Fix configs API * Formatting * Clean up old service object * Various fixes * Update DUS * Add model argument to admin_config_label * Fix key name * Fix specs * Add distinct request caches for settings classes * Fix e2e tests * Fix remaining system spec * Make DUS idempotent * Move routes block * Cleanup * Switch to ActiveSupport::CurrentAttributes * Pinned rails-settings-cached * Update e2e test * Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb Co-authored-by: rhymes <rhymes@hey.com> * Add guard to DUS * Temporarily re-add two SiteConfig fields * Fix config show view Co-authored-by: rhymes <rhymes@hey.com>
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(Settings::Authentication).to receive(: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
|