@@ -1,16 +1,16 | |||||
1 |
# |
|
1 | # Redmine - project management software | |
2 |
# Copyright (C) 2006-20 |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 |
# |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 |
# |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
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 |
|
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. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
@@ -24,13 +24,13 class WikiContentTest < ActiveSupport::TestCase | |||||
24 | @wiki = Wiki.find(1) |
|
24 | @wiki = Wiki.find(1) | |
25 | @page = @wiki.pages.first |
|
25 | @page = @wiki.pages.first | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_create |
|
28 | def test_create | |
29 |
page = WikiPage.new(:wiki => @wiki, :title => "Page") |
|
29 | page = WikiPage.new(:wiki => @wiki, :title => "Page") | |
30 | page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") |
|
30 | page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") | |
31 | assert page.save |
|
31 | assert page.save | |
32 | page.reload |
|
32 | page.reload | |
33 |
|
33 | |||
34 | content = page.content |
|
34 | content = page.content | |
35 | assert_kind_of WikiContent, content |
|
35 | assert_kind_of WikiContent, content | |
36 | assert_equal 1, content.version |
|
36 | assert_equal 1, content.version | |
@@ -40,14 +40,14 class WikiContentTest < ActiveSupport::TestCase | |||||
40 | assert_equal User.find(1), content.author |
|
40 | assert_equal User.find(1), content.author | |
41 | assert_equal content.text, content.versions.last.text |
|
41 | assert_equal content.text, content.versions.last.text | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | def test_create_should_send_email_notification |
|
44 | def test_create_should_send_email_notification | |
45 | Setting.notified_events = ['wiki_content_added'] |
|
45 | Setting.notified_events = ['wiki_content_added'] | |
46 | ActionMailer::Base.deliveries.clear |
|
46 | ActionMailer::Base.deliveries.clear | |
47 |
page = WikiPage.new(:wiki => @wiki, :title => "A new page") |
|
47 | page = WikiPage.new(:wiki => @wiki, :title => "A new page") | |
48 | page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") |
|
48 | page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") | |
49 | assert page.save |
|
49 | assert page.save | |
50 |
|
50 | |||
51 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
51 | assert_equal 1, ActionMailer::Base.deliveries.size | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
@@ -60,26 +60,26 class WikiContentTest < ActiveSupport::TestCase | |||||
60 | assert_equal version_count+1, content.version |
|
60 | assert_equal version_count+1, content.version | |
61 | assert_equal version_count+1, content.versions.length |
|
61 | assert_equal version_count+1, content.versions.length | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | def test_update_should_send_email_notification |
|
64 | def test_update_should_send_email_notification | |
65 | Setting.notified_events = ['wiki_content_updated'] |
|
65 | Setting.notified_events = ['wiki_content_updated'] | |
66 | ActionMailer::Base.deliveries.clear |
|
66 | ActionMailer::Base.deliveries.clear | |
67 | content = @page.content |
|
67 | content = @page.content | |
68 | content.text = "My new content" |
|
68 | content.text = "My new content" | |
69 | assert content.save |
|
69 | assert content.save | |
70 |
|
70 | |||
71 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
71 | assert_equal 1, ActionMailer::Base.deliveries.size | |
72 | end |
|
72 | end | |
73 |
|
73 | |||
74 | def test_fetch_history |
|
74 | def test_fetch_history | |
75 | assert !@page.content.versions.empty? |
|
75 | assert !@page.content.versions.empty? | |
76 | @page.content.versions.each do |version| |
|
76 | @page.content.versions.each do |version| | |
77 | assert_kind_of String, version.text |
|
77 | assert_kind_of String, version.text | |
78 | end |
|
78 | end | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | def test_large_text_should_not_be_truncated_to_64k |
|
81 | def test_large_text_should_not_be_truncated_to_64k | |
82 |
page = WikiPage.new(:wiki => @wiki, :title => "Big page") |
|
82 | page = WikiPage.new(:wiki => @wiki, :title => "Big page") | |
83 | page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1)) |
|
83 | page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1)) | |
84 | assert page.save |
|
84 | assert page.save | |
85 | page.reload |
|
85 | page.reload |
General Comments 0
You need to be logged in to leave comments.
Login now