From 03f0236a6ee995363c54f958d66a0abbf0d3a827 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 May 2008 12:50:33 +0000 Subject: [PATCH] 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 --- app/models/query.rb | 2 +- test/unit/query_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/query.rb b/app/models/query.rb index f25b5c401..c19bb8d7e 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -227,7 +227,7 @@ class Query < ActiveRecord::Base end 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$/, "") end diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index e143e6fc2..147bfbea3 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -116,6 +116,11 @@ class QueryTest < Test::Unit::TestCase assert q.has_column?(c) end + def test_label_for + q = Query.new + assert_equal 'assigned_to', q.label_for('assigned_to_id') + end + def test_editable_by admin = User.find(1) manager = User.find(2)