Prevents NoMethodError on @available_filters.has_key? in query.rb (#1178).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1454 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-05-25 12:50:33 +00:00
parent 02757f5892
commit 03f0236a6e
2 changed files with 6 additions and 1 deletions

View File

@ -227,7 +227,7 @@ class Query < ActiveRecord::Base
end end
def label_for(field) def label_for(field)
label = @available_filters[field][:name] if @available_filters.has_key?(field) label = available_filters[field][:name] if available_filters.has_key?(field)
label ||= field.gsub(/\_id$/, "") label ||= field.gsub(/\_id$/, "")
end end

View File

@ -116,6 +116,11 @@ class QueryTest < Test::Unit::TestCase
assert q.has_column?(c) assert q.has_column?(c)
end end
def test_label_for
q = Query.new
assert_equal 'assigned_to', q.label_for('assigned_to_id')
end
def test_editable_by def test_editable_by
admin = User.find(1) admin = User.find(1)
manager = User.find(2) manager = User.find(2)