##// END OF EJS Templates
Fixed: Unable to change locked, sticky flags and board when editing a message (#10564)....
Jean-Philippe Lang -
r9216:a7bacf70fb18
parent child
Show More
@@ -37,7 +37,6 class Message < ActiveRecord::Base
37 37 :author_key => :author_id
38 38 acts_as_watchable
39 39
40 attr_protected :locked, :sticky
41 40 validates_presence_of :board, :subject, :content
42 41 validates_length_of :subject, :maximum => 255
43 42 validate :cannot_reply_to_locked_topic, :on => :create
@@ -50,7 +49,7 class Message < ActiveRecord::Base
50 49 :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
51 50
52 51 safe_attributes 'subject', 'content'
53 safe_attributes 'locked', 'sticky',
52 safe_attributes 'locked', 'sticky', 'board_id',
54 53 :if => lambda {|message, user|
55 54 user.allowed_to?(:edit_messages, message.project)
56 55 }
@@ -131,6 +131,30 class MessagesControllerTest < ActionController::TestCase
131 131 assert_equal 'New body', message.content
132 132 end
133 133
134 def test_post_edit_sticky_and_locked
135 @request.session[:user_id] = 2
136 post :edit, :board_id => 1, :id => 1,
137 :message => { :subject => 'New subject',
138 :content => 'New body',
139 :locked => '1',
140 :sticky => '1'}
141 assert_redirected_to '/boards/1/topics/1'
142 message = Message.find(1)
143 assert_equal true, message.sticky?
144 assert_equal true, message.locked?
145 end
146
147 def test_post_edit_should_allow_to_change_board
148 @request.session[:user_id] = 2
149 post :edit, :board_id => 1, :id => 1,
150 :message => { :subject => 'New subject',
151 :content => 'New body',
152 :board_id => 2}
153 assert_redirected_to '/boards/2/topics/1'
154 message = Message.find(1)
155 assert_equal Board.find(2), message.board
156 end
157
134 158 def test_reply
135 159 @request.session[:user_id] = 2
136 160 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
General Comments 0
You need to be logged in to leave comments. Login now