the award job adds the user to a group
This commit is contained in:
parent
45501a0ca3
commit
999b106b65
|
@ -1,5 +1,4 @@
|
|||
require_dependency 'discourse'
|
||||
require_relative '../../jobs/award_group'
|
||||
|
||||
module DiscourseDonations
|
||||
class ChargesController < ActionController::Base
|
||||
|
|
|
@ -5,5 +5,16 @@ module Jobs
|
|||
def perform(args)
|
||||
puts '======================The Job was performed==========================='
|
||||
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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require_relative '../../app/jobs/award_group'
|
||||
|
||||
module ::DiscourseDonations
|
||||
class Engine < ::Rails::Engine
|
||||
engine_name 'discourse-donations'
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue