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
@@ -1,5 +1,4 @@
require_dependency 'discourse'
require_relative '../../jobs/award_group'
module DiscourseDonations
class ChargesController < ActionController::Base
+11
View File
@@ -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
+2
View File
@@ -1,3 +1,5 @@
require_relative '../../app/jobs/award_group'
module ::DiscourseDonations
class Engine < ::Rails::Engine
engine_name 'discourse-donations'
+9
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