mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:06:26 +08:00
Add a spec for the new plugins controller
This commit is contained in:
parent
0ce6524153
commit
8d46de4819
|
@ -1,6 +1,6 @@
|
|||
export default Ember.Route.extend({
|
||||
model() {
|
||||
return Discourse.ajax("/admin/plugins.json");
|
||||
return Discourse.ajax("/admin/plugins.json").then(res => res.plugins);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
class Admin::PluginsController < Admin::AdminController
|
||||
|
||||
def index
|
||||
# json = Discourse.plugins.map(&:metadata)
|
||||
render_serialized(Discourse.plugins, AdminPluginSerializer)
|
||||
render_serialized(Discourse.plugins, AdminPluginSerializer, root: 'plugins')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -85,12 +85,11 @@ module Discourse
|
|||
end
|
||||
|
||||
def self.disabled_plugin_names
|
||||
return [] if @plugins.blank?
|
||||
@plugins.select {|p| !p.enabled?}.map(&:name)
|
||||
plugins.select {|p| !p.enabled?}.map(&:name)
|
||||
end
|
||||
|
||||
def self.plugins
|
||||
@plugins
|
||||
@plugins ||= []
|
||||
end
|
||||
|
||||
def self.assets_digest
|
||||
|
@ -119,14 +118,12 @@ module Discourse
|
|||
|
||||
def self.auth_providers
|
||||
providers = []
|
||||
if plugins
|
||||
plugins.each do |p|
|
||||
next unless p.auth_providers
|
||||
p.auth_providers.each do |prov|
|
||||
providers << prov
|
||||
end
|
||||
end
|
||||
end
|
||||
providers
|
||||
end
|
||||
|
||||
|
|
20
spec/controllers/admin/plugins_controller_spec.rb
Normal file
20
spec/controllers/admin/plugins_controller_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Admin::PluginsController do
|
||||
|
||||
it "is a subclass of AdminController" do
|
||||
expect(Admin::PluginsController < Admin::AdminController).to eq(true)
|
||||
end
|
||||
|
||||
context "while logged in as an admin" do
|
||||
let!(:admin) { log_in(:admin) }
|
||||
|
||||
it 'should return JSON' do
|
||||
xhr :get, :index
|
||||
response.should be_success
|
||||
::JSON.parse(response.body).has_key?('plugins').should == true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user