motiro 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/app/controllers/wiki_controller.rb +25 -12
- data/app/core/version.rb +1 -1
- data/app/helpers/default_page_provider.rb +0 -2
- data/app/models/page.rb +64 -26
- data/app/models/revision.rb +27 -0
- data/app/views/javascript/motiro.rjs +1 -0
- data/app/views/wiki/_editbar.rhtml +3 -0
- data/app/views/wiki/history.rhtml +28 -0
- data/app/views/wiki/show.rhtml +2 -2
- data/db/migrate/016_create_revisions.rb +19 -0
- data/db/migrate/017_revision_mimics_page.rb +13 -0
- data/db/migrate/018_drop_redundant_page_columns.rb +25 -0
- data/db/migrate/019_move_event_date_to_revision.rb +13 -0
- data/db/motirodb.sqlite.initial +0 -0
- data/db/schema_version +1 -1
- data/db/translation/pt-BR.rb +4 -2
- data/test/acceptance/wiki_test.rb +4 -4
- data/test/fixtures/pages.yml +14 -54
- data/test/fixtures/revisions.yml +134 -0
- data/test/functional/root_controller_test.rb +2 -2
- data/test/functional/wiki_controller_test.rb +52 -8
- data/test/test_helper.rb +29 -0
- data/test/unit/page_test.rb +173 -51
- data/test/unit/revision_test.rb +32 -0
- data/test/unit/user_test.rb +4 -4
- data/test/unit/wiki_reporter_test.rb +5 -6
- metadata +327 -320
- data/app/controllers/edition_controller.rb +0 -13
@@ -0,0 +1,134 @@
|
|
1
|
+
page_creation:
|
2
|
+
id: 1
|
3
|
+
page_id: 11
|
4
|
+
kind: common
|
5
|
+
modified_at: 2007-01-22 12:18:43
|
6
|
+
last_editor_id: 1000004 #john
|
7
|
+
editors: ""
|
8
|
+
title: This page has been created
|
9
|
+
text: John entered some text here
|
10
|
+
|
11
|
+
page_edition:
|
12
|
+
id: 2
|
13
|
+
page_id: 11
|
14
|
+
kind: common
|
15
|
+
modified_at: 2007-01-22 13:21:26
|
16
|
+
last_editor_id: 1000005 #eric
|
17
|
+
editors: ""
|
18
|
+
title: This page has been edited since creation
|
19
|
+
text: Eric changed the text that John entered
|
20
|
+
|
21
|
+
main_page_creation:
|
22
|
+
id: 3
|
23
|
+
page_id: 1
|
24
|
+
last_editor_id: 1000001
|
25
|
+
editors: ""
|
26
|
+
text: = Motiro =
|
27
|
+
|
28
|
+
This is project motiro
|
29
|
+
|
30
|
+
johns_page_creation:
|
31
|
+
id: 4
|
32
|
+
page_id: 2
|
33
|
+
last_editor_id: 1000004
|
34
|
+
editors: john
|
35
|
+
text: This is John's page
|
36
|
+
|
37
|
+
bob_and_erics_page_creation:
|
38
|
+
id: 5
|
39
|
+
page_id: 3
|
40
|
+
last_editor_id: 1000001 #bob
|
41
|
+
editors: bob eric
|
42
|
+
text: This is Bob and Eric's page
|
43
|
+
|
44
|
+
nobodys_page_creation:
|
45
|
+
id: 6
|
46
|
+
page_id: 4
|
47
|
+
last_editor_id:
|
48
|
+
editors: ""
|
49
|
+
text: This page was created before the wiki access control was in place
|
50
|
+
|
51
|
+
test_page_creation:
|
52
|
+
id: 7
|
53
|
+
page_id: 5
|
54
|
+
kind: common
|
55
|
+
last_editor_id: 1000001
|
56
|
+
editors: ""
|
57
|
+
title:
|
58
|
+
text: This is the page text
|
59
|
+
|
60
|
+
non_matching_title_page_creation:
|
61
|
+
id: 8
|
62
|
+
page_id: 6
|
63
|
+
kind: common
|
64
|
+
last_editor_id: 1000001
|
65
|
+
editors: ""
|
66
|
+
title: The title does not match the name
|
67
|
+
text: This is the page text
|
68
|
+
|
69
|
+
list_last_modified_features_page_creation:
|
70
|
+
id: 9
|
71
|
+
page_id: 7
|
72
|
+
kind: feature
|
73
|
+
last_editor_id: 1000001
|
74
|
+
modified_at: 2033-12-27 16:47:00
|
75
|
+
editors: ""
|
76
|
+
title: List last modified features
|
77
|
+
text: Motiro should list the last modified feature suggestion pages on the
|
78
|
+
main page
|
79
|
+
|
80
|
+
provide_rss_feed_for_last_modified_pages_page_creation:
|
81
|
+
id: 10
|
82
|
+
page_id: 8
|
83
|
+
kind: feature
|
84
|
+
last_editor_id: 1000001
|
85
|
+
modified_at: 2033-12-27 12:32:48
|
86
|
+
editors: ""
|
87
|
+
title: Provide RSS feed for last modified pages
|
88
|
+
text: There could be an RSS feed for the last modified pages
|
89
|
+
|
90
|
+
provide_rss_feed_for_last_modified_pages_page_edition:
|
91
|
+
id: 11
|
92
|
+
page_id: 8
|
93
|
+
kind: feature
|
94
|
+
modified_at: 2033-12-27 12:33:48
|
95
|
+
last_editor_id: 1000004
|
96
|
+
editors: ""
|
97
|
+
title: Provide RSS feed for last modified pages
|
98
|
+
text: There could be an RSS feed for the last modified pages
|
99
|
+
|
100
|
+
events_are_just_special_pages_too_page_creation:
|
101
|
+
id: 12
|
102
|
+
page_id: 9
|
103
|
+
kind: feature
|
104
|
+
last_editor_id: 1000001
|
105
|
+
modified_at: 2033-12-25 18:41:12
|
106
|
+
editors: ""
|
107
|
+
title: Events are just special wiki pages too
|
108
|
+
text: Event descriptions can be treated just like other regular wiki pages,
|
109
|
+
in the same way that feature suggestion pages are
|
110
|
+
|
111
|
+
events_are_just_special_pages_too_page_edition:
|
112
|
+
id: 13
|
113
|
+
page_id: 9
|
114
|
+
kind: feature
|
115
|
+
modified_at: 2033-12-25 18:43:31
|
116
|
+
last_editor_id: 1000005
|
117
|
+
editors: ""
|
118
|
+
title: Events are just special wiki pages too
|
119
|
+
text: Event descriptions can be treated just like other regular wiki pages,
|
120
|
+
in the same way that feature suggestion pages are
|
121
|
+
|
122
|
+
release_event_creation:
|
123
|
+
id: 14
|
124
|
+
page_id: 10
|
125
|
+
kind: event
|
126
|
+
modified_at: 2007-01-18 13:28:47
|
127
|
+
last_editor_id: 1000004 #john
|
128
|
+
editors: ""
|
129
|
+
title: Fourteenth release
|
130
|
+
happens_at: 2007-01-24
|
131
|
+
text: The 0.6.1 release will be a bug fixing one and will introduce editable
|
132
|
+
event pages. This is included as part of the everything is a wiki page
|
133
|
+
motto.
|
134
|
+
|
@@ -6,7 +6,7 @@ class RootController; def rescue_action(e) raise e end; end
|
|
6
6
|
|
7
7
|
class RootControllerTest < Test::Unit::TestCase
|
8
8
|
|
9
|
-
fixtures :users, :pages
|
9
|
+
fixtures :users, :pages, :revisions
|
10
10
|
|
11
11
|
def setup
|
12
12
|
@controller = RootController.new
|
@@ -17,7 +17,7 @@ class RootControllerTest < Test::Unit::TestCase
|
|
17
17
|
def test_version_number
|
18
18
|
get :index, :locale => 'en'
|
19
19
|
|
20
|
-
assert_tag :content => /Motiro version 0.6.
|
20
|
+
assert_tag :content => /Motiro version 0.6.4/
|
21
21
|
end
|
22
22
|
|
23
23
|
|
@@ -26,7 +26,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|
26
26
|
|
27
27
|
include TestConfiguration
|
28
28
|
|
29
|
-
fixtures :users, :pages
|
29
|
+
fixtures :users, :pages, :revisions
|
30
30
|
|
31
31
|
def setup
|
32
32
|
@controller = WikiController.new
|
@@ -75,8 +75,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
|
75
75
|
page_provider.should_receive(:find_by_name).
|
76
76
|
with('TestPage').
|
77
77
|
once.
|
78
|
-
and_return(Page.new(:name => 'TestPage'
|
79
|
-
:text => ''))
|
78
|
+
and_return(Page.new(:name => 'TestPage'))
|
80
79
|
@controller = WikiController.new(page_provider)
|
81
80
|
|
82
81
|
ensure_logged_in
|
@@ -86,8 +85,8 @@ class WikiControllerTest < Test::Unit::TestCase
|
|
86
85
|
end
|
87
86
|
|
88
87
|
def test_authentication_required_for_edition
|
89
|
-
get :edit,
|
90
|
-
assert_redirected_to(:
|
88
|
+
get :edit, :page_name => 'TestPage'
|
89
|
+
assert_redirected_to(:action => 'show', :page_name => 'TestPage')
|
91
90
|
end
|
92
91
|
|
93
92
|
def test_only_original_author_can_change_editors_list
|
@@ -264,17 +263,62 @@ class WikiControllerTest < Test::Unit::TestCase
|
|
264
263
|
assert_xml_element "//div[@id = 'crumbs']/a[@href = '/report/older/events' and text() = 'Events']"
|
265
264
|
assert_xml_element "//div[@id = 'crumbs']/a[@href = '/wiki/show/#{release_event.name}' and text() = '#{release_event.title}']"
|
266
265
|
end
|
266
|
+
|
267
|
+
def test_shows_history_summary_and_details_for_new_wiki_pages
|
268
|
+
log_as :bob
|
269
|
+
post :save, :page_name => 'RevisedPage',
|
270
|
+
:btnSave => true,
|
271
|
+
:page => { :title => 'The title will be changed',
|
272
|
+
:text => 'Some very boring text',
|
273
|
+
:kind => 'common',
|
274
|
+
:editors => '' }
|
275
|
+
post :save, :page_name => 'RevisedPage',
|
276
|
+
:btnSave => true,
|
277
|
+
:page => { :title => 'The title was changed',
|
278
|
+
:text => 'A little more exciting text',
|
279
|
+
:kind => 'common',
|
280
|
+
:editors => '' }
|
281
|
+
|
282
|
+
log_out
|
283
|
+
|
284
|
+
get :history, :page_name => 'RevisedPage'
|
285
|
+
|
286
|
+
assert_tag :tag => 'a', :attributes => {
|
287
|
+
:href => @controller.url_for(
|
288
|
+
:controller => 'wiki', :action => 'show',
|
289
|
+
:page_name => 'RevisedPage', :revision => '1')},
|
290
|
+
:content => /The title will be changed/
|
291
|
+
assert_tag :content => /The title was changed/
|
292
|
+
|
293
|
+
get :show, :page_name => 'RevisedPage', :revision => '1'
|
294
|
+
assert_tag :content => /Some very boring text/
|
295
|
+
|
296
|
+
get :show, :page_name => 'RevisedPage', :revision => '0'
|
297
|
+
assert_tag :content => /A little more exciting text/
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_displays_old_text_when_showing_revisions
|
301
|
+
get :show, :page_name => pages('changed_page').name, :revision => '0'
|
302
|
+
assert_tag :content => revisions('page_edition').text
|
267
303
|
|
304
|
+
get :show, :page_name => pages('changed_page').name, :revision => '1'
|
305
|
+
assert_tag :content => revisions('page_creation').text
|
306
|
+
end
|
307
|
+
|
268
308
|
private
|
269
309
|
|
270
310
|
def log_as(user_name)
|
271
311
|
@request.session[:user] = users(user_name)
|
272
312
|
end
|
273
313
|
|
314
|
+
def log_out
|
315
|
+
@request.session[:user] = nil
|
316
|
+
end
|
317
|
+
|
274
318
|
def mocked_page
|
275
|
-
Page.new(:name => 'MockedPage'
|
276
|
-
|
277
|
-
|
319
|
+
Page.new(:name => 'MockedPage').
|
320
|
+
revise(bob, now, :title => 'Mocked page', :kind => 'common',
|
321
|
+
:text => "You've been mocked!\n\n--- pt-br ----\n\nVocê foi enganado!")
|
278
322
|
end
|
279
323
|
|
280
324
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# Motiro - A project tracking tool
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
+
|
1
18
|
ENV["RAILS_ENV"] = "test"
|
2
19
|
|
3
20
|
$:.push File.expand_path(File.dirname(__FILE__))
|
@@ -33,4 +50,16 @@ class Test::Unit::TestCase
|
|
33
50
|
self.use_instantiated_fixtures = false
|
34
51
|
|
35
52
|
# Add more helper methods to be used by all tests here...
|
53
|
+
def bob; users('bob'); end
|
54
|
+
def john; users('john'); end
|
55
|
+
def now; Time.local(2007, 3, 27, 23, 41, 38); end
|
56
|
+
|
57
|
+
def revise_named_page(attrs)
|
58
|
+
Page.new(:name => 'SomePage').revise(bob, now, attrs)
|
59
|
+
end
|
60
|
+
|
61
|
+
def revise_brand_new_page(attrs)
|
62
|
+
Page.new(:name => nil).revise(bob, now, attrs)
|
63
|
+
end
|
64
|
+
|
36
65
|
end
|
data/test/unit/page_test.rb
CHANGED
@@ -18,91 +18,92 @@
|
|
18
18
|
require File.dirname(__FILE__) + '/../test_helper'
|
19
19
|
|
20
20
|
class PageTest < Test::Unit::TestCase
|
21
|
-
fixtures :pages
|
22
|
-
|
21
|
+
fixtures :pages, :revisions, :users
|
22
|
+
|
23
23
|
def test_is_open_to_all
|
24
|
-
attrs = { :
|
25
|
-
assert !
|
26
|
-
assert
|
27
|
-
assert
|
28
|
-
assert !
|
29
|
-
assert
|
24
|
+
attrs = { :text => 'Page text' }
|
25
|
+
assert !revise_named_page(attrs.merge(:editors => 'john')).is_open_to_all?
|
26
|
+
assert revise_named_page(attrs.merge(:editors => '')).is_open_to_all?
|
27
|
+
assert revise_named_page(attrs.merge(:editors => ' ')).is_open_to_all?
|
28
|
+
assert !revise_named_page(attrs.merge(:editors => ' john ')).is_open_to_all?
|
29
|
+
assert revise_named_page(attrs.merge(:editors => "\n")).is_open_to_all?
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_fresh_page_is_open_to_all
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
assert Page.new(:name => 'FreshPage').is_open_to_all?
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_fresh_page_shows_default_text
|
37
|
+
assert_equal WIKI_NOT_FOUND_TEXT, Page.new(:name => 'FreshPage').text
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_default_text_for_main_page_shows_some_appraisal
|
41
|
+
assert_equal CONGRATS_TEXT, Page.new(:name => 'MainPage').text
|
36
42
|
end
|
37
43
|
|
38
44
|
def test_fresh_page_has_empty_editors_list
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal 0, page.editors.size
|
45
|
+
assert_equal 0, Page.new(:name => 'AnotherFreshPage').editors.size
|
42
46
|
end
|
43
47
|
|
44
48
|
def test_page_name_is_title_camelized
|
45
|
-
|
46
|
-
|
47
|
-
assert_equal 'HowToWriteAMotiroPage', page.name
|
49
|
+
assert_equal 'HowToWriteAMotiroPage',
|
50
|
+
revise_brand_new_page(:title => 'How to write a Motiro page').name
|
48
51
|
end
|
49
52
|
|
50
53
|
def test_user_entered_page_name_takes_precedence_over_camelized_title
|
51
54
|
page = Page.new(:name => 'MyFirstPageName')
|
52
|
-
page.title
|
55
|
+
page.revise(bob, now, :title => 'My first page title')
|
53
56
|
|
54
57
|
assert_equal 'MyFirstPageName', page.name
|
55
|
-
|
56
|
-
page = Page.new(:title => 'My second page title')
|
57
|
-
page.name = 'MySecondPageName'
|
58
|
-
|
59
|
-
assert_equal 'MySecondPageName', page.name
|
60
58
|
end
|
61
59
|
|
62
60
|
def test_converts_utf8_decorated_vowels_when_generating_name
|
63
|
-
assert_equal 'MinhaPagina',
|
61
|
+
assert_equal 'MinhaPagina',
|
62
|
+
revise_brand_new_page(:title => 'Minha página').name
|
64
63
|
assert_equal 'AaaaaEeeeIiiiiYyyOooooUuuuu',
|
65
|
-
|
64
|
+
revise_brand_new_page(:title => 'ãàáâä èéêë ĩìíîï ÿýý õòóôö ũùúûü').name
|
66
65
|
assert_equal 'AaaaaEeeeIiiiiYyOooooUuuuu',
|
67
|
-
|
66
|
+
revise_brand_new_page(:title => 'ÃÀÁÂÄ ÈÉÊË ĨÌÍÎÏ ÝŸ ÕÒÓÔÖ ŨÙÚÛÜ').name
|
68
67
|
end
|
69
68
|
|
70
69
|
def test_converts_utf8_decorated_consonants_when_generating_name
|
71
|
-
assert_equal 'ElNino',
|
70
|
+
assert_equal 'ElNino', revise_brand_new_page(:title => 'El Niño').name
|
72
71
|
assert_equal 'NnCcSrlzNnCcSrlz',
|
73
|
-
|
72
|
+
revise_brand_new_page(:title => 'ñń ćç śŕĺź ÑŃ ÇĆ ŚŔĹŹ').name
|
74
73
|
end
|
75
74
|
|
76
75
|
def test_drops_non_alpha_numeric_characters_when_generating_name
|
77
76
|
assert_equal 'ThisHasLotsOfPunctuation',
|
78
|
-
|
77
|
+
revise_brand_new_page(:title => 'This, has. lots! of? punctuation').name
|
79
78
|
assert_equal 'TitleWithSomeStrangeCharacters',
|
80
|
-
|
79
|
+
revise_brand_new_page(:title => 'Title%with$some&strange*characters').name
|
81
80
|
end
|
82
81
|
|
83
|
-
def
|
84
|
-
fst_page =
|
82
|
+
def test_resolves_clashing_page_names
|
83
|
+
fst_page = revise_brand_new_page(:title => 'My first Motiro page', :text => '')
|
85
84
|
assert_equal 'MyFirstMotiroPage', fst_page.name
|
86
85
|
fst_page.save
|
87
86
|
|
88
|
-
snd_page =
|
87
|
+
snd_page = revise_brand_new_page(:title => 'My first Motiro page', :text => '')
|
89
88
|
assert_equal 'MyFirstMotiroPage2', snd_page.name
|
90
89
|
snd_page.save
|
91
90
|
|
92
|
-
trd_page =
|
91
|
+
trd_page = revise_brand_new_page(:title => 'My first Motiro page')
|
93
92
|
assert_equal 'MyFirstMotiroPage3', trd_page.name
|
94
93
|
end
|
95
94
|
|
96
95
|
def test_uses_place_holder_title_when_nil
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
assert_equal PLACE_HOLDER_TITLE.t, Page.new.title
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_uses_place_holder_title_for_new_pages
|
100
|
+
assert_equal PLACE_HOLDER_TITLE.t, Page.new.title
|
100
101
|
end
|
101
102
|
|
102
|
-
def
|
103
|
-
page =
|
103
|
+
def test_uses_kind_based_title_when_revised_with_empty_title
|
104
|
+
page = revise_brand_new_page(:kind => 'feature', :title => '')
|
104
105
|
|
105
|
-
assert_equal
|
106
|
+
assert_equal 'Feature page', page.title
|
106
107
|
end
|
107
108
|
|
108
109
|
def test_translates_default_title
|
@@ -112,27 +113,21 @@ class PageTest < Test::Unit::TestCase
|
|
112
113
|
end
|
113
114
|
|
114
115
|
def test_saves_default_title_based_on_page_kind_when_title_is_place_holder
|
115
|
-
common_page = Page.new
|
116
|
+
common_page = Page.new.revise(bob, now, :title => PLACE_HOLDER_TITLE.t)
|
116
117
|
|
117
|
-
common_page.save
|
118
118
|
assert_equal 'Common page', common_page.title
|
119
119
|
|
120
|
-
feature_page =
|
121
|
-
feature_page.save
|
120
|
+
feature_page = revise_brand_new_page(:kind => 'feature')
|
122
121
|
assert_equal 'Feature page', feature_page.title
|
123
122
|
end
|
124
123
|
|
125
124
|
def test_numbers_titles_when_already_used
|
126
|
-
|
127
|
-
|
128
|
-
snd_page = Page.new
|
129
|
-
snd_page.save
|
125
|
+
revise_brand_new_page({})
|
130
126
|
|
127
|
+
snd_page = revise_brand_new_page({})
|
131
128
|
assert_equal 'Common page 2', snd_page.title
|
132
129
|
|
133
|
-
trd_page =
|
134
|
-
trd_page.save
|
135
|
-
|
130
|
+
trd_page = revise_brand_new_page({})
|
136
131
|
assert_equal 'Common page 3', trd_page.title
|
137
132
|
end
|
138
133
|
|
@@ -142,4 +137,131 @@ class PageTest < Test::Unit::TestCase
|
|
142
137
|
assert_equal 'Yet another motiro page', page.title
|
143
138
|
end
|
144
139
|
|
140
|
+
def test_revising_new_page_should_record_original_author_id_and_editors
|
141
|
+
john = users(:john)
|
142
|
+
time = Time.local(2007, 3, 15, 17, 3, 22)
|
143
|
+
page = Page.new(:name => 'BrandNew').revise(john, time,
|
144
|
+
:kind => 'feature',
|
145
|
+
:title => 'Brand new page',
|
146
|
+
:text => 'This is a new page',
|
147
|
+
:editors => 'john bob eric')
|
148
|
+
|
149
|
+
assert_equal john, page.last_editor
|
150
|
+
assert_equal john, page.original_author
|
151
|
+
assert_equal time, page.modified_at
|
152
|
+
assert_equal 'feature', page.kind
|
153
|
+
assert_equal 'Brand new page', page.title
|
154
|
+
assert_equal 'This is a new page', page.text
|
155
|
+
assert_equal 'john bob eric', page.editors
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_revising_old_page_should_not_record_original_author_id
|
159
|
+
john = users('john')
|
160
|
+
time = Time.local(2007, 3, 15, 17, 3, 22)
|
161
|
+
page = pages(:bob_and_erics_page).revise(john, time,
|
162
|
+
:title => "Bob and Eric's page",
|
163
|
+
:text => 'Do not touch')
|
164
|
+
|
165
|
+
assert_equal john, page.last_editor
|
166
|
+
assert_equal users('bob'), page.original_author
|
167
|
+
assert_equal time, page.modified_at
|
168
|
+
assert_equal "Bob and Eric's page", page.title
|
169
|
+
assert_equal 'Do not touch', page.text
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_only_original_author_should_be_able_to_change_editors_list
|
173
|
+
john = users('john')
|
174
|
+
editors = pages(:bob_and_erics_page).editors
|
175
|
+
page = pages(:bob_and_erics_page).revise(john, Time.local(2007, 3, 15, 17),
|
176
|
+
:title => "Bob and Eric's page",
|
177
|
+
:text => 'Do not touch',
|
178
|
+
:editors => 'john lennon')
|
179
|
+
|
180
|
+
assert_not_equal 'john lennon', editors
|
181
|
+
assert_equal editors, page.editors
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_keeps_revision_record
|
185
|
+
page = create_page_with_one_revision
|
186
|
+
assert_equal 1, page.revisions.size
|
187
|
+
|
188
|
+
page.revise(users('john'), Time.local(2007, 3, 15, 10, 19, 36),
|
189
|
+
:title => 'Revised page',
|
190
|
+
:text => 'Page revision number 2',
|
191
|
+
:editors => '')
|
192
|
+
|
193
|
+
assert_equal 2, page.revisions.size
|
194
|
+
assert_equal 'Page revision number 2', page.revisions.first.text
|
195
|
+
assert_equal 'Page revision number 1', page.revisions.last.text
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_copies_previous_editors_list_when_not_provided
|
199
|
+
page = create_page_with_one_revision
|
200
|
+
previous_editors = page.editors
|
201
|
+
|
202
|
+
page.revise(users('bob'), Time.now, :title => page.title,
|
203
|
+
:text => 'Bob was here')
|
204
|
+
|
205
|
+
assert_equal previous_editors, page.editors
|
206
|
+
assert_equal previous_editors, page.revisions.first.editors
|
207
|
+
assert_equal previous_editors, page.revisions.last.editors
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_most_recent_revision_comes_first
|
211
|
+
page = pages('changed_page')
|
212
|
+
assert_equal revisions('page_creation'), page.revisions[1]
|
213
|
+
assert_equal revisions('page_edition'), page.revisions[0]
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_records_original_author_for_pages_without_author
|
217
|
+
page = pages('nobodys_page')
|
218
|
+
bob = users('bob')
|
219
|
+
assert_nil page.original_author
|
220
|
+
|
221
|
+
page.revise(bob, now, :title => page.title, :text => 'Bob was here')
|
222
|
+
|
223
|
+
assert_equal bob, page.original_author
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_copies_previous_kind_when_not_provided
|
227
|
+
page = pages('list_last_modified_features_page')
|
228
|
+
|
229
|
+
page.revise(bob, now, :text => 'New feature page text')
|
230
|
+
|
231
|
+
assert_equal 'feature', page.kind
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_stores_revisions_for_happens_at
|
235
|
+
event = pages('release_event')
|
236
|
+
old_time = event.happens_at
|
237
|
+
new_time = Date.new(2007, 4, 4)
|
238
|
+
|
239
|
+
event.revise(bob, now, :happens_at => new_time)
|
240
|
+
|
241
|
+
assert_equal new_time, event.happens_at
|
242
|
+
assert_equal new_time, event.revisions.first.happens_at
|
243
|
+
assert_equal old_time, event.revisions.last.happens_at
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_rbab
|
247
|
+
date = Date.new(2007, 4, 4)
|
248
|
+
page = revise_brand_new_page(:kind => 'event',
|
249
|
+
:text => 'Something will happen',
|
250
|
+
:happens_at => date)
|
251
|
+
|
252
|
+
assert_equal date, page.happens_at
|
253
|
+
end
|
254
|
+
|
255
|
+
#TODO it seems that event pages do not get their happens_at attribute revised
|
256
|
+
|
257
|
+
private
|
258
|
+
|
259
|
+
def create_page_with_one_revision
|
260
|
+
Page.new(:name => 'RevisedPage').revise(
|
261
|
+
users('john'), Time.local(2007, 3, 15, 9, 15, 53),
|
262
|
+
:title => 'Revised page',
|
263
|
+
:text => 'Page revision number 1',
|
264
|
+
:editors => '')
|
265
|
+
end
|
266
|
+
|
145
267
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Motiro - A project tracking tool
|
2
|
+
# Copyright (C) 2006-2007 Thiago Arrais
|
3
|
+
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# 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 St, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
+
|
18
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
19
|
+
|
20
|
+
class RevisionTest < Test::Unit::TestCase
|
21
|
+
fixtures :users
|
22
|
+
|
23
|
+
def test_revisions_original_author_is_page_original_author
|
24
|
+
p = revise_brand_new_page(:title => 'My Title', :text => 'Original content')
|
25
|
+
p.revise(john, now, :text => 'Modified content')
|
26
|
+
|
27
|
+
assert_equal bob, p.original_author
|
28
|
+
assert_equal bob, p.revisions.first.original_author
|
29
|
+
assert_equal bob, p.revisions.last.original_author
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/test/unit/user_test.rb
CHANGED
@@ -107,9 +107,9 @@ class UserTest < Test::Unit::TestCase
|
|
107
107
|
u = User.new(:login => 'john')
|
108
108
|
attrs = { :name => 'TestPage', :text => '' }
|
109
109
|
|
110
|
-
assert u.can_edit?(
|
111
|
-
assert !u.can_edit?(
|
112
|
-
assert u.can_edit?(
|
110
|
+
assert u.can_edit?(revise_brand_new_page(:editors => 'john'))
|
111
|
+
assert !u.can_edit?(revise_brand_new_page(:editors => 'eric'))
|
112
|
+
assert u.can_edit?(revise_brand_new_page(:editors => ' '))
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_original_author_can_always_edit_page
|
@@ -117,7 +117,7 @@ class UserTest < Test::Unit::TestCase
|
|
117
117
|
john = users('john')
|
118
118
|
bobs_page = pages('bob_and_erics_page')
|
119
119
|
|
120
|
-
bobs_page.editors
|
120
|
+
bobs_page.revise(bob, now, :editors => 'john')
|
121
121
|
assert john.can_edit?(bobs_page)
|
122
122
|
assert bob.can_edit?(bobs_page)
|
123
123
|
end
|
@@ -35,6 +35,8 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
35
35
|
|
36
36
|
class WikiReporterTest < Test::Unit::TestCase
|
37
37
|
|
38
|
+
fixtures :users
|
39
|
+
|
38
40
|
def button; MotiroReporter.button; end
|
39
41
|
|
40
42
|
def test_title
|
@@ -68,9 +70,7 @@ class WikiReporterTest < Test::Unit::TestCase
|
|
68
70
|
mod_time = Time.local(2007, 1, 19, 15, 23, 8)
|
69
71
|
page_provider.should_receive(:find).
|
70
72
|
zero_or_more_times.
|
71
|
-
and_return([Page.new(:name => 'FeaturePage',
|
72
|
-
:last_editor => User.new(:login => 'arrais'),
|
73
|
-
:modified_at => mod_time,
|
73
|
+
and_return([Page.new(:name => 'FeaturePage').revise(bob, mod_time,
|
74
74
|
:title => 'Feature page')])
|
75
75
|
hl = FeaturesReporter.new(:page_provider => page_provider).headlines[0]
|
76
76
|
assert_equal mod_time, hl.happened_at
|
@@ -82,10 +82,9 @@ class WikiReporterTest < Test::Unit::TestCase
|
|
82
82
|
planned_date = Date.civil(2007, 1, 19)
|
83
83
|
page_provider.should_receive(:find).
|
84
84
|
zero_or_more_times.
|
85
|
-
and_return([Page.new(:name => '
|
86
|
-
:last_editor => User.new(:login => 'arrais'),
|
85
|
+
and_return([Page.new(:name => 'EventPage').revise(bob, now,
|
87
86
|
:happens_at => planned_date,
|
88
|
-
:title => '
|
87
|
+
:title => 'Event page')])
|
89
88
|
hl = EventsReporter.new(:page_provider => page_provider).headlines[0]
|
90
89
|
assert_equal planned_date.to_t, hl.happened_at
|
91
90
|
end
|