|
@@
-1,496
+1,504
|
|
1
|
# Redmine - project management software
|
|
1
|
# Redmine - project management software
|
|
2
|
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
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.
|
|
17
|
|
|
17
|
|
|
18
|
require File.expand_path('../../test_helper', __FILE__)
|
|
18
|
require File.expand_path('../../test_helper', __FILE__)
|
|
19
|
require 'wiki_controller'
|
|
19
|
require 'wiki_controller'
|
|
20
|
|
|
20
|
|
|
21
|
# Re-raise errors caught by the controller.
|
|
21
|
# Re-raise errors caught by the controller.
|
|
22
|
class WikiController; def rescue_action(e) raise e end; end
|
|
22
|
class WikiController; def rescue_action(e) raise e end; end
|
|
23
|
|
|
23
|
|
|
24
|
class WikiControllerTest < ActionController::TestCase
|
|
24
|
class WikiControllerTest < ActionController::TestCase
|
|
25
|
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments
|
|
25
|
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments
|
|
26
|
|
|
26
|
|
|
27
|
def setup
|
|
27
|
def setup
|
|
28
|
@controller = WikiController.new
|
|
28
|
@controller = WikiController.new
|
|
29
|
@request = ActionController::TestRequest.new
|
|
29
|
@request = ActionController::TestRequest.new
|
|
30
|
@response = ActionController::TestResponse.new
|
|
30
|
@response = ActionController::TestResponse.new
|
|
31
|
User.current = nil
|
|
31
|
User.current = nil
|
|
32
|
end
|
|
32
|
end
|
|
33
|
|
|
33
|
|
|
34
|
def test_show_start_page
|
|
34
|
def test_show_start_page
|
|
35
|
get :show, :project_id => 'ecookbook'
|
|
35
|
get :show, :project_id => 'ecookbook'
|
|
36
|
assert_response :success
|
|
36
|
assert_response :success
|
|
37
|
assert_template 'show'
|
|
37
|
assert_template 'show'
|
|
38
|
assert_tag :tag => 'h1', :content => /CookBook documentation/
|
|
38
|
assert_tag :tag => 'h1', :content => /CookBook documentation/
|
|
39
|
|
|
39
|
|
|
40
|
# child_pages macro
|
|
40
|
# child_pages macro
|
|
41
|
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
|
41
|
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
|
42
|
:child => { :tag => 'li',
|
|
42
|
:child => { :tag => 'li',
|
|
43
|
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
|
43
|
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
|
44
|
:content => 'Page with an inline image' } }
|
|
44
|
:content => 'Page with an inline image' } }
|
|
45
|
end
|
|
45
|
end
|
|
46
|
|
|
46
|
|
|
47
|
def test_show_page_with_name
|
|
47
|
def test_show_page_with_name
|
|
48
|
get :show, :project_id => 1, :id => 'Another_page'
|
|
48
|
get :show, :project_id => 1, :id => 'Another_page'
|
|
49
|
assert_response :success
|
|
49
|
assert_response :success
|
|
50
|
assert_template 'show'
|
|
50
|
assert_template 'show'
|
|
51
|
assert_tag :tag => 'h1', :content => /Another page/
|
|
51
|
assert_tag :tag => 'h1', :content => /Another page/
|
|
52
|
# Included page with an inline image
|
|
52
|
# Included page with an inline image
|
|
53
|
assert_tag :tag => 'p', :content => /This is an inline image/
|
|
53
|
assert_tag :tag => 'p', :content => /This is an inline image/
|
|
54
|
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
|
|
54
|
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
|
|
55
|
:alt => 'This is a logo' }
|
|
55
|
:alt => 'This is a logo' }
|
|
56
|
end
|
|
56
|
end
|
|
57
|
|
|
57
|
|
|
58
|
def test_show_with_sidebar
|
|
58
|
def test_show_with_sidebar
|
|
59
|
page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
|
|
59
|
page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
|
|
60
|
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
|
60
|
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
|
|
61
|
page.save!
|
|
61
|
page.save!
|
|
62
|
|
|
62
|
|
|
63
|
get :show, :project_id => 1, :id => 'Another_page'
|
|
63
|
get :show, :project_id => 1, :id => 'Another_page'
|
|
64
|
assert_response :success
|
|
64
|
assert_response :success
|
|
65
|
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
|
|
65
|
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
|
|
66
|
:content => /Side bar content for test_show_with_sidebar/
|
|
66
|
:content => /Side bar content for test_show_with_sidebar/
|
|
67
|
end
|
|
67
|
end
|
|
68
|
|
|
68
|
|
|
69
|
def test_show_unexistent_page_without_edit_right
|
|
69
|
def test_show_unexistent_page_without_edit_right
|
|
70
|
get :show, :project_id => 1, :id => 'Unexistent page'
|
|
70
|
get :show, :project_id => 1, :id => 'Unexistent page'
|
|
71
|
assert_response 404
|
|
71
|
assert_response 404
|
|
72
|
end
|
|
72
|
end
|
|
73
|
|
|
73
|
|
|
74
|
def test_show_unexistent_page_with_edit_right
|
|
74
|
def test_show_unexistent_page_with_edit_right
|
|
75
|
@request.session[:user_id] = 2
|
|
75
|
@request.session[:user_id] = 2
|
|
76
|
get :show, :project_id => 1, :id => 'Unexistent page'
|
|
76
|
get :show, :project_id => 1, :id => 'Unexistent page'
|
|
77
|
assert_response :success
|
|
77
|
assert_response :success
|
|
78
|
assert_template 'edit'
|
|
78
|
assert_template 'edit'
|
|
79
|
end
|
|
79
|
end
|
|
80
|
|
|
80
|
|
|
81
|
def test_create_page
|
|
81
|
def test_create_page
|
|
82
|
@request.session[:user_id] = 2
|
|
82
|
@request.session[:user_id] = 2
|
|
83
|
put :update, :project_id => 1,
|
|
83
|
put :update, :project_id => 1,
|
|
84
|
:id => 'New page',
|
|
84
|
:id => 'New page',
|
|
85
|
:content => {:comments => 'Created the page',
|
|
85
|
:content => {:comments => 'Created the page',
|
|
86
|
:text => "h1. New page\n\nThis is a new page",
|
|
86
|
:text => "h1. New page\n\nThis is a new page",
|
|
87
|
:version => 0}
|
|
87
|
:version => 0}
|
|
88
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page'
|
|
88
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'New_page'
|
|
89
|
page = Project.find(1).wiki.find_page('New page')
|
|
89
|
page = Project.find(1).wiki.find_page('New page')
|
|
90
|
assert !page.new_record?
|
|
90
|
assert !page.new_record?
|
|
91
|
assert_not_nil page.content
|
|
91
|
assert_not_nil page.content
|
|
92
|
assert_equal 'Created the page', page.content.comments
|
|
92
|
assert_equal 'Created the page', page.content.comments
|
|
93
|
end
|
|
93
|
end
|
|
94
|
|
|
94
|
|
|
95
|
def test_create_page_with_attachments
|
|
95
|
def test_create_page_with_attachments
|
|
96
|
@request.session[:user_id] = 2
|
|
96
|
@request.session[:user_id] = 2
|
|
97
|
assert_difference 'WikiPage.count' do
|
|
97
|
assert_difference 'WikiPage.count' do
|
|
98
|
assert_difference 'Attachment.count' do
|
|
98
|
assert_difference 'Attachment.count' do
|
|
99
|
put :update, :project_id => 1,
|
|
99
|
put :update, :project_id => 1,
|
|
100
|
:id => 'New page',
|
|
100
|
:id => 'New page',
|
|
101
|
:content => {:comments => 'Created the page',
|
|
101
|
:content => {:comments => 'Created the page',
|
|
102
|
:text => "h1. New page\n\nThis is a new page",
|
|
102
|
:text => "h1. New page\n\nThis is a new page",
|
|
103
|
:version => 0},
|
|
103
|
:version => 0},
|
|
104
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
104
|
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
105
|
end
|
|
105
|
end
|
|
106
|
end
|
|
106
|
end
|
|
107
|
page = Project.find(1).wiki.find_page('New page')
|
|
107
|
page = Project.find(1).wiki.find_page('New page')
|
|
108
|
assert_equal 1, page.attachments.count
|
|
108
|
assert_equal 1, page.attachments.count
|
|
109
|
assert_equal 'testfile.txt', page.attachments.first.filename
|
|
109
|
assert_equal 'testfile.txt', page.attachments.first.filename
|
|
110
|
end
|
|
110
|
end
|
|
111
|
|
|
111
|
|
|
112
|
def test_update_page
|
|
112
|
def test_update_page
|
|
113
|
@request.session[:user_id] = 2
|
|
113
|
@request.session[:user_id] = 2
|
|
114
|
assert_no_difference 'WikiPage.count' do
|
|
114
|
assert_no_difference 'WikiPage.count' do
|
|
115
|
assert_no_difference 'WikiContent.count' do
|
|
115
|
assert_no_difference 'WikiContent.count' do
|
|
116
|
assert_difference 'WikiContent::Version.count' do
|
|
116
|
assert_difference 'WikiContent::Version.count' do
|
|
117
|
put :update, :project_id => 1,
|
|
117
|
put :update, :project_id => 1,
|
|
118
|
:id => 'Another_page',
|
|
118
|
:id => 'Another_page',
|
|
119
|
:content => {
|
|
119
|
:content => {
|
|
120
|
:comments => "my comments",
|
|
120
|
:comments => "my comments",
|
|
121
|
:text => "edited",
|
|
121
|
:text => "edited",
|
|
122
|
:version => 1
|
|
122
|
:version => 1
|
|
123
|
}
|
|
123
|
}
|
|
124
|
end
|
|
124
|
end
|
|
125
|
end
|
|
125
|
end
|
|
126
|
end
|
|
126
|
end
|
|
127
|
assert_redirected_to '/projects/ecookbook/wiki/Another_page'
|
|
127
|
assert_redirected_to '/projects/ecookbook/wiki/Another_page'
|
|
128
|
|
|
128
|
|
|
129
|
page = Wiki.find(1).pages.find_by_title('Another_page')
|
|
129
|
page = Wiki.find(1).pages.find_by_title('Another_page')
|
|
130
|
assert_equal "edited", page.content.text
|
|
130
|
assert_equal "edited", page.content.text
|
|
131
|
assert_equal 2, page.content.version
|
|
131
|
assert_equal 2, page.content.version
|
|
132
|
assert_equal "my comments", page.content.comments
|
|
132
|
assert_equal "my comments", page.content.comments
|
|
133
|
end
|
|
133
|
end
|
|
134
|
|
|
134
|
|
|
135
|
def test_update_page_with_failure
|
|
135
|
def test_update_page_with_failure
|
|
136
|
@request.session[:user_id] = 2
|
|
136
|
@request.session[:user_id] = 2
|
|
137
|
assert_no_difference 'WikiPage.count' do
|
|
137
|
assert_no_difference 'WikiPage.count' do
|
|
138
|
assert_no_difference 'WikiContent.count' do
|
|
138
|
assert_no_difference 'WikiContent.count' do
|
|
139
|
assert_no_difference 'WikiContent::Version.count' do
|
|
139
|
assert_no_difference 'WikiContent::Version.count' do
|
|
140
|
put :update, :project_id => 1,
|
|
140
|
put :update, :project_id => 1,
|
|
141
|
:id => 'Another_page',
|
|
141
|
:id => 'Another_page',
|
|
142
|
:content => {
|
|
142
|
:content => {
|
|
143
|
:comments => 'a' * 300, # failure here, comment is too long
|
|
143
|
:comments => 'a' * 300, # failure here, comment is too long
|
|
144
|
:text => 'edited',
|
|
144
|
:text => 'edited',
|
|
145
|
:version => 1
|
|
145
|
:version => 1
|
|
146
|
}
|
|
146
|
}
|
|
147
|
end
|
|
147
|
end
|
|
148
|
end
|
|
148
|
end
|
|
149
|
end
|
|
149
|
end
|
|
150
|
assert_response :success
|
|
150
|
assert_response :success
|
|
151
|
assert_template 'edit'
|
|
151
|
assert_template 'edit'
|
|
152
|
|
|
152
|
|
|
153
|
assert_error_tag :descendant => {:content => /Comment is too long/}
|
|
153
|
assert_error_tag :descendant => {:content => /Comment is too long/}
|
|
154
|
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
|
|
154
|
assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => 'edited'
|
|
155
|
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
|
|
155
|
assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'}
|
|
156
|
end
|
|
156
|
end
|
|
157
|
|
|
157
|
|
|
158
|
def test_update_stale_page_should_not_raise_an_error
|
|
158
|
def test_update_stale_page_should_not_raise_an_error
|
|
159
|
@request.session[:user_id] = 2
|
|
159
|
@request.session[:user_id] = 2
|
|
160
|
c = Wiki.find(1).find_page('Another_page').content
|
|
160
|
c = Wiki.find(1).find_page('Another_page').content
|
|
161
|
c.text = 'Previous text'
|
|
161
|
c.text = 'Previous text'
|
|
162
|
c.save!
|
|
162
|
c.save!
|
|
163
|
assert_equal 2, c.version
|
|
163
|
assert_equal 2, c.version
|
|
164
|
|
|
164
|
|
|
165
|
assert_no_difference 'WikiPage.count' do
|
|
165
|
assert_no_difference 'WikiPage.count' do
|
|
166
|
assert_no_difference 'WikiContent.count' do
|
|
166
|
assert_no_difference 'WikiContent.count' do
|
|
167
|
assert_no_difference 'WikiContent::Version.count' do
|
|
167
|
assert_no_difference 'WikiContent::Version.count' do
|
|
168
|
put :update, :project_id => 1,
|
|
168
|
put :update, :project_id => 1,
|
|
169
|
:id => 'Another_page',
|
|
169
|
:id => 'Another_page',
|
|
170
|
:content => {
|
|
170
|
:content => {
|
|
171
|
:comments => 'My comments',
|
|
171
|
:comments => 'My comments',
|
|
172
|
:text => 'Text should not be lost',
|
|
172
|
:text => 'Text should not be lost',
|
|
173
|
:version => 1
|
|
173
|
:version => 1
|
|
174
|
}
|
|
174
|
}
|
|
175
|
end
|
|
175
|
end
|
|
176
|
end
|
|
176
|
end
|
|
177
|
end
|
|
177
|
end
|
|
178
|
assert_response :success
|
|
178
|
assert_response :success
|
|
179
|
assert_template 'edit'
|
|
179
|
assert_template 'edit'
|
|
180
|
assert_tag :div,
|
|
180
|
assert_tag :div,
|
|
181
|
:attributes => { :class => /error/ },
|
|
181
|
:attributes => { :class => /error/ },
|
|
182
|
:content => /Data has been updated by another user/
|
|
182
|
:content => /Data has been updated by another user/
|
|
183
|
assert_tag 'textarea',
|
|
183
|
assert_tag 'textarea',
|
|
184
|
:attributes => { :name => 'content[text]' },
|
|
184
|
:attributes => { :name => 'content[text]' },
|
|
185
|
:content => /Text should not be lost/
|
|
185
|
:content => /Text should not be lost/
|
|
186
|
assert_tag 'input',
|
|
186
|
assert_tag 'input',
|
|
187
|
:attributes => { :name => 'content[comments]', :value => 'My comments' }
|
|
187
|
:attributes => { :name => 'content[comments]', :value => 'My comments' }
|
|
188
|
|
|
188
|
|
|
189
|
c.reload
|
|
189
|
c.reload
|
|
190
|
assert_equal 'Previous text', c.text
|
|
190
|
assert_equal 'Previous text', c.text
|
|
191
|
assert_equal 2, c.version
|
|
191
|
assert_equal 2, c.version
|
|
192
|
end
|
|
192
|
end
|
|
193
|
|
|
193
|
|
|
194
|
def test_preview
|
|
194
|
def test_preview
|
|
195
|
@request.session[:user_id] = 2
|
|
195
|
@request.session[:user_id] = 2
|
|
196
|
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
|
|
196
|
xhr :post, :preview, :project_id => 1, :id => 'CookBook_documentation',
|
|
197
|
:content => { :comments => '',
|
|
197
|
:content => { :comments => '',
|
|
198
|
:text => 'this is a *previewed text*',
|
|
198
|
:text => 'this is a *previewed text*',
|
|
199
|
:version => 3 }
|
|
199
|
:version => 3 }
|
|
200
|
assert_response :success
|
|
200
|
assert_response :success
|
|
201
|
assert_template 'common/_preview'
|
|
201
|
assert_template 'common/_preview'
|
|
202
|
assert_tag :tag => 'strong', :content => /previewed text/
|
|
202
|
assert_tag :tag => 'strong', :content => /previewed text/
|
|
203
|
end
|
|
203
|
end
|
|
204
|
|
|
204
|
|
|
205
|
def test_preview_new_page
|
|
205
|
def test_preview_new_page
|
|
206
|
@request.session[:user_id] = 2
|
|
206
|
@request.session[:user_id] = 2
|
|
207
|
xhr :post, :preview, :project_id => 1, :id => 'New page',
|
|
207
|
xhr :post, :preview, :project_id => 1, :id => 'New page',
|
|
208
|
:content => { :text => 'h1. New page',
|
|
208
|
:content => { :text => 'h1. New page',
|
|
209
|
:comments => '',
|
|
209
|
:comments => '',
|
|
210
|
:version => 0 }
|
|
210
|
:version => 0 }
|
|
211
|
assert_response :success
|
|
211
|
assert_response :success
|
|
212
|
assert_template 'common/_preview'
|
|
212
|
assert_template 'common/_preview'
|
|
213
|
assert_tag :tag => 'h1', :content => /New page/
|
|
213
|
assert_tag :tag => 'h1', :content => /New page/
|
|
214
|
end
|
|
214
|
end
|
|
215
|
|
|
215
|
|
|
216
|
def test_history
|
|
216
|
def test_history
|
|
217
|
get :history, :project_id => 1, :id => 'CookBook_documentation'
|
|
217
|
get :history, :project_id => 1, :id => 'CookBook_documentation'
|
|
218
|
assert_response :success
|
|
218
|
assert_response :success
|
|
219
|
assert_template 'history'
|
|
219
|
assert_template 'history'
|
|
220
|
assert_not_nil assigns(:versions)
|
|
220
|
assert_not_nil assigns(:versions)
|
|
221
|
assert_equal 3, assigns(:versions).size
|
|
221
|
assert_equal 3, assigns(:versions).size
|
|
222
|
assert_select "input[type=submit][name=commit]"
|
|
222
|
assert_select "input[type=submit][name=commit]"
|
|
223
|
end
|
|
223
|
end
|
|
224
|
|
|
224
|
|
|
225
|
def test_history_with_one_version
|
|
225
|
def test_history_with_one_version
|
|
226
|
get :history, :project_id => 1, :id => 'Another_page'
|
|
226
|
get :history, :project_id => 1, :id => 'Another_page'
|
|
227
|
assert_response :success
|
|
227
|
assert_response :success
|
|
228
|
assert_template 'history'
|
|
228
|
assert_template 'history'
|
|
229
|
assert_not_nil assigns(:versions)
|
|
229
|
assert_not_nil assigns(:versions)
|
|
230
|
assert_equal 1, assigns(:versions).size
|
|
230
|
assert_equal 1, assigns(:versions).size
|
|
231
|
assert_select "input[type=submit][name=commit]", false
|
|
231
|
assert_select "input[type=submit][name=commit]", false
|
|
232
|
end
|
|
232
|
end
|
|
233
|
|
|
233
|
|
|
234
|
def test_diff
|
|
234
|
def test_diff
|
|
235
|
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1
|
|
235
|
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1
|
|
236
|
assert_response :success
|
|
236
|
assert_response :success
|
|
237
|
assert_template 'diff'
|
|
237
|
assert_template 'diff'
|
|
238
|
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
|
|
238
|
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
|
|
239
|
:content => /updated/
|
|
239
|
:content => /updated/
|
|
240
|
end
|
|
240
|
end
|
|
241
|
|
|
241
|
|
|
242
|
def test_annotate
|
|
242
|
def test_annotate
|
|
243
|
get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2
|
|
243
|
get :annotate, :project_id => 1, :id => 'CookBook_documentation', :version => 2
|
|
244
|
assert_response :success
|
|
244
|
assert_response :success
|
|
245
|
assert_template 'annotate'
|
|
245
|
assert_template 'annotate'
|
|
246
|
# Line 1
|
|
246
|
# Line 1
|
|
247
|
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1' },
|
|
247
|
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1' },
|
|
248
|
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/ },
|
|
248
|
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/ },
|
|
249
|
:child => { :tag => 'td', :content => /h1\. CookBook documentation/ }
|
|
249
|
:child => { :tag => 'td', :content => /h1\. CookBook documentation/ }
|
|
250
|
# Line 2
|
|
250
|
# Line 2
|
|
251
|
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '2' },
|
|
251
|
assert_tag :tag => 'tr', :child => { :tag => 'th', :attributes => {:class => 'line-num'}, :content => '2' },
|
|
252
|
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
|
|
252
|
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
|
|
253
|
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
|
253
|
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
|
254
|
end
|
|
254
|
end
|
|
255
|
|
|
255
|
|
|
256
|
def test_get_rename
|
|
256
|
def test_get_rename
|
|
257
|
@request.session[:user_id] = 2
|
|
257
|
@request.session[:user_id] = 2
|
|
258
|
get :rename, :project_id => 1, :id => 'Another_page'
|
|
258
|
get :rename, :project_id => 1, :id => 'Another_page'
|
|
259
|
assert_response :success
|
|
259
|
assert_response :success
|
|
260
|
assert_template 'rename'
|
|
260
|
assert_template 'rename'
|
|
261
|
assert_tag 'option',
|
|
261
|
assert_tag 'option',
|
|
262
|
:attributes => {:value => ''},
|
|
262
|
:attributes => {:value => ''},
|
|
263
|
:content => '',
|
|
263
|
:content => '',
|
|
264
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
264
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
265
|
assert_no_tag 'option',
|
|
265
|
assert_no_tag 'option',
|
|
266
|
:attributes => {:selected => 'selected'},
|
|
266
|
:attributes => {:selected => 'selected'},
|
|
267
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
267
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
268
|
end
|
|
268
|
end
|
|
269
|
|
|
269
|
|
|
270
|
def test_get_rename_child_page
|
|
270
|
def test_get_rename_child_page
|
|
271
|
@request.session[:user_id] = 2
|
|
271
|
@request.session[:user_id] = 2
|
|
272
|
get :rename, :project_id => 1, :id => 'Child_1'
|
|
272
|
get :rename, :project_id => 1, :id => 'Child_1'
|
|
273
|
assert_response :success
|
|
273
|
assert_response :success
|
|
274
|
assert_template 'rename'
|
|
274
|
assert_template 'rename'
|
|
275
|
assert_tag 'option',
|
|
275
|
assert_tag 'option',
|
|
276
|
:attributes => {:value => ''},
|
|
276
|
:attributes => {:value => ''},
|
|
277
|
:content => '',
|
|
277
|
:content => '',
|
|
278
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
278
|
:parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}}
|
|
279
|
assert_tag 'option',
|
|
279
|
assert_tag 'option',
|
|
280
|
:attributes => {:value => '2', :selected => 'selected'},
|
|
280
|
:attributes => {:value => '2', :selected => 'selected'},
|
|
281
|
:content => /Another page/,
|
|
281
|
:content => /Another page/,
|
|
282
|
:parent => {
|
|
282
|
:parent => {
|
|
283
|
:tag => 'select',
|
|
283
|
:tag => 'select',
|
|
284
|
:attributes => {:name => 'wiki_page[parent_id]'}
|
|
284
|
:attributes => {:name => 'wiki_page[parent_id]'}
|
|
285
|
}
|
|
285
|
}
|
|
286
|
end
|
|
286
|
end
|
|
287
|
|
|
287
|
|
|
288
|
def test_rename_with_redirect
|
|
288
|
def test_rename_with_redirect
|
|
289
|
@request.session[:user_id] = 2
|
|
289
|
@request.session[:user_id] = 2
|
|
290
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
290
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
291
|
:wiki_page => { :title => 'Another renamed page',
|
|
291
|
:wiki_page => { :title => 'Another renamed page',
|
|
292
|
:redirect_existing_links => 1 }
|
|
292
|
:redirect_existing_links => 1 }
|
|
293
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
|
|
293
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
|
|
294
|
wiki = Project.find(1).wiki
|
|
294
|
wiki = Project.find(1).wiki
|
|
295
|
# Check redirects
|
|
295
|
# Check redirects
|
|
296
|
assert_not_nil wiki.find_page('Another page')
|
|
296
|
assert_not_nil wiki.find_page('Another page')
|
|
297
|
assert_nil wiki.find_page('Another page', :with_redirect => false)
|
|
297
|
assert_nil wiki.find_page('Another page', :with_redirect => false)
|
|
298
|
end
|
|
298
|
end
|
|
299
|
|
|
299
|
|
|
300
|
def test_rename_without_redirect
|
|
300
|
def test_rename_without_redirect
|
|
301
|
@request.session[:user_id] = 2
|
|
301
|
@request.session[:user_id] = 2
|
|
302
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
302
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
303
|
:wiki_page => { :title => 'Another renamed page',
|
|
303
|
:wiki_page => { :title => 'Another renamed page',
|
|
304
|
:redirect_existing_links => "0" }
|
|
304
|
:redirect_existing_links => "0" }
|
|
305
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
|
|
305
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_renamed_page'
|
|
306
|
wiki = Project.find(1).wiki
|
|
306
|
wiki = Project.find(1).wiki
|
|
307
|
# Check that there's no redirects
|
|
307
|
# Check that there's no redirects
|
|
308
|
assert_nil wiki.find_page('Another page')
|
|
308
|
assert_nil wiki.find_page('Another page')
|
|
309
|
end
|
|
309
|
end
|
|
310
|
|
|
310
|
|
|
311
|
def test_rename_with_parent_assignment
|
|
311
|
def test_rename_with_parent_assignment
|
|
312
|
@request.session[:user_id] = 2
|
|
312
|
@request.session[:user_id] = 2
|
|
313
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
313
|
post :rename, :project_id => 1, :id => 'Another_page',
|
|
314
|
:wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' }
|
|
314
|
:wiki_page => { :title => 'Another page', :redirect_existing_links => "0", :parent_id => '4' }
|
|
315
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
|
|
315
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
|
|
316
|
assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent
|
|
316
|
assert_equal WikiPage.find(4), WikiPage.find_by_title('Another_page').parent
|
|
317
|
end
|
|
317
|
end
|
|
318
|
|
|
318
|
|
|
319
|
def test_rename_with_parent_unassignment
|
|
319
|
def test_rename_with_parent_unassignment
|
|
320
|
@request.session[:user_id] = 2
|
|
320
|
@request.session[:user_id] = 2
|
|
321
|
post :rename, :project_id => 1, :id => 'Child_1',
|
|
321
|
post :rename, :project_id => 1, :id => 'Child_1',
|
|
322
|
:wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' }
|
|
322
|
:wiki_page => { :title => 'Child 1', :redirect_existing_links => "0", :parent_id => '' }
|
|
323
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
|
|
323
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Child_1'
|
|
324
|
assert_nil WikiPage.find_by_title('Child_1').parent
|
|
324
|
assert_nil WikiPage.find_by_title('Child_1').parent
|
|
325
|
end
|
|
325
|
end
|
|
326
|
|
|
326
|
|
|
327
|
def test_destroy_child
|
|
327
|
def test_destroy_child
|
|
328
|
@request.session[:user_id] = 2
|
|
328
|
@request.session[:user_id] = 2
|
|
329
|
delete :destroy, :project_id => 1, :id => 'Child_1'
|
|
329
|
delete :destroy, :project_id => 1, :id => 'Child_1'
|
|
330
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
330
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
331
|
end
|
|
331
|
end
|
|
332
|
|
|
332
|
|
|
333
|
def test_destroy_parent
|
|
333
|
def test_destroy_parent
|
|
334
|
@request.session[:user_id] = 2
|
|
334
|
@request.session[:user_id] = 2
|
|
335
|
assert_no_difference('WikiPage.count') do
|
|
335
|
assert_no_difference('WikiPage.count') do
|
|
336
|
delete :destroy, :project_id => 1, :id => 'Another_page'
|
|
336
|
delete :destroy, :project_id => 1, :id => 'Another_page'
|
|
337
|
end
|
|
337
|
end
|
|
338
|
assert_response :success
|
|
338
|
assert_response :success
|
|
339
|
assert_template 'destroy'
|
|
339
|
assert_template 'destroy'
|
|
340
|
end
|
|
340
|
end
|
|
341
|
|
|
341
|
|
|
342
|
def test_destroy_parent_with_nullify
|
|
342
|
def test_destroy_parent_with_nullify
|
|
343
|
@request.session[:user_id] = 2
|
|
343
|
@request.session[:user_id] = 2
|
|
344
|
assert_difference('WikiPage.count', -1) do
|
|
344
|
assert_difference('WikiPage.count', -1) do
|
|
345
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify'
|
|
345
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'nullify'
|
|
346
|
end
|
|
346
|
end
|
|
347
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
347
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
348
|
assert_nil WikiPage.find_by_id(2)
|
|
348
|
assert_nil WikiPage.find_by_id(2)
|
|
349
|
end
|
|
349
|
end
|
|
350
|
|
|
350
|
|
|
351
|
def test_destroy_parent_with_cascade
|
|
351
|
def test_destroy_parent_with_cascade
|
|
352
|
@request.session[:user_id] = 2
|
|
352
|
@request.session[:user_id] = 2
|
|
353
|
assert_difference('WikiPage.count', -3) do
|
|
353
|
assert_difference('WikiPage.count', -3) do
|
|
354
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy'
|
|
354
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'destroy'
|
|
355
|
end
|
|
355
|
end
|
|
356
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
356
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
357
|
assert_nil WikiPage.find_by_id(2)
|
|
357
|
assert_nil WikiPage.find_by_id(2)
|
|
358
|
assert_nil WikiPage.find_by_id(5)
|
|
358
|
assert_nil WikiPage.find_by_id(5)
|
|
359
|
end
|
|
359
|
end
|
|
360
|
|
|
360
|
|
|
361
|
def test_destroy_parent_with_reassign
|
|
361
|
def test_destroy_parent_with_reassign
|
|
362
|
@request.session[:user_id] = 2
|
|
362
|
@request.session[:user_id] = 2
|
|
363
|
assert_difference('WikiPage.count', -1) do
|
|
363
|
assert_difference('WikiPage.count', -1) do
|
|
364
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
|
|
364
|
delete :destroy, :project_id => 1, :id => 'Another_page', :todo => 'reassign', :reassign_to_id => 1
|
|
365
|
end
|
|
365
|
end
|
|
366
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
366
|
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
|
|
367
|
assert_nil WikiPage.find_by_id(2)
|
|
367
|
assert_nil WikiPage.find_by_id(2)
|
|
368
|
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
|
|
368
|
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
|
|
369
|
end
|
|
369
|
end
|
|
370
|
|
|
370
|
|
|
371
|
def test_index
|
|
371
|
def test_index
|
|
372
|
get :index, :project_id => 'ecookbook'
|
|
372
|
get :index, :project_id => 'ecookbook'
|
|
373
|
assert_response :success
|
|
373
|
assert_response :success
|
|
374
|
assert_template 'index'
|
|
374
|
assert_template 'index'
|
|
375
|
pages = assigns(:pages)
|
|
375
|
pages = assigns(:pages)
|
|
376
|
assert_not_nil pages
|
|
376
|
assert_not_nil pages
|
|
377
|
assert_equal Project.find(1).wiki.pages.size, pages.size
|
|
377
|
assert_equal Project.find(1).wiki.pages.size, pages.size
|
|
378
|
assert_equal pages.first.content.updated_on, pages.first.updated_on
|
|
378
|
assert_equal pages.first.content.updated_on, pages.first.updated_on
|
|
379
|
|
|
379
|
|
|
380
|
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
|
380
|
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
|
381
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
|
|
381
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
|
|
382
|
:content => 'CookBook documentation' },
|
|
382
|
:content => 'CookBook documentation' },
|
|
383
|
:child => { :tag => 'ul',
|
|
383
|
:child => { :tag => 'ul',
|
|
384
|
:child => { :tag => 'li',
|
|
384
|
:child => { :tag => 'li',
|
|
385
|
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
|
385
|
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
|
386
|
:content => 'Page with an inline image' } } } },
|
|
386
|
:content => 'Page with an inline image' } } } },
|
|
387
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
|
|
387
|
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
|
|
388
|
:content => 'Another page' } }
|
|
388
|
:content => 'Another page' } }
|
|
389
|
end
|
|
389
|
end
|
|
|
|
|
390
|
|
|
|
|
|
391
|
def test_index_should_include_atom_link
|
|
|
|
|
392
|
get :index, :project_id => 'ecookbook'
|
|
|
|
|
393
|
assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
|
|
|
|
|
394
|
end
|
|
390
|
|
|
395
|
|
|
391
|
context "GET :export" do
|
|
396
|
context "GET :export" do
|
|
392
|
context "with an authorized user to export the wiki" do
|
|
397
|
context "with an authorized user to export the wiki" do
|
|
393
|
setup do
|
|
398
|
setup do
|
|
394
|
@request.session[:user_id] = 2
|
|
399
|
@request.session[:user_id] = 2
|
|
395
|
get :export, :project_id => 'ecookbook'
|
|
400
|
get :export, :project_id => 'ecookbook'
|
|
396
|
end
|
|
401
|
end
|
|
397
|
|
|
402
|
|
|
398
|
should_respond_with :success
|
|
403
|
should_respond_with :success
|
|
399
|
should_assign_to :pages
|
|
404
|
should_assign_to :pages
|
|
400
|
should_respond_with_content_type "text/html"
|
|
405
|
should_respond_with_content_type "text/html"
|
|
401
|
should "export all of the wiki pages to a single html file" do
|
|
406
|
should "export all of the wiki pages to a single html file" do
|
|
402
|
assert_select "a[name=?]", "CookBook_documentation"
|
|
407
|
assert_select "a[name=?]", "CookBook_documentation"
|
|
403
|
assert_select "a[name=?]", "Another_page"
|
|
408
|
assert_select "a[name=?]", "Another_page"
|
|
404
|
assert_select "a[name=?]", "Page_with_an_inline_image"
|
|
409
|
assert_select "a[name=?]", "Page_with_an_inline_image"
|
|
405
|
end
|
|
410
|
end
|
|
406
|
|
|
411
|
|
|
407
|
end
|
|
412
|
end
|
|
408
|
|
|
413
|
|
|
409
|
context "with an unauthorized user" do
|
|
414
|
context "with an unauthorized user" do
|
|
410
|
setup do
|
|
415
|
setup do
|
|
411
|
get :export, :project_id => 'ecookbook'
|
|
416
|
get :export, :project_id => 'ecookbook'
|
|
412
|
|
|
417
|
|
|
413
|
should_respond_with :redirect
|
|
418
|
should_respond_with :redirect
|
|
414
|
should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :id => nil} }
|
|
419
|
should_redirect_to('wiki index') { {:action => 'show', :project_id => @project, :id => nil} }
|
|
415
|
end
|
|
420
|
end
|
|
416
|
end
|
|
421
|
end
|
|
417
|
end
|
|
422
|
end
|
|
418
|
|
|
423
|
|
|
419
|
context "GET :date_index" do
|
|
424
|
context "GET :date_index" do
|
|
420
|
setup do
|
|
425
|
setup do
|
|
421
|
get :date_index, :project_id => 'ecookbook'
|
|
426
|
get :date_index, :project_id => 'ecookbook'
|
|
422
|
end
|
|
427
|
end
|
|
423
|
|
|
428
|
|
|
424
|
should_respond_with :success
|
|
429
|
should_respond_with :success
|
|
425
|
should_assign_to :pages
|
|
430
|
should_assign_to :pages
|
|
426
|
should_assign_to :pages_by_date
|
|
431
|
should_assign_to :pages_by_date
|
|
427
|
should_render_template 'wiki/date_index'
|
|
432
|
should_render_template 'wiki/date_index'
|
|
428
|
|
|
433
|
|
|
|
|
|
434
|
should "include atom link" do
|
|
|
|
|
435
|
assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'}
|
|
|
|
|
436
|
end
|
|
429
|
end
|
|
437
|
end
|
|
430
|
|
|
438
|
|
|
431
|
def test_not_found
|
|
439
|
def test_not_found
|
|
432
|
get :show, :project_id => 999
|
|
440
|
get :show, :project_id => 999
|
|
433
|
assert_response 404
|
|
441
|
assert_response 404
|
|
434
|
end
|
|
442
|
end
|
|
435
|
|
|
443
|
|
|
436
|
def test_protect_page
|
|
444
|
def test_protect_page
|
|
437
|
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
|
445
|
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
|
438
|
assert !page.protected?
|
|
446
|
assert !page.protected?
|
|
439
|
@request.session[:user_id] = 2
|
|
447
|
@request.session[:user_id] = 2
|
|
440
|
post :protect, :project_id => 1, :id => page.title, :protected => '1'
|
|
448
|
post :protect, :project_id => 1, :id => page.title, :protected => '1'
|
|
441
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
|
|
449
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'Another_page'
|
|
442
|
assert page.reload.protected?
|
|
450
|
assert page.reload.protected?
|
|
443
|
end
|
|
451
|
end
|
|
444
|
|
|
452
|
|
|
445
|
def test_unprotect_page
|
|
453
|
def test_unprotect_page
|
|
446
|
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
|
454
|
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
|
447
|
assert page.protected?
|
|
455
|
assert page.protected?
|
|
448
|
@request.session[:user_id] = 2
|
|
456
|
@request.session[:user_id] = 2
|
|
449
|
post :protect, :project_id => 1, :id => page.title, :protected => '0'
|
|
457
|
post :protect, :project_id => 1, :id => page.title, :protected => '0'
|
|
450
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation'
|
|
458
|
assert_redirected_to :action => 'show', :project_id => 'ecookbook', :id => 'CookBook_documentation'
|
|
451
|
assert !page.reload.protected?
|
|
459
|
assert !page.reload.protected?
|
|
452
|
end
|
|
460
|
end
|
|
453
|
|
|
461
|
|
|
454
|
def test_show_page_with_edit_link
|
|
462
|
def test_show_page_with_edit_link
|
|
455
|
@request.session[:user_id] = 2
|
|
463
|
@request.session[:user_id] = 2
|
|
456
|
get :show, :project_id => 1
|
|
464
|
get :show, :project_id => 1
|
|
457
|
assert_response :success
|
|
465
|
assert_response :success
|
|
458
|
assert_template 'show'
|
|
466
|
assert_template 'show'
|
|
459
|
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
|
467
|
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
|
460
|
end
|
|
468
|
end
|
|
461
|
|
|
469
|
|
|
462
|
def test_show_page_without_edit_link
|
|
470
|
def test_show_page_without_edit_link
|
|
463
|
@request.session[:user_id] = 4
|
|
471
|
@request.session[:user_id] = 4
|
|
464
|
get :show, :project_id => 1
|
|
472
|
get :show, :project_id => 1
|
|
465
|
assert_response :success
|
|
473
|
assert_response :success
|
|
466
|
assert_template 'show'
|
|
474
|
assert_template 'show'
|
|
467
|
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
|
475
|
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
|
468
|
end
|
|
476
|
end
|
|
469
|
|
|
477
|
|
|
470
|
def test_edit_unprotected_page
|
|
478
|
def test_edit_unprotected_page
|
|
471
|
# Non members can edit unprotected wiki pages
|
|
479
|
# Non members can edit unprotected wiki pages
|
|
472
|
@request.session[:user_id] = 4
|
|
480
|
@request.session[:user_id] = 4
|
|
473
|
get :edit, :project_id => 1, :id => 'Another_page'
|
|
481
|
get :edit, :project_id => 1, :id => 'Another_page'
|
|
474
|
assert_response :success
|
|
482
|
assert_response :success
|
|
475
|
assert_template 'edit'
|
|
483
|
assert_template 'edit'
|
|
476
|
end
|
|
484
|
end
|
|
477
|
|
|
485
|
|
|
478
|
def test_edit_protected_page_by_nonmember
|
|
486
|
def test_edit_protected_page_by_nonmember
|
|
479
|
# Non members can't edit protected wiki pages
|
|
487
|
# Non members can't edit protected wiki pages
|
|
480
|
@request.session[:user_id] = 4
|
|
488
|
@request.session[:user_id] = 4
|
|
481
|
get :edit, :project_id => 1, :id => 'CookBook_documentation'
|
|
489
|
get :edit, :project_id => 1, :id => 'CookBook_documentation'
|
|
482
|
assert_response 403
|
|
490
|
assert_response 403
|
|
483
|
end
|
|
491
|
end
|
|
484
|
|
|
492
|
|
|
485
|
def test_edit_protected_page_by_member
|
|
493
|
def test_edit_protected_page_by_member
|
|
486
|
@request.session[:user_id] = 2
|
|
494
|
@request.session[:user_id] = 2
|
|
487
|
get :edit, :project_id => 1, :id => 'CookBook_documentation'
|
|
495
|
get :edit, :project_id => 1, :id => 'CookBook_documentation'
|
|
488
|
assert_response :success
|
|
496
|
assert_response :success
|
|
489
|
assert_template 'edit'
|
|
497
|
assert_template 'edit'
|
|
490
|
end
|
|
498
|
end
|
|
491
|
|
|
499
|
|
|
492
|
def test_history_of_non_existing_page_should_return_404
|
|
500
|
def test_history_of_non_existing_page_should_return_404
|
|
493
|
get :history, :project_id => 1, :id => 'Unknown_page'
|
|
501
|
get :history, :project_id => 1, :id => 'Unknown_page'
|
|
494
|
assert_response 404
|
|
502
|
assert_response 404
|
|
495
|
end
|
|
503
|
end
|
|
496
|
end
|
|
504
|
end
|