164 |
164 |
assert_nil page.parent
|
165 |
165 |
end
|
166 |
166 |
|
|
167 |
test "PUT /projects/:project_id/wiki/:title.json with attachment via params[:attachments]" do
|
|
168 |
set_tmp_attachments_directory
|
|
169 |
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
|
170 |
assert_difference 'WikiPage.count' do
|
|
171 |
assert_difference 'WikiContent::Version.count' do
|
|
172 |
put '/projects/ecookbook/wiki/New_page_from_API.json',
|
|
173 |
{:wiki_page => {:text => 'New content from API with Attachments', :comments => 'API create with Attachments'},
|
|
174 |
:attachments => [:token => attachment.token, :filename => 'testfile.txt', :content_type => "text/plain"]},
|
|
175 |
credentials('jsmith')
|
|
176 |
assert_response 201
|
|
177 |
end
|
|
178 |
end
|
|
179 |
|
|
180 |
page = WikiPage.order('id DESC').first
|
|
181 |
assert_equal 'New_page_from_API', page.title
|
|
182 |
assert_include attachment, page.attachments
|
|
183 |
assert_equal attachment.filename, page.attachments.first.filename
|
|
184 |
end
|
|
185 |
|
|
186 |
test "PUT /projects/:project_id/wiki/:title.xml with attachment via params[:wiki_page][:uploads]" do
|
|
187 |
set_tmp_attachments_directory
|
|
188 |
attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2)
|
|
189 |
assert_difference 'WikiPage.count' do
|
|
190 |
assert_difference 'WikiContent::Version.count' do
|
|
191 |
put '/projects/ecookbook/wiki/New_page_from_API.xml',
|
|
192 |
{:wiki_page => {:text => 'New content from API with Attachments', :comments => 'API create with Attachments',
|
|
193 |
:uploads => [:token => attachment.token, :filename => 'testfile.txt', :content_type => "text/plain"]}},
|
|
194 |
credentials('jsmith')
|
|
195 |
assert_response 201
|
|
196 |
end
|
|
197 |
end
|
|
198 |
|
|
199 |
page = WikiPage.order('id DESC').first
|
|
200 |
assert_equal 'New_page_from_API', page.title
|
|
201 |
assert_include attachment, page.attachments
|
|
202 |
assert_equal attachment.filename, page.attachments.first.filename
|
|
203 |
end
|
|
204 |
|
167 |
205 |
test "PUT /projects/:project_id/wiki/:title.xml with parent" do
|
168 |
206 |
assert_difference 'WikiPage.count' do
|
169 |
207 |
assert_difference 'WikiContent::Version.count' do
|