mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Sort plugins by their setting category name (#25128)
Some plugins have names (e.g. discourse-x-yz) that are totally different from what they are actually called, and that causes issues when showing them in a sorted way in the admin plugin list. Now, we should use the setting category name from client.en.yml if it exists, otherwise fall back to the name, for sorting. This is what we do on the client to determine what text to show for the plugin name as well.
This commit is contained in:
@ -67,6 +67,30 @@ RSpec.describe Discourse do
|
||||
end
|
||||
end
|
||||
|
||||
describe ".plugins_sorted_by_name" do
|
||||
before do
|
||||
Discourse.stubs(:visible_plugins).returns(
|
||||
[
|
||||
stub(enabled?: false, name: "discourse-doctor-sleep", humanized_name: "Doctor Sleep"),
|
||||
stub(enabled?: true, name: "discourse-shining", humanized_name: "The Shining"),
|
||||
stub(enabled?: true, name: "discourse-misery", humanized_name: "misery"),
|
||||
],
|
||||
)
|
||||
end
|
||||
|
||||
it "sorts enabled plugins by humanized name" do
|
||||
expect(Discourse.plugins_sorted_by_name.map(&:name)).to eq(
|
||||
%w[discourse-misery discourse-shining],
|
||||
)
|
||||
end
|
||||
|
||||
it "sorts both enabled and disabled plugins when that option is provided" do
|
||||
expect(Discourse.plugins_sorted_by_name(enabled_only: false).map(&:name)).to eq(
|
||||
%w[discourse-doctor-sleep discourse-misery discourse-shining],
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "plugins" do
|
||||
let(:plugin_class) do
|
||||
Class.new(Plugin::Instance) do
|
||||
|
Reference in New Issue
Block a user