diff --git a/app/models/query.rb b/app/models/query.rb index f25b5c40..c19bb8d7 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 e143e6fc..147bfbea 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)