diff options
author | Henare Degan <henare.degan@gmail.com> | 2012-10-18 18:18:21 +1100 |
---|---|---|
committer | Henare Degan <henare.degan@gmail.com> | 2012-10-18 18:39:02 +1100 |
commit | 9736e3ad0be4a64d6f6dd1d5c96d236dc1ac1b4b (patch) | |
tree | 0f2351652c4609d3e14c7512d5ae29aa90898d0d | |
parent | 0e7263201e58f00201e25e85ff2aa477f5521d30 (diff) |
Fix description of a search
Used to say "comments or requests which are " when you did: View requests > All requests > Follow
-rw-r--r-- | app/models/track_thing.rb | 7 | ||||
-rw-r--r-- | spec/models/track_thing_spec.rb | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index d1cef4d4d..2a61eb858 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -107,7 +107,12 @@ class TrackThing < ActiveRecord::Base end descriptions = [] if varieties.include? _("requests") - descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).sort.join(_(' or '))) + if statuses.empty? + # HACK: Relies on the 'descriptions.sort' below to luckily put this first + descriptions << _("all requests") + else + descriptions << _("requests which are {{list_of_statuses}}", :list_of_statuses => Array(statuses).sort.join(_(' or '))) + end varieties -= [_("requests")] end if descriptions.empty? and varieties.empty? diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 3647c6261..c42eb5e8b 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -37,7 +37,8 @@ describe TrackThing, "when tracking changes" do it "will make some sane descriptions of search-based tracks" do tests = { 'bob variety:user' => "users matching text 'bob'", 'bob (variety:sent OR variety:followup_sent OR variety:response OR variety:comment) (latest_status:successful OR latest_status:partially_successful OR latest_status:rejected OR latest_status:not_held)' => "comments or requests which are successful or unsuccessful matching text 'bob'", - '(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)' => 'requests which are awaiting a response' } + '(latest_status:waiting_response OR latest_status:waiting_clarification OR waiting_classification:true)' => 'requests which are awaiting a response', + ' (variety:sent OR variety:followup_sent OR variety:response OR variety:comment)' => 'all requests or comments' } tests.each do |query, description| track_thing = TrackThing.create_track_for_search_query(query) track_thing.track_query_description.should == description |