Skip to content

Commit 1eb6695

Browse files
committed
add test for vide_tag macro
1 parent 18adfaa commit 1eb6695

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

lib/wiki_extensions_video_macro.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module WikiExtensionsVideoMacro
4242
o = '<video src="' + attachment_path + '"'
4343
o += ' width="' + h(args[1].strip) + '"' if args.length >= 2
4444
o += ' height="' + h(args[2].strip) + '"' if args.length >= 3
45-
o += args.length >= 3 ? ' ' + h(args[3].strip) : ' controls'
45+
o += args.length >= 4 ? ' ' + h(args[3].strip) : ' controls'
4646
o += '>'
4747

4848
o.html_safe
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Wiki Extensions plugin for Redmine
2+
# Copyright (C) 2009-2010 Haruyuki Iida
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License
6+
# as published by the Free Software Foundation; either version 2
7+
# of the License, or (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program; if not, write to the Free Software
16+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
18+
require File.expand_path('../test_helper', __dir__)
19+
20+
class WikiExtensionsMacroVideoTest < ActiveSupport::TestCase
21+
include ApplicationHelper
22+
include ActionDispatch::Assertions::SelectorAssertions
23+
include ERB::Util
24+
25+
def test_video_tag_macro
26+
with_settings :text_formatting => 'textile' do
27+
result = textilizable("{{video_tag(https://samplelib.com/lib/preview/mp4/sample-5s.mp4, 320, 240, controls autoplay muted)}}")
28+
29+
assert_select_in result, 'video[src="https://samplelib.com/lib/preview/mp4/sample-5s.mp4"]'
30+
assert_select_in result, 'video[width="320"]'
31+
assert_select_in result, 'video[height="240"]'
32+
assert_select_in result, 'video[controls]'
33+
assert_select_in result, 'video[autoplay]'
34+
assert_select_in result, 'video[muted]'
35+
end
36+
end
37+
end

0 commit comments

Comments
 (0)