Sort tag search result by name

closes #6734
This commit is contained in:
Steffen van Bergerem 2016-03-03 11:12:17 +01:00 committed by Dennis Schubert
parent 98d76af318
commit b98af83c9d
3 changed files with 8 additions and 1 deletions

View file

@ -1,6 +1,7 @@
# 0.5.8.0 # 0.5.8.0
## Refactor ## Refactor
* Sort tag autocompletion by tag name [#6734](https://github.com/diaspora/diaspora/pull/6734)
## Bug fixes ## Bug fixes
* Fix empty name field when editing aspect names [#6706](https://github.com/diaspora/diaspora/pull/6706) * Fix empty name field when editing aspect names [#6706](https://github.com/diaspora/diaspora/pull/6706)

View file

@ -8,7 +8,7 @@ module ActsAsTaggableOn
end end
def self.autocomplete(name) def self.autocomplete(name)
where("name LIKE ?", "#{name.downcase}%") where("name LIKE ?", "#{name.downcase}%").order("name ASC")
end end
def self.normalize(name) def self.normalize(name)

View file

@ -13,6 +13,12 @@ describe ActsAsTaggableOn::Tag, :type => :model do
it "does an end where on tags" do it "does an end where on tags" do
expect(tag.autocomplete("CAT")).to eq([tag_cats]) expect(tag.autocomplete("CAT")).to eq([tag_cats])
end end
it "sorts the results by name" do
tag_cat = tag.create(name: "cat")
tag_catt = tag.create(name: "catt")
expect(tag.autocomplete("CAT")).to eq([tag_cat, tag_cats, tag_catt])
end
end end
describe ".normalize" do describe ".normalize" do