mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:13:39 +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({
|
export default Ember.Route.extend({
|
||||||
model() {
|
model() {
|
||||||
return Discourse.ajax("/admin/plugins.json");
|
return Discourse.ajax("/admin/plugins.json").then(res => res.plugins);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
class Admin::PluginsController < Admin::AdminController
|
class Admin::PluginsController < Admin::AdminController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# json = Discourse.plugins.map(&:metadata)
|
render_serialized(Discourse.plugins, AdminPluginSerializer, root: 'plugins')
|
||||||
render_serialized(Discourse.plugins, AdminPluginSerializer)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,12 +85,11 @@ module Discourse
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.disabled_plugin_names
|
def self.disabled_plugin_names
|
||||||
return [] if @plugins.blank?
|
plugins.select {|p| !p.enabled?}.map(&:name)
|
||||||
@plugins.select {|p| !p.enabled?}.map(&:name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.plugins
|
def self.plugins
|
||||||
@plugins
|
@plugins ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.assets_digest
|
def self.assets_digest
|
||||||
|
@ -119,12 +118,10 @@ module Discourse
|
||||||
|
|
||||||
def self.auth_providers
|
def self.auth_providers
|
||||||
providers = []
|
providers = []
|
||||||
if plugins
|
plugins.each do |p|
|
||||||
plugins.each do |p|
|
next unless p.auth_providers
|
||||||
next unless p.auth_providers
|
p.auth_providers.each do |prov|
|
||||||
p.auth_providers.each do |prov|
|
providers << prov
|
||||||
providers << prov
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
providers
|
providers
|
||||||
|
|
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