empty badge grant job

This commit is contained in:
Rimian Perkins 2017-04-27 18:47:27 +10:00
parent 9038701520
commit 219444eab2
4 changed files with 23 additions and 1 deletions

View File

@ -4,7 +4,7 @@ module Jobs
every 1.minutes
def execute(_args)
puts '====================== The Job was executed ==========================='
puts '====================== The Award Group Job was executed ==========================='
user_queue.each do |email|
user = User.find_by_email(email)
DiscourseDonations::Rewards.new(user).add_to_group(group_name) if user.present?

10
app/jobs/grant_badge.rb Normal file
View File

@ -0,0 +1,10 @@
module Jobs
class GrantBadge < ::Jobs::Scheduled
every 5.minutes
def execute(_args)
puts '====================== The Grant Badge Job was executed ==========================='
end
end
end

View File

@ -12,6 +12,7 @@ enabled_site_setting :discourse_donations_enabled
after_initialize do
load File.expand_path('../app/jobs/award_group.rb', __FILE__)
load File.expand_path('../app/jobs/grant_badge.rb', __FILE__)
# Must be placed on every page for fraud protection.
header_script = '<script src="https://js.stripe.com/v3/"></script>'

View File

@ -0,0 +1,11 @@
RSpec.describe Jobs::GrantBadge, type: :job do
let(:users) { [Fabricate(:user), Fabricate(:user)] }
let(:badge) { Fabricate(:badge, name: 'el-grande') }
before do
SiteSetting.stubs(:discourse_donations_reward_badge_name).returns(badge.name)
end
it 'grants all the users the badge'
end