diff --git a/app/assets/javascripts/app/views/post/small_frame.js b/app/assets/javascripts/app/views/post/small_frame.js index ae79a1cb3..fe847d45d 100644 --- a/app/assets/javascripts/app/views/post/small_frame.js +++ b/app/assets/javascripts/app/views/post/small_frame.js @@ -71,7 +71,7 @@ app.views.Post.SmallFrame = app.views.Post.extend({ }, goToPost : function(evt) { - if(evt) { evt.stopImmediatePropagation(); } + if(evt) { evt.preventDefault() && evt.stopImmediatePropagation(); } app.setPreload('post',this.model.attributes) app.router.navigate(this.model.url(), true) } diff --git a/app/assets/javascripts/app/views/post/stream_frame.js b/app/assets/javascripts/app/views/post/stream_frame.js index ecc503373..7410fa66e 100644 --- a/app/assets/javascripts/app/views/post/stream_frame.js +++ b/app/assets/javascripts/app/views/post/stream_frame.js @@ -5,7 +5,7 @@ app.views.Post.StreamFrame = app.views.Base.extend({ subviews : { ".small-frame" : "smallFrameView", - '.stream-frame-feedback' : 'feedbackView' + ".stream-frame-feedback" : "feedbackView" }, initialize : function(options) { @@ -15,10 +15,15 @@ app.views.Post.StreamFrame = app.views.Base.extend({ }, events : { - 'click .content' : 'triggerInteracted' + 'click .content' : 'triggerInteracted', + "click a.permalink" : "goToPost" }, triggerInteracted : function() { this.stream.trigger("frame:interacted", this.model) + }, + + goToPost : function(evt) { + this.smallFrameView.goToPost(evt) } }); diff --git a/app/assets/templates/stream-frame.jst.hbs b/app/assets/templates/stream-frame.jst.hbs index 1d58685fb..83633409e 100644 --- a/app/assets/templates/stream-frame.jst.hbs +++ b/app/assets/templates/stream-frame.jst.hbs @@ -1,5 +1,5 @@ diff --git a/spec/javascripts/app/views/post/stream_frame_spec.js b/spec/javascripts/app/views/post/stream_frame_spec.js index ba526fc52..6e690e08c 100644 --- a/spec/javascripts/app/views/post/stream_frame_spec.js +++ b/spec/javascripts/app/views/post/stream_frame_spec.js @@ -3,12 +3,12 @@ describe("app.views.Post.StreamFrame", function(){ this.post = factory.post() this.stream = new Backbone.Model this.view = new app.views.Post.StreamFrame({model : this.post, stream: this.stream }) - }) + }); describe("rendering", function(){ beforeEach(function(){ this.view.render() - }) + }); context("clicking the content", function(){ it("triggers frame interacted", function(){ @@ -17,7 +17,21 @@ describe("app.views.Post.StreamFrame", function(){ this.view.$('.content').click() expect(spy).toHaveBeenCalledWith(this.post) }) + }) + }); + describe("going to a post", function(){ + beforeEach(function(){ + this.view.render() + }) + + context("clicking the permalink", function(){ + it("calls goToPost on the smallFrame view", function(){ + spyOn(app.router, "navigate").andReturn(true) + spyOn(this.view.smallFrameView, "goToPost") + this.view.$(".permalink").click() + expect(this.view.smallFrameView.goToPost).toHaveBeenCalled() + }) }) }) }); \ No newline at end of file