the award job adds the user to a group

This commit is contained in:
Rimian Perkins 2017-04-27 14:51:47 +10:00
parent 45501a0ca3
commit 999b106b65
4 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,4 @@
require_dependency 'discourse' require_dependency 'discourse'
require_relative '../../jobs/award_group'
module DiscourseDonations module DiscourseDonations
class ChargesController < ActionController::Base class ChargesController < ActionController::Base

View File

@ -5,5 +5,16 @@ module Jobs
def perform(args) def perform(args)
puts '======================The Job was performed===========================' puts '======================The Job was performed==========================='
end end
def self.perform_in(arg, opts)
puts '======================The Job was enqueued==========================='
end
def execute(args)
user = User.find_by_email(args[:email])
if user.present?
DiscourseDonations::Rewards.new(user).add_to_group(args[:group_name])
end
end
end end
end end

View File

@ -1,3 +1,5 @@
require_relative '../../app/jobs/award_group'
module ::DiscourseDonations module ::DiscourseDonations
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
engine_name 'discourse-donations' engine_name 'discourse-donations'

View File

@ -0,0 +1,9 @@
RSpec.describe Jobs::AwardGroup, type: :job do
it 'adds the user to a group' do
user = Fabricate(:user)
grp = Fabricate(:group)
Jobs::AwardGroup.new.execute(email: user.email, group_name: grp.name)
expect(user.groups).to include(grp)
end
end