Backported r9140 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.3-stable@9156 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-03-07 18:40:41 +00:00
parent 4e64c01a32
commit 4a9013917d
3 changed files with 15 additions and 2 deletions

View File

@ -65,7 +65,8 @@ class BoardsController < ApplicationController
verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
def new
@board = Board.new(params[:board])
@board = Board.new
@board.safe_attributes = params[:board]
@board.project = @project
if request.post? && @board.save
flash[:notice] = l(:notice_successful_create)
@ -74,7 +75,8 @@ class BoardsController < ApplicationController
end
def edit
if request.post? && @board.update_attributes(params[:board])
@board.safe_attributes = params[:board]
if request.post? && @board.save
redirect_to_settings_in_projects
end
end

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class Board < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
@ -30,6 +31,8 @@ class Board < ActiveRecord::Base
named_scope :visible, lambda {|*args| { :include => :project,
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
safe_attributes 'name', 'description', 'move_to'
def visible?(user=User.current)
!user.nil? && user.allowed_to?(:view_messages, project)
end

View File

@ -88,6 +88,14 @@ class BoardsControllerTest < ActionController::TestCase
assert_equal 'Testing', Board.find(2).name
end
def test_update_position
@request.session[:user_id] = 2
post :edit, :project_id => 1, :id => 2, :board => { :move_to => 'highest'}
assert_redirected_to '/projects/ecookbook/settings/boards'
board = Board.find(2)
assert_equal 1, board.position
end
def test_post_destroy
@request.session[:user_id] = 2
assert_difference 'Board.count', -1 do