Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider cefffc60 rédigé par Steffen van Bergerem's avatar Steffen van Bergerem
Parcourir les fichiers

Move contacts search to contacts#index

parent 9f28b935
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -32,7 +32,7 @@ app.views.PublisherMention = app.views.SearchBase.extend({ ...@@ -32,7 +32,7 @@ app.views.PublisherMention = app.views.SearchBase.extend({
typeaheadInput: this.typeaheadInput, typeaheadInput: this.typeaheadInput,
customSearch: true, customSearch: true,
autoselect: true, autoselect: true,
remoteRoute: "/contacts/search" remoteRoute: "/contacts"
}); });
}, },
......
...@@ -13,17 +13,12 @@ class ContactsController < ApplicationController ...@@ -13,17 +13,12 @@ class ContactsController < ApplicationController
# Used by the mobile site # Used by the mobile site
format.mobile { set_up_contacts_mobile } format.mobile { set_up_contacts_mobile }
end
end
def search
@people = Person.search(params[:q], current_user, only_contacts: true).limit(15)
respond_to do |format| # Used for mentions in the publisher
format.json do format.json {
@people = @people.limit(15) @people = Person.search(params[:q], current_user, only_contacts: true).limit(15)
render json: @people render json: @people
end }
end end
end end
......
...@@ -155,9 +155,6 @@ Diaspora::Application.routes.draw do ...@@ -155,9 +155,6 @@ Diaspora::Application.routes.draw do
resources :contacts, only: %i(index) resources :contacts, only: %i(index)
get "contacts/search" => "contacts#search"
resources :aspect_memberships, :only => [:destroy, :create] resources :aspect_memberships, :only => [:destroy, :create]
resources :share_visibilities, :only => [:update] resources :share_visibilities, :only => [:update]
resources :blocks, :only => [:create, :destroy] resources :blocks, :only => [:create, :destroy]
......
...@@ -48,28 +48,26 @@ describe ContactsController, :type => :controller do ...@@ -48,28 +48,26 @@ describe ContactsController, :type => :controller do
expect(contacts.to_set).to eq(bob.contacts.to_set) expect(contacts.to_set).to eq(bob.contacts.to_set)
end end
end end
end
describe "#search" do context "format json" do
before do before do
@eugene = FactoryGirl.create(:person, profile: FactoryGirl.build(:profile, first_name: "Eugene", last_name: "W")) @person1 = FactoryGirl.create(:person)
bob.share_with(@eugene, bob.aspects.first) bob.share_with(@person1, bob.aspects.first)
@casey = FactoryGirl.create(:person, profile: FactoryGirl.build(:profile, first_name: "Casey", last_name: "W")) @person2 = FactoryGirl.create(:person)
end end
describe "via json" do
it "succeeds" do it "succeeds" do
get :search, q: "Eugene", format: "json" get :index, q: @person1.first_name, format: "json"
expect(response).to be_success expect(response).to be_success
end end
it "responds with json" do it "responds with json" do
get :search, q: "Eugene", format: "json" get :index, q: @person1.first_name, format: "json"
expect(response.body).to eq([@eugene].to_json) expect(response.body).to eq([@person1].to_json)
end end
it "only returns contacts" do it "only returns contacts" do
get :search, q: "Casey", format: "json" get :index, q: @person2.first_name, format: "json"
expect(response.body).to eq([].to_json) expect(response.body).to eq([].to_json)
end end
end end
......
...@@ -19,7 +19,7 @@ describe("app.views.PublisherMention", function() { ...@@ -19,7 +19,7 @@ describe("app.views.PublisherMention", function() {
expect(call.args[0].typeaheadInput.selector).toBe("#publisher .typeahead-mention-box"); expect(call.args[0].typeaheadInput.selector).toBe("#publisher .typeahead-mention-box");
expect(call.args[0].customSearch).toBeTruthy(); expect(call.args[0].customSearch).toBeTruthy();
expect(call.args[0].autoselect).toBeTruthy(); expect(call.args[0].autoselect).toBeTruthy();
expect(call.args[0].remoteRoute).toBe("/contacts/search"); expect(call.args[0].remoteRoute).toBe("/contacts");
}); });
it("calls bindTypeaheadEvents", function() { it("calls bindTypeaheadEvents", function() {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter