Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
65097e7d
Commit
65097e7d
authored
Nov 05, 2010
by
Tim Felgentreff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing tests
parent
5dda7e34
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
44 deletions
+6
-44
wiki_controller.rb
app/controllers/wiki_controller.rb
+4
-34
edit.rhtml
app/views/wiki/edit.rhtml
+1
-1
journals_controller_test.rb
test/functional/journals_controller_test.rb
+0
-7
wiki_controller_test.rb
test/functional/wiki_controller_test.rb
+1
-2
No files found.
app/controllers/wiki_controller.rb
View file @
65097e7d
...
@@ -90,40 +90,9 @@ class WikiController < ApplicationController
...
@@ -90,40 +90,9 @@ class WikiController < ApplicationController
@content
.
text
=
initial_page_content
(
@page
)
if
@content
.
text
.
blank?
@content
.
text
=
initial_page_content
(
@page
)
if
@content
.
text
.
blank?
# don't keep previous comment
# don't keep previous comment
@content
.
comments
=
nil
@content
.
comments
=
nil
if
request
.
get?
# To prevent StaleObjectError exception when reverting to a previous version
# To prevent StaleObjectError exception when reverting to a previous version
@content
.
lock_version
=
@page
.
content
.
lock_version
@content
.
lock_version
=
@page
.
content
.
lock_version
else
if
!
@page
.
new_record?
&&
@content
.
text
==
params
[
:content
][
:text
]
attachments
=
Attachment
.
attach_files
(
@page
,
params
[
:attachments
])
render_attachment_warning_if_needed
(
@page
)
# don't save if text wasn't changed
redirect_to
:action
=>
'index'
,
:project_id
=>
@project
,
:page
=>
@page
.
title
return
end
#@content.text = params[:content][:text]
#@content.comments = params[:content][:comments]
@content
.
init_journal
(
User
.
current
,
params
[
:content
][
:comments
])
@content
.
attributes
=
params
[
:content
]
@content
.
author
=
User
.
current
# if page is new @page.save will also save content, but not if page isn't a new record
if
(
@page
.
new_record?
?
@page
.
save
:
@content
.
save
)
attachments
=
Attachment
.
attach_files
(
@page
,
params
[
:attachments
])
render_attachment_warning_if_needed
(
@page
)
call_hook
(
:controller_wiki_edit_after_save
,
{
:params
=>
params
,
:page
=>
@page
})
redirect_to
:action
=>
'index'
,
:project_id
=>
@project
,
:page
=>
@page
.
title
end
end
@content
.
attributes
=
params
[
:content
]
@content
.
author
=
User
.
current
# if page is new @page.save will also save content, but not if page isn't a new record
if
(
@page
.
new_record?
?
@page
.
save
:
@content
.
save
)
attachments
=
Attachment
.
attach_files
(
@page
,
params
[
:attachments
])
render_attachment_warning_if_needed
(
@page
)
call_hook
(
:controller_wiki_edit_after_save
,
{
:params
=>
params
,
:page
=>
@page
})
redirect_to
:action
=>
'show'
,
:project_id
=>
@project
,
:page
=>
@page
.
title
end
rescue
ActiveRecord
::
StaleObjectError
rescue
ActiveRecord
::
StaleObjectError
# Optimistic locking exception
# Optimistic locking exception
flash
[
:error
]
=
l
(
:notice_locking_conflict
)
flash
[
:error
]
=
l
(
:notice_locking_conflict
)
...
@@ -148,6 +117,7 @@ class WikiController < ApplicationController
...
@@ -148,6 +117,7 @@ class WikiController < ApplicationController
redirect_to
:action
=>
'show'
,
:project_id
=>
@project
,
:id
=>
@page
.
title
redirect_to
:action
=>
'show'
,
:project_id
=>
@project
,
:id
=>
@page
.
title
return
return
end
end
params
[
:content
].
delete
(
:version
)
# The version count is automatically increased
@content
.
attributes
=
params
[
:content
]
@content
.
attributes
=
params
[
:content
]
@content
.
author
=
User
.
current
@content
.
author
=
User
.
current
# if page is new @page.save will also save content, but not if page isn't a new record
# if page is new @page.save will also save content, but not if page isn't a new record
...
...
app/views/wiki/edit.rhtml
View file @
65097e7d
<h2>
<%=
h
@page
.
pretty_title
%>
</h2>
<h2>
<%=
h
@page
.
pretty_title
%>
</h2>
<%
form_for
:content
,
@content
,
:url
=>
{
:action
=>
'update'
,
:id
=>
@page
.
title
},
:html
=>
{
:method
=>
:put
,
:multipart
=>
true
,
:id
=>
'wiki_form'
}
do
|
f
|
%>
<%
form_for
:content
,
@content
,
:url
=>
{
:action
=>
'update'
,
:id
=>
@page
.
title
},
:html
=>
{
:method
=>
:put
,
:multipart
=>
true
,
:id
=>
'wiki_form'
}
do
|
f
|
%>
<%=
f
.
hidden_field
:version
%>
<%=
f
.
hidden_field
:
lock_
version
%>
<%=
error_messages_for
'content'
%>
<%=
error_messages_for
'content'
%>
<p>
<%=
f
.
text_area
:text
,
:cols
=>
100
,
:rows
=>
25
,
:class
=>
'wiki-edit'
,
:accesskey
=>
accesskey
(
:edit
)
%>
</p>
<p>
<%=
f
.
text_area
:text
,
:cols
=>
100
,
:rows
=>
25
,
:class
=>
'wiki-edit'
,
:accesskey
=>
accesskey
(
:edit
)
%>
</p>
...
...
test/functional/journals_controller_test.rb
View file @
65097e7d
...
@@ -30,13 +30,6 @@ class JournalsControllerTest < ActionController::TestCase
...
@@ -30,13 +30,6 @@ class JournalsControllerTest < ActionController::TestCase
@response
=
ActionController
::
TestResponse
.
new
@response
=
ActionController
::
TestResponse
.
new
User
.
current
=
nil
User
.
current
=
nil
end
end
def
test_index
get
:index
,
:project_id
=>
1
assert_response
:success
assert_not_nil
assigns
(
:journals
)
assert_equal
'application/atom+xml'
,
@response
.
content_type
end
def
test_get_edit
def
test_get_edit
@request
.
session
[
:user_id
]
=
1
@request
.
session
[
:user_id
]
=
1
...
...
test/functional/wiki_controller_test.rb
View file @
65097e7d
...
@@ -83,8 +83,7 @@ class WikiControllerTest < ActionController::TestCase
...
@@ -83,8 +83,7 @@ class WikiControllerTest < ActionController::TestCase
put
:update
,
:project_id
=>
1
,
put
:update
,
:project_id
=>
1
,
:id
=>
'New page'
,
:id
=>
'New page'
,
:content
=>
{
:comments
=>
'Created the page'
,
:content
=>
{
:comments
=>
'Created the page'
,
:text
=>
"h1. New page
\n\n
This is a new page"
,
:text
=>
"h1. New page
\n\n
This is a new page"
}
:version
=>
0
}
assert_redirected_to
:action
=>
'show'
,
:project_id
=>
'ecookbook'
,
:id
=>
'New_page'
assert_redirected_to
:action
=>
'show'
,
:project_id
=>
'ecookbook'
,
:id
=>
'New_page'
page
=
Project
.
find
(
1
).
wiki
.
find_page
(
'New page'
)
page
=
Project
.
find
(
1
).
wiki
.
find_page
(
'New page'
)
assert
!
page
.
new_record?
assert
!
page
.
new_record?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment