Merge branch 'next-minor' into develop
This commit is contained in:
commit
75dcc1008e
5 changed files with 65 additions and 11 deletions
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
## Bug fixes
|
||||
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)
|
||||
* Closed accounts will no longer show up in the account search [#7042](https://github.com/diaspora/diaspora/pull/7042)
|
||||
|
||||
## Features
|
||||
* Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class PeopleController < ApplicationController
|
|||
format.any(:html, :mobile) do
|
||||
#only do it if it is an email address
|
||||
if diaspora_id?(search_query)
|
||||
@people = Person.where(:diaspora_handle => search_query.downcase)
|
||||
@people = Person.where(diaspora_handle: search_query.downcase, closed_account: false)
|
||||
if @people.empty?
|
||||
Workers::FetchWebfinger.perform_async(search_query)
|
||||
@background_query = search_query.downcase
|
||||
|
|
@ -55,7 +55,7 @@ class PeopleController < ApplicationController
|
|||
|
||||
def refresh_search
|
||||
@aspect = :search
|
||||
@people = Person.where(:diaspora_handle => search_query.downcase)
|
||||
@people = Person.where(diaspora_handle: search_query.downcase, closed_account: false)
|
||||
@answer_html = ""
|
||||
unless @people.empty?
|
||||
@hashes = hashes_for_people(@people, @aspects)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ class Person < ActiveRecord::Base
|
|||
).searchable(user)
|
||||
end
|
||||
|
||||
query.where(sql, *tokens)
|
||||
query.where(closed_account: false)
|
||||
.where(sql, *tokens)
|
||||
.includes(:profile)
|
||||
.order(["contacts.user_id IS NULL", "profiles.last_name ASC", "profiles.first_name ASC"])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,10 +15,19 @@ describe PeopleController, :type => :controller do
|
|||
|
||||
describe '#index (search)' do
|
||||
before do
|
||||
@eugene = FactoryGirl.create(:person,
|
||||
:profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w"))
|
||||
@korth = FactoryGirl.create(:person,
|
||||
:profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth"))
|
||||
@eugene = FactoryGirl.create(
|
||||
:person,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Eugene", last_name: "w")
|
||||
)
|
||||
@korth = FactoryGirl.create(
|
||||
:person,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Evan", last_name: "Korth")
|
||||
)
|
||||
@closed = FactoryGirl.create(
|
||||
:person,
|
||||
closed_account: true,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Closed", last_name: "Account")
|
||||
)
|
||||
end
|
||||
|
||||
describe 'via json' do
|
||||
|
|
@ -36,6 +45,13 @@ describe PeopleController, :type => :controller do
|
|||
get :index, :q => "Korth", :format => 'json'
|
||||
expect(assigns[:hashes]).to be_nil
|
||||
end
|
||||
|
||||
it "doesn't include closed accounts" do
|
||||
get :index, q: "Closed", format: "json"
|
||||
expect(JSON.parse(response.body).size).to eq(0)
|
||||
get :index, q: @closed.diaspora_handle, format: "json"
|
||||
expect(JSON.parse(response.body).size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'via html' do
|
||||
|
|
@ -64,6 +80,11 @@ describe PeopleController, :type => :controller do
|
|||
get :index, :q => "Eugene@Example1.ORG"
|
||||
expect(assigns[:background_query]).to eq("eugene@example1.org")
|
||||
end
|
||||
|
||||
it "doesn't include closed accounts" do
|
||||
get :index, q: @closed.diaspora_handle
|
||||
expect(assigns[:people].size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'query is not a tag or a diaspora ID' do
|
||||
|
|
@ -114,6 +135,11 @@ describe PeopleController, :type => :controller do
|
|||
get :index, :q => "Eug"
|
||||
expect(assigns[:people]).not_to match_array([eugene2])
|
||||
end
|
||||
|
||||
it "doesn't include closed accounts" do
|
||||
get :index, q: "Closed"
|
||||
expect(assigns[:people].size).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -516,10 +542,19 @@ describe PeopleController, :type => :controller do
|
|||
|
||||
describe '#refresh_search ' do
|
||||
before(:each)do
|
||||
@eugene = FactoryGirl.create(:person,
|
||||
:profile => FactoryGirl.build(:profile, :first_name => "Eugene", :last_name => "w"))
|
||||
@korth = FactoryGirl.create(:person,
|
||||
:profile => FactoryGirl.build(:profile, :first_name => "Evan", :last_name => "Korth"))
|
||||
@eugene = FactoryGirl.create(
|
||||
:person,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Eugene", last_name: "w")
|
||||
)
|
||||
@korth = FactoryGirl.create(
|
||||
:person,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Evan", last_name: "Korth")
|
||||
)
|
||||
@closed = FactoryGirl.create(
|
||||
:person,
|
||||
closed_account: true,
|
||||
profile: FactoryGirl.build(:profile, first_name: "Closed", last_name: "Account")
|
||||
)
|
||||
end
|
||||
|
||||
describe "via json" do
|
||||
|
|
@ -537,6 +572,11 @@ describe PeopleController, :type => :controller do
|
|||
get :refresh_search, q: @korth.diaspora_handle
|
||||
expect(JSON.parse(response.body)["contacts"].size).to eq(1)
|
||||
end
|
||||
|
||||
it "doesn't include closed accounts" do
|
||||
get :refresh_search, q: @closed.diaspora_handle
|
||||
expect(JSON.parse(response.body)["contacts"]).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -299,6 +299,7 @@ describe Person, :type => :model do
|
|||
@yevgeniy_dodis = FactoryGirl.build(:person)
|
||||
@casey_grippi = FactoryGirl.build(:person)
|
||||
@invisible_person = FactoryGirl.build(:person)
|
||||
@closed_account = FactoryGirl.build(:person, closed_account: true)
|
||||
|
||||
@robert_grimm.profile.first_name = "Robert"
|
||||
@robert_grimm.profile.last_name = "Grimm"
|
||||
|
|
@ -325,6 +326,11 @@ describe Person, :type => :model do
|
|||
@invisible_person.profile.searchable = false
|
||||
@invisible_person.profile.save
|
||||
@invisible_person.reload
|
||||
|
||||
@closed_account.profile.first_name = "Closed"
|
||||
@closed_account.profile.last_name = "Account"
|
||||
@closed_account.profile.save
|
||||
@closed_account.reload
|
||||
end
|
||||
|
||||
it 'orders results by last name' do
|
||||
|
|
@ -379,6 +385,12 @@ describe Person, :type => :model do
|
|||
expect(Person.search("Johnson", @user)).to be_empty
|
||||
end
|
||||
|
||||
it "doesn't display closed accounts" do
|
||||
expect(Person.search("Closed", @user)).to be_empty
|
||||
expect(Person.search("Account", @user)).to be_empty
|
||||
expect(Person.search(@closed_account.diaspora_handle, @user)).to be_empty
|
||||
end
|
||||
|
||||
it "displays contacts that are not searchable" do
|
||||
@user.contacts.create(person: @invisible_person, aspects: [@user.aspects.first])
|
||||
people = Person.search("Johnson", @user)
|
||||
|
|
|
|||
Loading…
Reference in a new issue