Loading app/assets/javascripts/app/views/profile_header_view.js +7 −2 Original line number Diff line number Diff line Loading @@ -81,8 +81,13 @@ app.views.ProfileHeader = app.views.Base.extend({ showMessageModal: function(){ $("#conversationModal").on("modal:loaded", function() { new app.views.ConversationsForm({prefill: gon.conversationPrefill}); new app.views.ConversationsForm({ prefill: [_.extend({ avatar: this.model.get("profile").avatar.small, handle: this.model.get("diaspora_id") }, this.model.attributes)] }); }.bind(this)); app.helpers.showModal("#conversationModal"); } }); Loading app/controllers/conversations_controller.rb +1 −3 Original line number Diff line number Diff line Loading @@ -103,9 +103,7 @@ class ConversationsController < ApplicationController render :layout => true else if params[:contact_id] gon.push conversation_prefill: [current_user.contacts.find(params[:contact_id]).person.as_json] elsif params[:aspect_id] if params[:aspect_id] gon.push conversation_prefill: current_user.aspects .find(params[:aspect_id]).contacts.map {|c| c.person.as_json } end Loading spec/controllers/conversations_controller_spec.rb +0 −5 Original line number Diff line number Diff line Loading @@ -21,11 +21,6 @@ describe ConversationsController, :type => :controller do expect(response).to be_success end it "assigns a contact if passed a contact id" do get :new, params: {contact_id: alice.contacts.first.id, modal: true} expect(controller.gon.conversation_prefill).to eq([alice.contacts.first.person.as_json]) end it "assigns a set of contacts if passed an aspect id" do get :new, params: {aspect_id: alice.aspects.first.id, modal: true} expect(controller.gon.conversation_prefill).to eq(alice.aspects.first.contacts.map {|c| c.person.as_json }) Loading spec/javascripts/app/views/profile_header_view_spec.js +11 −10 Original line number Diff line number Diff line Loading @@ -4,8 +4,11 @@ describe("app.views.ProfileHeader", function() { this.model = factory.personWithProfile({ diaspora_id: "my@pod", name: "User Name", relationship: 'mutual', profile: { tags: ['test'] } relationship: "mutual", profile: { avatar: {small: "http://example.org/avatar.jpg"}, tags: ["test"] } }); this.view = new app.views.ProfileHeader({model: this.model}); loginAs(factory.userAttrs()); Loading Loading @@ -71,17 +74,15 @@ describe("app.views.ProfileHeader", function() { }); it("initializes app.views.ConversationsForm with correct parameters when modal is loaded", function() { gon.conversationPrefill = [ {id: 1, name: "diaspora user", handle: "diaspora-user@pod.tld"}, {id: 2, name: "other diaspora user", handle: "other-diaspora-user@pod.tld"}, {id: 3, name: "user@pod.tld", handle: "user@pod.tld"} ]; spyOn(app.views.ConversationsForm.prototype, "initialize"); spyOn($.fn, "load").and.callFake(function(url, callback) { callback(); }); this.view.showMessageModal(); expect(app.views.ConversationsForm.prototype.initialize) .toHaveBeenCalledWith({prefill: gon.conversationPrefill}); expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled(); var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill; expect(prefill.length).toBe(1); expect(prefill[0].handle).toBe("my@pod"); expect(prefill[0].name).toBe("User Name"); expect(prefill[0].avatar).toBe("http://example.org/avatar.jpg"); }); }); }); Loading
app/assets/javascripts/app/views/profile_header_view.js +7 −2 Original line number Diff line number Diff line Loading @@ -81,8 +81,13 @@ app.views.ProfileHeader = app.views.Base.extend({ showMessageModal: function(){ $("#conversationModal").on("modal:loaded", function() { new app.views.ConversationsForm({prefill: gon.conversationPrefill}); new app.views.ConversationsForm({ prefill: [_.extend({ avatar: this.model.get("profile").avatar.small, handle: this.model.get("diaspora_id") }, this.model.attributes)] }); }.bind(this)); app.helpers.showModal("#conversationModal"); } }); Loading
app/controllers/conversations_controller.rb +1 −3 Original line number Diff line number Diff line Loading @@ -103,9 +103,7 @@ class ConversationsController < ApplicationController render :layout => true else if params[:contact_id] gon.push conversation_prefill: [current_user.contacts.find(params[:contact_id]).person.as_json] elsif params[:aspect_id] if params[:aspect_id] gon.push conversation_prefill: current_user.aspects .find(params[:aspect_id]).contacts.map {|c| c.person.as_json } end Loading
spec/controllers/conversations_controller_spec.rb +0 −5 Original line number Diff line number Diff line Loading @@ -21,11 +21,6 @@ describe ConversationsController, :type => :controller do expect(response).to be_success end it "assigns a contact if passed a contact id" do get :new, params: {contact_id: alice.contacts.first.id, modal: true} expect(controller.gon.conversation_prefill).to eq([alice.contacts.first.person.as_json]) end it "assigns a set of contacts if passed an aspect id" do get :new, params: {aspect_id: alice.aspects.first.id, modal: true} expect(controller.gon.conversation_prefill).to eq(alice.aspects.first.contacts.map {|c| c.person.as_json }) Loading
spec/javascripts/app/views/profile_header_view_spec.js +11 −10 Original line number Diff line number Diff line Loading @@ -4,8 +4,11 @@ describe("app.views.ProfileHeader", function() { this.model = factory.personWithProfile({ diaspora_id: "my@pod", name: "User Name", relationship: 'mutual', profile: { tags: ['test'] } relationship: "mutual", profile: { avatar: {small: "http://example.org/avatar.jpg"}, tags: ["test"] } }); this.view = new app.views.ProfileHeader({model: this.model}); loginAs(factory.userAttrs()); Loading Loading @@ -71,17 +74,15 @@ describe("app.views.ProfileHeader", function() { }); it("initializes app.views.ConversationsForm with correct parameters when modal is loaded", function() { gon.conversationPrefill = [ {id: 1, name: "diaspora user", handle: "diaspora-user@pod.tld"}, {id: 2, name: "other diaspora user", handle: "other-diaspora-user@pod.tld"}, {id: 3, name: "user@pod.tld", handle: "user@pod.tld"} ]; spyOn(app.views.ConversationsForm.prototype, "initialize"); spyOn($.fn, "load").and.callFake(function(url, callback) { callback(); }); this.view.showMessageModal(); expect(app.views.ConversationsForm.prototype.initialize) .toHaveBeenCalledWith({prefill: gon.conversationPrefill}); expect(app.views.ConversationsForm.prototype.initialize).toHaveBeenCalled(); var prefill = app.views.ConversationsForm.prototype.initialize.calls.mostRecent().args[0].prefill; expect(prefill.length).toBe(1); expect(prefill[0].handle).toBe("my@pod"); expect(prefill[0].name).toBe("User Name"); expect(prefill[0].avatar).toBe("http://example.org/avatar.jpg"); }); }); });