diff --git a/src/api-umbrella/web-app/app/controllers/api/v1/admin_permissions_controller.rb b/src/api-umbrella/web-app/app/controllers/api/v1/admin_permissions_controller.rb index 824170534..cbe341792 100644 --- a/src/api-umbrella/web-app/app/controllers/api/v1/admin_permissions_controller.rb +++ b/src/api-umbrella/web-app/app/controllers/api/v1/admin_permissions_controller.rb @@ -4,7 +4,7 @@ class Api::V1::AdminPermissionsController < Api::V1::BaseController skip_after_filter :verify_authorized, :only => [:index] def index - @admin_permissions = AdminPermission.sorted.all + @admin_permissions = AdminPermission.sorted.all.to_a respond_with(:api_v1, @admin_permissions, :root => "admin_permissions") end end diff --git a/src/api-umbrella/web-app/spec/controllers/api/v1/admin_permissions_spec.rb b/src/api-umbrella/web-app/spec/controllers/api/v1/admin_permissions_spec.rb new file mode 100644 index 000000000..4c96187f4 --- /dev/null +++ b/src/api-umbrella/web-app/spec/controllers/api/v1/admin_permissions_spec.rb @@ -0,0 +1,29 @@ +require "spec_helper" + +describe Api::V1::AdminPermissionsController do + before(:all) do + @admin = FactoryGirl.create(:admin) + end + + describe "GET index" do + it "returns the expected permissions in the display order" do + admin_token_auth(@admin) + get :index, :format => "json" + + data = MultiJson.load(response.body) + permission_names = data["admin_permissions"].map { |permission| permission["name"] } + permission_names.should eql([ + "Analytics", + "API Users - View", + "API Users - Manage", + "Admin Accounts - View & Manage", + "API Backend Configuration - View & Manage", + "API Backend Configuration - Publish", + ]) + + data["admin_permissions"].first["id"].should eql("analytics") + data["admin_permissions"].first["name"].should eql("Analytics") + data["admin_permissions"].first["display_order"].should eql(1) + end + end +end