Mercurial > hg > soundsoftware-site
comparison test/unit/lib/redmine/.svn/text-base/unified_diff_test.rb.svn-base @ 0:513646585e45
* Import Redmine trunk SVN rev 3859
author | Chris Cannam |
---|---|
date | Fri, 23 Jul 2010 15:52:44 +0100 |
parents | |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:513646585e45 |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | |
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.dirname(__FILE__) + '/../../../test_helper' | |
19 | |
20 class Redmine::UnifiedDiffTest < ActiveSupport::TestCase | |
21 | |
22 def setup | |
23 end | |
24 | |
25 def test_subversion_diff | |
26 diff = Redmine::UnifiedDiff.new(read_diff_fixture('subversion.diff')) | |
27 # number of files | |
28 assert_equal 4, diff.size | |
29 assert diff.detect {|file| file.file_name =~ %r{^config/settings.yml}} | |
30 end | |
31 | |
32 def test_truncate_diff | |
33 diff = Redmine::UnifiedDiff.new(read_diff_fixture('subversion.diff'), :max_lines => 20) | |
34 assert_equal 2, diff.size | |
35 end | |
36 | |
37 def test_line_starting_with_dashes | |
38 diff = Redmine::UnifiedDiff.new(<<-DIFF | |
39 --- old.txt Wed Nov 11 14:24:58 2009 | |
40 +++ new.txt Wed Nov 11 14:25:02 2009 | |
41 @@ -1,8 +1,4 @@ | |
42 -Lines that starts with dashes: | |
43 - | |
44 ------------------------- | |
45 --- file.c | |
46 ------------------------- | |
47 +A line that starts with dashes: | |
48 | |
49 and removed. | |
50 | |
51 @@ -23,4 +19,4 @@ | |
52 | |
53 | |
54 | |
55 -Another chunk of change | |
56 +Another chunk of changes | |
57 | |
58 DIFF | |
59 ) | |
60 assert_equal 1, diff.size | |
61 end | |
62 | |
63 private | |
64 | |
65 def read_diff_fixture(filename) | |
66 File.new(File.join(File.dirname(__FILE__), '/../../../fixtures/diffs', filename)).read | |
67 end | |
68 end |