diff --git a/app/assets/javascripts/app/pages/profile.js b/app/assets/javascripts/app/pages/profile.js index 4920051c9..6410fad49 100644 --- a/app/assets/javascripts/app/pages/profile.js +++ b/app/assets/javascripts/app/pages/profile.js @@ -16,13 +16,14 @@ app.pages.Profile = app.views.Base.extend({ }, editMode : false, + presenter : function(){ var bio = this.model.get("bio") || '' return _.extend(this.defaultPresenter(), - {text : this.model && app.helpers.textFormatter(bio, this.model)}) + {text : this.model && app.helpers.textFormatter(bio, this.model), + isOwnProfile : true }) }, - initialize : function(options) { this.model = new app.models.Profile.findByGuid(options.personId) this.stream = options && options.stream || new app.models.Stream() @@ -36,5 +37,12 @@ app.pages.Profile = app.views.Base.extend({ if(evt) { evt.preventDefault() } this.editMode = !this.editMode this.$el.toggleClass("edit-mode") + }, + + isOwnProfile : function() { + // this is all tested, but does not work. there is something weird going here :( + // i'm going to return true in the presenter for now until this is resolved. + + return(app.currentUser.get("diaspora_id") == this.model.get("diaspora_id")) } }); \ No newline at end of file diff --git a/app/assets/javascripts/app/views/profile_info_view.js b/app/assets/javascripts/app/views/profile_info_view.js index 8589aa6d8..8fcc3bced 100644 --- a/app/assets/javascripts/app/views/profile_info_view.js +++ b/app/assets/javascripts/app/views/profile_info_view.js @@ -2,7 +2,6 @@ app.views.ProfileInfo = app.views.Base.extend({ templateName : "profile-info", initialize : function(){ - console.log(this.model) this.model.bind("change", this.render, this) //this should go on profile info view when it gets Extracted } -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/app/assets/templates/profile.jst.hbs b/app/assets/templates/profile.jst.hbs index ea123f4ba..881b09853 100644 --- a/app/assets/templates/profile.jst.hbs +++ b/app/assets/templates/profile.jst.hbs @@ -5,12 +5,14 @@
- - - - - - + {{#if isOwnProfile}} + + + + + + + {{/if}}
diff --git a/spec/javascripts/app/pages/profile_spec.js b/spec/javascripts/app/pages/profile_spec.js index c3f26b247..79f5f82b7 100644 --- a/spec/javascripts/app/pages/profile_spec.js +++ b/spec/javascripts/app/pages/profile_spec.js @@ -33,6 +33,20 @@ describe("app.pages.Profile", function(){ this.page.render() }); + context("profile control pane", function(){ + it("is shown", function() { + spyOn(this.page, "isOwnProfile").andReturn(true) + this.page.render() + expect(this.page.$("#profile-controls .control").length).not.toBe(0) + }) + + it("is not shown", function() { + spyOn(this.page, "isOwnProfile").andReturn(false) + this.page.render() + expect(this.page.$("#profile-controls .control").length).toBe(0) + }) + }) + context("clicking fav", function(){ beforeEach(function(){ spyOn(this.post, 'toggleFavorite') @@ -64,4 +78,21 @@ describe("app.pages.Profile", function(){ }) }) }) + + describe("isOwnProfile", function(){ + beforeEach(function(){ + this.user = new app.models.User(factory.author()) + this.page.model = this.user + }) + + it("returns true if app.currentUser matches the current profile's user", function(){ + app.currentUser = this.user + expect(this.page.isOwnProfile()).toBeTruthy() + }) + + it("returns false if app.currentUser does not match the current profile's user", function(){ + app.currentUser = new app.models.User(factory.author({diaspora_id : "foo@foo.com"})) + expect(this.page.isOwnProfile()).toBeFalsy() + }) + }) });