This commit is contained in:
Rimian Perkins 2017-04-27 20:26:36 +10:00
parent 1549a47088
commit 638eb21005
3 changed files with 7 additions and 4 deletions

View File

@ -4,6 +4,8 @@ module Jobs
every 1.minutes
def execute(_args)
puts "===================== Running add to group ========================"
puts user_queue
user_queue.each do |email|
user = User.find_by_email(email)
next if user.nil?

View File

@ -4,6 +4,8 @@ module Jobs
every 5.minutes
def execute(_args)
puts "===================== Running badge grant ========================"
puts user_queue
user_queue.each do |email|
user = User.find_by_email(email)
next if user.nil?

View File

@ -32,15 +32,14 @@ module DiscourseDonations
let(:badge_name) { 'Beanie' }
let(:response_rewards) { JSON.parse(response.body)['rewards'] }
let(:stripe) { ::Stripe::Charge }
let!(:grp) { Fabricate(:group, name: group_name) }
let!(:badge) { Fabricate(:badge, name: badge_name) }
before do
SiteSetting.stubs(:discourse_donations_reward_group_name).returns(group_name)
SiteSetting.stubs(:discourse_donations_reward_badge_name).returns(badge_name)
Fabricate(:group, name: group_name)
Fabricate(:badge, name: badge_name)
end
describe 'new user' do
let(:params) { { email: 'new-user@example.com' } }
@ -49,7 +48,7 @@ module DiscourseDonations
expect(response_rewards).to be_empty
end
it 'stores the email in group:add and badge:grant' do
it 'stores the email in group:add and badge:grant and adds them' do
PluginStore.expects(:get).with('discourse-donations', 'group:add').returns([])
PluginStore.expects(:set).with('discourse-donations', 'group:add', [params[:email]])
PluginStore.expects(:get).with('discourse-donations', 'badge:grant').returns([])