FIX: base sql vanishes after badge creation

This commit is contained in:
Sam Saffron 2017-05-09 09:25:57 -04:00
parent 94683b33b8
commit c2829dce22
2 changed files with 15 additions and 2 deletions

View File

@ -66,7 +66,7 @@ class Admin::BadgesController < Admin::AdminController
if errors.present? if errors.present?
render_json_error errors render_json_error errors
else else
render_serialized(badge, BadgeSerializer, root: "badge") render_serialized(badge, AdminBadgeSerializer, root: "badge")
end end
end end
@ -78,7 +78,7 @@ class Admin::BadgesController < Admin::AdminController
if errors.present? if errors.present?
render_json_error errors render_json_error errors
else else
render_serialized(badge, BadgeSerializer, root: "badge") render_serialized(badge, AdminBadgeSerializer, root: "badge")
end end
end end

View File

@ -26,6 +26,19 @@ describe Admin::BadgesController do
end end
end end
describe '.create' do
render_views
it 'can create badges correctly' do
SiteSetting.enable_badge_sql = true
result = xhr :post, :create, name: 'test', query: 'select 1 as user_id, null as granted_at', badge_type_id: 1
json = JSON.parse(result.body)
expect(result.status).to eq(200)
expect(json["badge"]["name"]).to eq('test')
expect(json["badge"]["query"]).to eq('select 1 as user_id, null as granted_at')
end
end
context '.save_badge_groupings' do context '.save_badge_groupings' do
it 'can save badge groupings' do it 'can save badge groupings' do