From 5a3466a6c33be9d681b45d09cc28cf2c75b7ea85 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 30 Jul 2014 08:35:15 +1000 Subject: [PATCH] FIX: keep correct ordering on admin badges --- app/controllers/admin/badges_controller.rb | 4 +++- spec/controllers/admin/badges_controller_spec.rb | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/badges_controller.rb b/app/controllers/admin/badges_controller.rb index 1bd7d3b0e..900b92b8e 100644 --- a/app/controllers/admin/badges_controller.rb +++ b/app/controllers/admin/badges_controller.rb @@ -4,7 +4,9 @@ class Admin::BadgesController < Admin::AdminController data = { badge_types: BadgeType.all.order(:id).to_a, badge_groupings: BadgeGrouping.all.order(:position).to_a, - badges: Badge.all.to_a, + badges: Badge.includes(:badge_grouping) + .references(:badge_grouping) + .order('badge_groupings.position, badge_type_id, badges.name').to_a, protected_system_fields: Badge.protected_system_fields, triggers: Badge.trigger_hash } diff --git a/spec/controllers/admin/badges_controller_spec.rb b/spec/controllers/admin/badges_controller_spec.rb index e36930e84..e5102cafb 100644 --- a/spec/controllers/admin/badges_controller_spec.rb +++ b/spec/controllers/admin/badges_controller_spec.rb @@ -6,6 +6,13 @@ describe Admin::BadgesController do let!(:user) { log_in(:admin) } let!(:badge) { Fabricate(:badge) } + context 'index' do + it 'returns badge index' do + xhr :get, :index + response.should be_success + end + end + context '.save_badge_groupings' do it 'can save badge groupings' do