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
16947dc0
Commit
16947dc0
authored
Apr 14, 2012
by
Jean-Philippe Lang
Committed by
Holger Just
Apr 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[984] Allow to change locked and sticky status and the board of messages
parent
e7d96825
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
message.rb
app/models/message.rb
+1
-2
messages_controller_test.rb
test/functional/messages_controller_test.rb
+24
-0
No files found.
app/models/message.rb
View file @
16947dc0
...
...
@@ -41,7 +41,6 @@ class Message < ActiveRecord::Base
acts_as_watchable
attr_protected
:locked
,
:sticky
validates_presence_of
:board
,
:subject
,
:content
validates_length_of
:subject
,
:maximum
=>
255
...
...
@@ -51,7 +50,7 @@ class Message < ActiveRecord::Base
:conditions
=>
Project
.
allowed_to_condition
(
args
.
first
||
User
.
current
,
:view_messages
)
}
}
safe_attributes
'subject'
,
'content'
safe_attributes
'locked'
,
'sticky'
,
safe_attributes
'locked'
,
'sticky'
,
'board_id'
,
:if
=>
lambda
{
|
message
,
user
|
user
.
allowed_to?
(
:edit_messages
,
message
.
project
)
}
...
...
test/functional/messages_controller_test.rb
View file @
16947dc0
...
...
@@ -121,6 +121,30 @@ class MessagesControllerTest < ActionController::TestCase
assert_equal
'New body'
,
message
.
content
end
def
test_post_edit_sticky_and_locked
@request
.
session
[
:user_id
]
=
2
post
:edit
,
:board_id
=>
1
,
:id
=>
1
,
:message
=>
{
:subject
=>
'New subject'
,
:content
=>
'New body'
,
:locked
=>
'1'
,
:sticky
=>
'1'
}
assert_redirected_to
'/boards/1/topics/1'
message
=
Message
.
find
(
1
)
assert_equal
true
,
message
.
sticky?
assert_equal
true
,
message
.
locked?
end
def
test_post_edit_should_allow_to_change_board
@request
.
session
[
:user_id
]
=
2
post
:edit
,
:board_id
=>
1
,
:id
=>
1
,
:message
=>
{
:subject
=>
'New subject'
,
:content
=>
'New body'
,
:board_id
=>
2
}
assert_redirected_to
'/boards/2/topics/1'
message
=
Message
.
find
(
1
)
assert_equal
Board
.
find
(
2
),
message
.
board
end
def
test_reply
@request
.
session
[
:user_id
]
=
2
post
:reply
,
:board_id
=>
1
,
:id
=>
1
,
:reply
=>
{
:content
=>
'This is a test reply'
,
:subject
=>
'Test reply'
}
...
...
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