Commit b98af83c authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Dennis Schubert

Sort tag search result by name

closes #6734
parent 98d76af3
# 0.5.8.0
## Refactor
* Sort tag autocompletion by tag name [#6734](https://github.com/diaspora/diaspora/pull/6734)
## Bug fixes
* Fix empty name field when editing aspect names [#6706](https://github.com/diaspora/diaspora/pull/6706)
......
......@@ -8,7 +8,7 @@ module ActsAsTaggableOn
end
def self.autocomplete(name)
where("name LIKE ?", "#{name.downcase}%")
where("name LIKE ?", "#{name.downcase}%").order("name ASC")
end
def self.normalize(name)
......
......@@ -13,6 +13,12 @@ describe ActsAsTaggableOn::Tag, :type => :model do
it "does an end where on tags" do
expect(tag.autocomplete("CAT")).to eq([tag_cats])
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
describe ".normalize" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment