summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/query.rb2
-rw-r--r--test/unit/query_test.rb5
2 files changed, 6 insertions, 1 deletions
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)