only include mutual sharing contacts in conversations form on contacts page

fixes #7377
This commit is contained in:
kas70 2018-03-21 15:49:39 +01:00 committed by Benjamin Neff
parent c7709e29f2
commit 40fc175d6e
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 7 additions and 2 deletions

View file

@ -81,7 +81,7 @@ app.pages.Contacts = Backbone.View.extend({
showMessageModal: function(){
$("#conversationModal").on("modal:loaded", function() {
var people = _.pluck(app.contacts.filter(function(contact) {
return contact.inAspect(app.aspect.get("id"));
return contact.person.get("relationship") === "mutual" && contact.inAspect(app.aspect.get("id"));
}), "person");
new app.views.ConversationsForm({prefill: people});
});

View file

@ -20,6 +20,9 @@ describe ContactsController, :type => :controller do
end
it "generates the aspects_manage_contacts_json fixture", fixture: true do
# adds one not mutual contact
bob.share_with(FactoryGirl.create(:person), @aspect)
get :index, params: {a_id: @aspect.id, page: "1"}, format: :json
save_fixture(response.body, "aspects_manage_contacts_json")
end

View file

@ -297,7 +297,9 @@ describe("app.pages.Contacts", function(){
expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled();
var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill;
var contacts = app.contacts.filter(function(contact) { return contact.inAspect(app.aspect.get("id")); });
var contacts = app.contacts.filter(function(contact) {
return contact.person.get("relationship") === "mutual" && contact.inAspect(app.aspect.get("id"));
});
expect(_.pluck(prefill, "id")).toEqual(contacts.map(function(contact) { return contact.person.id; }));
});
});