From 49c27d9a88d0937e2c061b8269267f5d56cb1df9 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 25 Oct 2016 14:55:53 +0800 Subject: [PATCH] FEATURE: Add interface in `Plugin::Instance` to register a seedfu fixture. --- lib/plugin/instance.rb | 5 +++++ spec/components/plugin/instance_spec.rb | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index a9de8e4698b..c1f9660c37c 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -203,6 +203,11 @@ class Plugin::Instance end end + def register_seedfu_fixtures(paths) + paths = [paths] if !paths.kind_of?(Array) + SeedFu.fixture_paths.concat(paths) + end + def listen_for(event_name) return unless self.respond_to?(event_name) DiscourseEvent.on(event_name, &self.method(event_name)) diff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rb index 119cfbcde95..2e99df132a3 100644 --- a/spec/components/plugin/instance_spec.rb +++ b/spec/components/plugin/instance_spec.rb @@ -180,4 +180,15 @@ describe Plugin::Instance do end end + describe '.register_seedfu_fixtures' do + it "should add the new path to SeedFu's fixtures path" do + plugin = Plugin::Instance.new nil, "/tmp/test.rb" + plugin.register_seedfu_fixtures(['some_path']) + plugin.register_seedfu_fixtures('some_path2') + + expect(SeedFu.fixture_paths).to include('some_path') + expect(SeedFu.fixture_paths).to include('some_path2') + end + end + end