mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
refactoring the plugin interfaces to allow for better extensible
This commit is contained in:
32
spec/components/plugin/instance_spec.rb
Normal file
32
spec/components/plugin/instance_spec.rb
Normal file
@ -0,0 +1,32 @@
|
||||
require 'spec_helper'
|
||||
require_dependency 'plugin/instance'
|
||||
|
||||
describe Plugin::Instance do
|
||||
|
||||
context "activate!" do
|
||||
it "can activate plugins correctly" do
|
||||
plugin = Plugin.new
|
||||
plugin.path = "#{Rails.root}/spec/fixtures/plugins/my_plugin/plugin.rb"
|
||||
junk_file = "#{plugin.auto_generated_path}/junk"
|
||||
|
||||
plugin.ensure_directory(junk_file)
|
||||
File.open("#{plugin.auto_generated_path}/junk", "w") {|f| f.write("junk")}
|
||||
plugin.activate!
|
||||
|
||||
plugin.auth_providers.count.should == 1
|
||||
auth_provider = plugin.auth_providers[0]
|
||||
auth_provider.options.should == {:identifier => 'https://zappa.com'}
|
||||
auth_provider.type.should == :open_id
|
||||
|
||||
# calls ensure_assets! make sure they are there
|
||||
plugin.assets.count.should == 2
|
||||
plugin.assets.each do |a|
|
||||
File.exists?(a).should be_true
|
||||
end
|
||||
|
||||
# ensure it cleans up all crap in autogenerated directory
|
||||
File.exists?(junk_file).should be_false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user