Add Oauth check to AwardContributorFromGithub (#17155)
* Add oauth check to AwardContributorFromGithub * Add spec * Simplify spec
This commit is contained in:
parent
0ca5096a9e
commit
d28aa37ed2
2 changed files with 10 additions and 0 deletions
|
|
@ -25,6 +25,8 @@ module Badges
|
|||
end
|
||||
|
||||
def call
|
||||
return unless Settings::Authentication.providers.include?(:github)
|
||||
|
||||
REPOSITORIES.each do |repo|
|
||||
award_single_commit_contributors(repo)
|
||||
award_multi_commit_contributors(repo)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,17 @@ RSpec.describe Badges::AwardContributorFromGithub, type: :service, vcr: true do
|
|||
before do
|
||||
badge
|
||||
omniauth_mock_github_payload
|
||||
allow(Settings::Authentication).to receive(:providers).and_return([:github])
|
||||
stub_const("#{described_class}::REPOSITORIES", ["forem/DEV-Android"])
|
||||
end
|
||||
|
||||
it "won't work without Github oauth configured" do
|
||||
allow(Settings::Authentication).to receive(:providers).and_return([])
|
||||
user = create(:user, :with_identity, identities: ["github"], uid: "389169")
|
||||
|
||||
expect { described_class.call }.not_to change(user.badge_achievements, :count)
|
||||
end
|
||||
|
||||
it "awards contributor badge" do
|
||||
user = create(:user, :with_identity, identities: ["github"], uid: "389169")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue