clicking a permalink on the new stream does not make an HTTP request to go to the post's page

This commit is contained in:
danielgrippi 2012-05-24 12:05:27 -07:00
parent 3e09d4ed14
commit 58ac040f8f
4 changed files with 25 additions and 6 deletions

View file

@ -71,7 +71,7 @@ app.views.Post.SmallFrame = app.views.Post.extend({
}, },
goToPost : function(evt) { goToPost : function(evt) {
if(evt) { evt.stopImmediatePropagation(); } if(evt) { evt.preventDefault() && evt.stopImmediatePropagation(); }
app.setPreload('post',this.model.attributes) app.setPreload('post',this.model.attributes)
app.router.navigate(this.model.url(), true) app.router.navigate(this.model.url(), true)
} }

View file

@ -5,7 +5,7 @@ app.views.Post.StreamFrame = app.views.Base.extend({
subviews : { subviews : {
".small-frame" : "smallFrameView", ".small-frame" : "smallFrameView",
'.stream-frame-feedback' : 'feedbackView' ".stream-frame-feedback" : "feedbackView"
}, },
initialize : function(options) { initialize : function(options) {
@ -15,10 +15,15 @@ app.views.Post.StreamFrame = app.views.Base.extend({
}, },
events : { events : {
'click .content' : 'triggerInteracted' 'click .content' : 'triggerInteracted',
"click a.permalink" : "goToPost"
}, },
triggerInteracted : function() { triggerInteracted : function() {
this.stream.trigger("frame:interacted", this.model) this.stream.trigger("frame:interacted", this.model)
},
goToPost : function(evt) {
this.smallFrameView.goToPost(evt)
} }
}); });

View file

@ -1,5 +1,5 @@
<div class="permalink-wrapper info"> <div class="permalink-wrapper info">
<a href="/p/{{guid}}"> <a href="/posts/{{id}}" class="permalink">
<i class="icon-zoom-in icon-white"></i> <i class="icon-zoom-in icon-white"></i>
</a> </a>
</div> </div>

View file

@ -3,12 +3,12 @@ describe("app.views.Post.StreamFrame", function(){
this.post = factory.post() this.post = factory.post()
this.stream = new Backbone.Model this.stream = new Backbone.Model
this.view = new app.views.Post.StreamFrame({model : this.post, stream: this.stream }) this.view = new app.views.Post.StreamFrame({model : this.post, stream: this.stream })
}) });
describe("rendering", function(){ describe("rendering", function(){
beforeEach(function(){ beforeEach(function(){
this.view.render() this.view.render()
}) });
context("clicking the content", function(){ context("clicking the content", function(){
it("triggers frame interacted", function(){ it("triggers frame interacted", function(){
@ -17,7 +17,21 @@ describe("app.views.Post.StreamFrame", function(){
this.view.$('.content').click() this.view.$('.content').click()
expect(spy).toHaveBeenCalledWith(this.post) 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()
})
}) })
}) })
}); });