empty rewards

This commit is contained in:
Rimian Perkins 2017-04-21 12:08:52 +10:00
parent b2393cb2aa
commit c3fe90f4d1
3 changed files with 11 additions and 6 deletions

View File

@ -14,9 +14,12 @@ module DiscourseDonations
response = {}
end
response['rewards'] = []
if reward_user?(payment)
reward = DiscourseDonations::Rewards.new(current_user)
reward.add_to_group(SiteSetting.discourse_donations_reward_group) if add_to_group?
group_name = SiteSetting.discourse_donations_reward_group
reward.add_to_group(group_name) if group_name.present?
end
render :json => response
@ -28,10 +31,6 @@ module DiscourseDonations
payment.present? && payment.successful? && current_user.present?
end
def add_to_group?
SiteSetting.discourse_donations_reward_group.present?
end
def secret_key
SiteSetting.discourse_donations_secret_key
end

View File

@ -26,5 +26,11 @@ module DiscourseDonations
post :create
expect(response).to have_http_status(200)
end
it 'has no rewards' do
current_user = log_in(:coding_horror)
post :create
expect(JSON.parse(response.body)['rewards']).to eq([])
end
end
end

View File

@ -2,7 +2,7 @@ require 'rails_helper'
module DiscourseDonations
RSpec.describe DiscourseDonations::Rewards do
let(:grp) { Fabricate(:group, name: 'w00t') }
let(:grp) { Fabricate(:group) }
let(:user) { Fabricate(:user) }
subject { described_class.new(user) }