@@ -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 | } |
@@ -6,13 +6,17 | |||
|
6 | 6 | <p><label for="message_subject"><%= l(:field_subject) %></label><br /> |
|
7 | 7 | <%= f.text_field :subject, :size => 120, :id => "message_subject" %> |
|
8 | 8 | |
|
9 | <% if !replying && User.current.allowed_to?(:edit_messages, @project) %> | |
|
9 | <% unless replying %> | |
|
10 | <% if @message.safe_attribute? 'sticky' %> | |
|
10 | 11 | <label><%= f.check_box :sticky %><%= l(:label_board_sticky) %></label> |
|
12 | <% end %> | |
|
13 | <% if @message.safe_attribute? 'locked' %> | |
|
11 | 14 | <label><%= f.check_box :locked %><%= l(:label_board_locked) %></label> |
|
15 | <% end %> | |
|
12 | 16 | <% end %> |
|
13 | 17 | </p> |
|
14 | 18 | |
|
15 |
<% if !replying && !@message.new_record? && |
|
|
19 | <% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %> | |
|
16 | 20 | <p><label><%= l(:label_board) %></label><br /> |
|
17 | 21 | <%= f.select :board_id, @project.boards.collect {|b| [b.name, b.id]} %></p> |
|
18 | 22 | <% end %> |
@@ -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