# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006- Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require_relative '../../../../../test_helper' class GitAdapterTest < ActiveSupport::TestCase REPOSITORY_PATH = Rails.root.join('tmp/test/git_repository').to_s ## Git, Mercurial and CVS path encodings are binary. ## Subversion supports URL encoding for path. ## Redmine Mercurial adapter and extension use URL encoding. ## Git accepts only binary path in command line parameter. ## So, there is no way to use binary command line parameter in JRuby. JRUBY_SKIP = (RUBY_PLATFORM == 'java') JRUBY_SKIP_STR = "TODO: This test fails in JRuby" if File.directory?(REPOSITORY_PATH) ## Ruby uses ANSI api to fork a process on Windows. ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem ## and these are incompatible with ASCII. ## Git for Windows (msysGit) changed internal API from ANSI to Unicode in 1.7.10 ## http://code.google.com/p/msysgit/issues/detail?id=80 ## So, Latin-1 path tests fail on Japanese Windows WINDOWS_PASS = (Redmine::Platform.mswin? && Redmine::Scm::Adapters::GitAdapter.client_version_above?([1, 7, 10])) WINDOWS_SKIP_STR = "TODO: This test fails in Git for Windows above 1.7.10" def setup @adapter = Redmine::Scm::Adapters::GitAdapter. new( REPOSITORY_PATH, nil, nil, nil, 'ISO-8859-1' ) assert @adapter skip "SCM is unavailable" unless @adapter.class.client_available @char_1 = 'Ü' @str_felix_hex = "Felix Sch\xC3\xA4fer".b end def test_scm_version to_test = { "git version 1.7.3.4\n" => [1, 7, 3, 4], "1.6.1\n1.7\n1.8" => [1, 6, 1], "1.6.2\r\n1.8.1\r\n1.9.1" => [1, 6, 2] } to_test.each do |s, v| test_scm_version_for(s, v) end end def test_branches brs = @adapter.branches assert_equal 8, brs.length br_issue_8857 = brs[0] assert_equal 'issue-8857', br_issue_8857.to_s assert_equal '2a682156a3b6e77a8bf9cd4590e8db757f3c6c78', br_issue_8857.revision assert_equal br_issue_8857.scmid, br_issue_8857.revision assert_equal false, br_issue_8857.is_default br_latin_1_branch1 = brs[1] assert_equal "latin-1-branch-#{@char_1}-01", br_latin_1_branch1.to_s assert_equal '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', br_latin_1_branch1.revision assert_equal br_latin_1_branch1.scmid, br_latin_1_branch1.revision assert_equal false, br_latin_1_branch1.is_default br_latin_1_branch2 = brs[2] assert_equal "latin-1-branch-#{@char_1}-02", br_latin_1_branch2.to_s assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', br_latin_1_branch2.revision assert_equal br_latin_1_branch2.scmid, br_latin_1_branch2.revision assert_equal false, br_latin_1_branch2.is_default br_latin_1_path = brs[3] assert_equal 'latin-1-path-encoding', br_latin_1_path.to_s assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', br_latin_1_path.revision assert_equal br_latin_1_path.scmid, br_latin_1_path.revision assert_equal false, br_latin_1_path.is_default br_master = brs[4] assert_equal 'master', br_master.to_s assert_equal 'b1650eac7c505a6dab9f19858afc9ecb481eccc2', br_master.revision assert_equal br_master.scmid, br_master.revision assert_equal false, br_master.is_default br_master_20120212 = brs[5] assert_equal 'master-20120212', br_master_20120212.to_s assert_equal 'b1650eac7c505a6dab9f19858afc9ecb481eccc2', br_master_20120212.revision assert_equal br_master_20120212.scmid, br_master_20120212.revision assert_equal true, br_master_20120212.is_default br_latin_1 = brs[-2] assert_equal 'test-latin-1', br_latin_1.to_s assert_equal '67e7792ce20ccae2e4bb73eed09bb397819c8834', br_latin_1.revision assert_equal br_latin_1.scmid, br_latin_1.revision assert_equal false, br_latin_1.is_default br_test = brs[-1] assert_equal 'test_branch', br_test.to_s assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', br_test.revision assert_equal br_test.scmid, br_test.revision assert_equal false, br_test.is_default end def test_default_branch assert_equal 'master-20120212', @adapter.default_branch # When no branch is marked as the default, GitAdapter treats # "main" or "master" branch as the default b_foo, b_bar, b_main, b_master = %w[foo bar main master].map do |name| Redmine::Scm::Adapters::GitAdapter::GitBranch.new(name) end @adapter.stubs(:branches).returns([b_foo, b_main, b_bar]) assert_equal 'main', @adapter.default_branch @adapter.stubs(:branches).returns([b_foo, b_master, b_bar]) assert_equal 'master', @adapter.default_branch # The first found branch is treated as the default branch # when neither "main" nor "master" is found @adapter.stubs(:branches).returns([b_foo, b_bar]) assert_equal 'foo', @adapter.default_branch @adapter.stubs(:branches).returns([]) assert_nil @adapter.default_branch end def test_tags assert_equal( [ "tag00.lightweight", "tag01.annotated", "tag02.lightweight.#{@char_1}.01", ], @adapter.tags ) end def test_revisions_master_all revs1 = [] @adapter.revisions('', nil, "master", {}) do |rev| revs1 << rev end assert_equal 16, revs1.length assert_equal 'b1650eac7c505a6dab9f19858afc9ecb481eccc2', revs1[0].identifier assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs1[-1].identifier revs2 = [] @adapter.revisions('', nil, "master", {:reverse => true}) do |rev| revs2 << rev end assert_equal 16, revs2.length assert_equal 'b1650eac7c505a6dab9f19858afc9ecb481eccc2', revs2[-1].identifier assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', revs2[0].identifier end def test_revisions_master_merged_rev revs1 = [] @adapter.revisions('', "713f4944648826f558cf548222f813dabe7cbb04", "master", {:reverse => true}) do |rev| revs1 << rev end assert_equal 9, revs1.length assert_equal 'fba357b886984ee71185ad2065e65fc0417d9b92', revs1[0].identifier assert_equal '7e61ac704deecde634b51e59daa81104
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Tabs - Collapse content</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.5.1.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.tabs.js"></script>
<link rel="stylesheet" href="../demos.css">
<script>
$(function() {
$( "#tabs" ).tabs({
collapsible: true
});
});
</script>
</head>
<body>
<div class="demo">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p><strong>Click this tab again to close the content pane.</strong></p>
<p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
</div>
<div id="tabs-2">
<p><strong>Click this tab again to close the content pane.</strong></p>
<p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
</div>
<div id="tabs-3">
<p><strong>Click this tab again to close the content pane.</strong></p>
<p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
</div>
</div>
</div><!-- End demo -->
<div class="demo-description">
<p>Click the selected tab to toggle its content closed/open. To enable this functionality, set the <code>collapsible</code> option to true.</p>
<pre><code>collapsible: true
</code></pre>
</div><!-- End demo-description -->
</body>
</html>