Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/reference_filter_spec_helper.rb')
-rw-r--r--spec/support/reference_filter_spec_helper.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/support/reference_filter_spec_helper.rb b/spec/support/reference_filter_spec_helper.rb
new file mode 100644
index 00000000000..e4138405602
--- /dev/null
+++ b/spec/support/reference_filter_spec_helper.rb
@@ -0,0 +1,37 @@
+# Common methods and setup for Gitlab::Markdown reference filter specs
+#
+# Must be included into specs manually
+module ReferenceFilterSpecHelper
+ extend ActiveSupport::Concern
+
+ included do
+ before { set_default_url_options }
+ end
+
+ # Allow *_url helpers to work
+ def set_default_url_options
+ Rails.application.routes.default_url_options = {
+ host: 'example.foo'
+ }
+ end
+
+ # Shortcut to Rails' auto-generated routes helpers, to avoid including the
+ # module
+ def urls
+ Rails.application.routes.url_helpers
+ end
+
+ # Perform `call` on the described class
+ #
+ # Automatically passes the current `project` value to the context if none is
+ # provided.
+ #
+ # html - String text to pass to the filter's `call` method.
+ # contexts - Hash context for the filter. (default: {project: project})
+ #
+ # Returns the String text returned by the filter's `call` method.
+ def filter(html, contexts = {})
+ contexts.reverse_merge!(project: project)
+ described_class.call(html, contexts)
+ end
+end