mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 14:55:05 +08:00
b58f660cd2
For the admin plugin list we want to be able to link to a meta topic for plugins, but we have no standard way to do this at the moment. This adds support for meta_topic_id alongside other plugin metadata like authors, URL etc, that gets built into a Meta topic URL in the serializer.
54 lines
1.3 KiB
Ruby
54 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Plugin::Metadata do
|
|
describe "parse" do
|
|
it "correctly parses plugin info" do
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
# name: plugin-name
|
|
# about: about: my plugin
|
|
# version: 0.1
|
|
# authors: Frank Zappa
|
|
# contact emails: frankz@example.com
|
|
# url: http://discourse.org
|
|
# required version: 1.3.0beta6+48
|
|
# meta_topic_id: 1234
|
|
|
|
some_ruby
|
|
TEXT
|
|
|
|
expect(metadata.name).to eq("plugin-name")
|
|
expect(metadata.about).to eq("about: my plugin")
|
|
expect(metadata.version).to eq("0.1")
|
|
expect(metadata.authors).to eq("Frank Zappa")
|
|
expect(metadata.contact_emails).to eq("frankz@example.com")
|
|
expect(metadata.url).to eq("http://discourse.org")
|
|
expect(metadata.required_version).to eq("1.3.0beta6+48")
|
|
expect(metadata.meta_topic_id).to eq("1234")
|
|
end
|
|
end
|
|
|
|
def official(name)
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
# name: #{name}
|
|
TEXT
|
|
|
|
expect(metadata.official?).to eq(true)
|
|
end
|
|
|
|
def unofficial(name)
|
|
metadata = Plugin::Metadata.parse <<TEXT
|
|
# name: #{name}
|
|
TEXT
|
|
|
|
expect(metadata.official?).to eq(false)
|
|
end
|
|
|
|
it "correctly detects official vs unofficial plugins" do
|
|
official("discourse-adplugin")
|
|
official("discourse-akismet")
|
|
official("discourse-cakeday")
|
|
official("discourse-data-explorer")
|
|
unofficial("babble")
|
|
end
|
|
end
|