FIX: exact group match always should be added

This commit is contained in:
Sam 2016-10-24 12:43:38 +11:00
parent 6c334c3786
commit f083994f5a
4 changed files with 17 additions and 1 deletions

View File

@ -59,7 +59,7 @@ function organizeResults(r, options) {
if (r.groups) { if (r.groups) {
r.groups.every(function(g) { r.groups.every(function(g) {
if (results.length > limit) return false; if (results.length > limit && options.term !== g.name) return false;
if (exclude.indexOf(g.name) === -1) { if (exclude.indexOf(g.name) === -1) {
groups.push(g); groups.push(g);
results.push(g); results.push(g);

View File

@ -0,0 +1,3 @@
export default {
"/search/user/search?term=team&include_mentionable_groups=true": {"users":[{"username":"TeaMoe","name":"TeaMoe","avatar_template":"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png"},{"username":"TeamOneJ","name":"J Cobb","avatar_template":"https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png"},{"username":"kudos","name":"Team Blogeto.com","avatar_template":"/user_avatar/meta.discourse.org/kudos/{size}/62185_1.png"},{"username":"RosieLinda","name":"Linda Teaman","avatar_template":"https://avatars.discourse.org/v3/letter/r/bc8723/{size}.png"},{"username":"legalatom","name":"Team LegalAtom","avatar_template":"https://avatars.discourse.org/v3/letter/l/a9a28c/{size}.png"},{"username":"dzsat_team","name":"Dz Sat Dz Sat","avatar_template":"https://avatars.discourse.org/v3/letter/d/eb9ed0/{size}.png"}],"groups":[{"name":"team","usernames":[]}]}
};

View File

@ -90,6 +90,10 @@ export default function() {
return response({}); return response({});
}); });
this.get('/users/search/users', () => {
return response(fixturesByUrl['/search/user/search?term=team&include_mentionable_groups=true']);
});
this.put('/users/eviltrout', () => response({ user: {} })); this.put('/users/eviltrout', () => response({ user: {} }));

View File

@ -0,0 +1,9 @@
import userSearch from 'discourse/lib/user-search';
module("lib:user-search");
test("it places groups unconditionally for exact match", function() {
return userSearch({term: 'team'}).then((results)=>{
equal(results[results.length-1]["name"], "team");
});
});