Skip to content

Commit

Permalink
Merge 4b3f36e into 9d662a9
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrd-senya committed Aug 15, 2016
2 parents 9d662a9 + 4b3f36e commit 6e7e3d6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
12 changes: 9 additions & 3 deletions app/assets/javascripts/contact-list.js
Expand Up @@ -15,9 +15,15 @@ var List = {
});

streamEl.html(string);
$('.aspect_membership_dropdown').each(function(){
new app.views.AspectMembership({el: this});
});

if (data.contacts) {
var contacts = new app.collections.Contacts(data.contacts);
$(".aspect_membership_dropdown.placeholder").each(function() {
var personId = $(this).data("personId");
var view = new app.views.AspectMembership({person: contacts.findWhere({"person_id": personId}).person});
$(this).html(view.render().$el);
});
}
},

startSearchDelay: function (theSearch) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/people_controller.rb
Expand Up @@ -63,7 +63,7 @@ def refresh_search
self.formats = self.formats + [:html]
@answer_html = render_to_string :partial => 'people/person', :locals => @hashes.first
end
render :json => { :search_count => @people.count, :search_html => @answer_html }.to_json
render json: {search_html: @answer_html, contacts: gon.preloads[:contacts]}.to_json
end

# renders the persons user profile page
Expand Down
7 changes: 7 additions & 0 deletions features/desktop/search.feature
Expand Up @@ -26,6 +26,13 @@ Scenario: search for a inexistent user and go to the search page

Then I should see "Users matching Trinity" within "#search_title"

Scenario: search for a user in background
When I sign in as "bob@bob.bob"
And I search for "user@pod.tld"
And a person with ID "user@pod.tld" has been discovered
Then I should see "user@pod.tld" within ".stream .info.diaspora_handle"
And I should see a ".aspect_dropdown" within ".stream"

Scenario: search for a not searchable user
When I sign in as "carol@example.com"
And I go to the edit profile page
Expand Down
4 changes: 4 additions & 0 deletions features/step_definitions/user_steps.rb
Expand Up @@ -229,3 +229,7 @@
Then /^I should get a zipped file$/ do
expect(page.response_headers["Content-Type"]).to eq("application/zip")
end

And /^a person with ID "([^\"]*)" has been discovered$/ do |diaspora_id|
FactoryGirl.create(:person, diaspora_handle: diaspora_id)
end
6 changes: 6 additions & 0 deletions features/support/poor_mans_webmock.rb
Expand Up @@ -26,4 +26,10 @@ def perform(*_args)
# don't post to services in cucumber
end
end

class FetchWebfinger < Base
def perform(*_args)
# don't do real discovery in cucumber
end
end
end
21 changes: 11 additions & 10 deletions spec/controllers/people_controller_spec.rb
Expand Up @@ -490,19 +490,20 @@
:profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth"))
end

describe 'via json' do
it 'returns a zero count when a search fails' do
get :refresh_search, :q => "weweweKorth", :format => 'json'
expect(response.body).to eq({:search_count=>0, :search_html=>""}.to_json)
describe "via json" do
it "returns no data when a search fails" do
get :refresh_search, q: "weweweKorth", format: "json"
expect(response.body).to eq({search_html: "", contacts: nil}.to_json)
end

it 'returns with a zero count unless a fully composed name is sent' do
get :refresh_search, :q => "Korth"
expect(response.body).to eq({:search_count=>0, :search_html=>""}.to_json)
it "returns no data unless a fully composed name is sent" do
get :refresh_search, q: "Korth"
expect(response.body).to eq({search_html: "", contacts: nil}.to_json)
end
it 'returns with a found name' do
get :refresh_search, :q => @korth.diaspora_handle
expect(JSON.parse( response.body )["search_count"]).to eq(1)

it "returns with a found name" do
get :refresh_search, q: @korth.diaspora_handle
expect(JSON.parse(response.body)["contacts"].size).to eq(1)
end
end
end
Expand Down

0 comments on commit 6e7e3d6

Please sign in to comment.