end
def new
- @board = @project.boards.build(params[:board])
+ @board = @project.boards.build
+ @board.safe_attributes = params[:board]
end
def create
- @board = @project.boards.build(params[:board])
+ @board = @project.boards.build
+ @board.safe_attributes = params[:board]
if @board.save
flash[:notice] = l(:notice_successful_create)
redirect_to_settings_in_projects
end
def update
- if @board.update_attributes(params[:board])
+ @board.safe_attributes = params[:board]
+ if @board.save
redirect_to_settings_in_projects
else
render :action => 'edit'
# 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"
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
assert_equal 'Testing', Board.find(2).name
end
+ def test_update_position
+ @request.session[:user_id] = 2
+ put :update, :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_update_with_failure
@request.session[:user_id] = 2
put :update, :project_id => 1, :id => 2, :board => { :name => '', :description => 'Testing board update'}