diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-06 12:23:53 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-04-06 12:23:53 +0000 |
commit | cda408dd81ba449243aeeba465b8b830aae93417 (patch) | |
tree | 4c4567bc082802c5b584a5070159c3d524031c95 | |
parent | bec5e4443db7f264f7926e011f9ba28466c1bbfd (diff) | |
download | redmine-cda408dd81ba449243aeeba465b8b830aae93417.tar.gz redmine-cda408dd81ba449243aeeba465b8b830aae93417.zip |
Merged r9350 and r9351 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.3-stable@9353 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/message.rb | 3 | ||||
-rw-r--r-- | app/views/messages/_form.html.erb | 8 | ||||
-rw-r--r-- | test/functional/messages_controller_test.rb | 24 |
3 files changed, 31 insertions, 4 deletions
diff --git a/app/models/message.rb b/app/models/message.rb index 5721cb571..5d028870d 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -37,7 +37,6 @@ class Message < ActiveRecord::Base :author_key => :author_id acts_as_watchable - attr_protected :locked, :sticky validates_presence_of :board, :subject, :content validates_length_of :subject, :maximum => 255 validate :cannot_reply_to_locked_topic, :on => :create @@ -50,7 +49,7 @@ class Message < ActiveRecord::Base :conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } } 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) } diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index b3b0e130e..916f460e1 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -6,13 +6,17 @@ <p><label for="message_subject"><%= l(:field_subject) %></label><br /> <%= f.text_field :subject, :size => 120, :id => "message_subject" %> -<% if !replying && User.current.allowed_to?(:edit_messages, @project) %> +<% unless replying %> + <% if @message.safe_attribute? 'sticky' %> <label><%= f.check_box :sticky %><%= l(:label_board_sticky) %></label> + <% end %> + <% if @message.safe_attribute? 'locked' %> <label><%= f.check_box :locked %><%= l(:label_board_locked) %></label> + <% end %> <% end %> </p> -<% if !replying && !@message.new_record? && User.current.allowed_to?(:edit_messages, @project) %> +<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %> <p><label><%= l(:label_board) %></label><br /> <%= f.select :board_id, @project.boards.collect {|b| [b.name, b.id]} %></p> <% end %> diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 77c477d4a..256decffd 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -131,6 +131,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' } |