]> source.dussan.org Git - redmine.git/commitdiff
Merged r10885 from trunk (#12451).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Dec 2012 07:54:21 +0000 (07:54 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 15 Dec 2012 07:54:21 +0000 (07:54 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.1-stable@11007 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/macros.rb
test/unit/lib/redmine/wiki_formatting/macros_test.rb

index 23e6caf007cb41949efdb97e88e8cda40c9e2f0b..7d7488f1b2b2382bf47aa3231b036b4cfde1fc7e 100644 (file)
@@ -48,7 +48,7 @@ module Redmine
 
         def extract_macro_options(args, *keys)
           options = {}
-          while args.last.to_s.strip =~ %r{^(.+)\=(.+)$} && keys.include?($1.downcase.to_sym)
+          while args.last.to_s.strip =~ %r{^(.+?)\=(.+)$} && keys.include?($1.downcase.to_sym)
             options[$1.downcase.to_sym] = $2
             args.pop
           end
index 75376652a317e734c4a710b61693372177ae5884..00d9f0a8e176fc31704928d34c9749e7c51c3801 100644 (file)
@@ -100,6 +100,25 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
     assert_equal '<p>Hello world! Object: Issue, Called with no argument and no block of text.</p>', textilizable(text, :object => Issue.find(1))
   end
 
+  def test_extract_macro_options_should_with_args
+    options = extract_macro_options(["arg1", "arg2"], :foo, :size)
+    assert_equal([["arg1", "arg2"], {}], options)
+  end
+
+  def test_extract_macro_options_should_with_options
+    options = extract_macro_options(["foo=bar", "size=2"], :foo, :size)
+    assert_equal([[], {:foo => "bar", :size => "2"}], options)
+  end
+
+  def test_extract_macro_options_should_with_args_and_options
+    options = extract_macro_options(["arg1", "arg2", "foo=bar", "size=2"], :foo, :size)
+    assert_equal([["arg1", "arg2"], {:foo => "bar", :size => "2"}], options)
+  end
+
+  def test_extract_macro_options_should_parse_options_lazily
+    options = extract_macro_options(["params=x=1&y=2"], :params)
+    assert_equal([[], {:params => "x=1&y=2"}], options)
+  end
 
   def test_macro_exception_should_be_displayed
     Redmine::WikiFormatting::Macros.macro :exception do |obj, args|