Skip to content

Commit

Permalink
Fix admin permissions API endpoint and add test.
Browse files Browse the repository at this point in the history
I'm not exactly sure what's going on, but this seems like it must have
broken during some gem updates as part of the lua upgrade. The
respond_with output is doing some odd things and the structure of the
data being returned now isn't what's expected.
  • Loading branch information
GUI committed Dec 5, 2015
1 parent 9fd0d0b commit 7170d65
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7170d65

Please sign in to comment.