From 3f0bcc8a10e56607796abdae1dc87325d0d33956 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Wed, 19 Sep 2012 12:52:33 +0200 Subject: [PATCH 1/2] rack expects an array instead of a string, fixes #3499 --- lib/rack/chrome_frame.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rack/chrome_frame.rb b/lib/rack/chrome_frame.rb index 1875bcb1f..81f438d6d 100644 --- a/lib/rack/chrome_frame.rb +++ b/lib/rack/chrome_frame.rb @@ -17,7 +17,7 @@ module Rack status, headers, response = @app.call(env) new_body = insert_tag(build_response_body(response)) new_headers = recalculate_body_length(headers, new_body) - return [status, new_headers, new_body] + return [status, new_headers, [new_body]] elsif @options[:minimum].nil? or ie_version(env['HTTP_USER_AGENT']) < @options[:minimum] html = <<-HTML @@ -42,6 +42,10 @@ module Rack def build_response_body(response) response_body = "" response.each { |part| response_body += part } + + # see: http://johnbintz.github.com/blog/2012/03/05/closing-given-body-in-rack-middleware/ + response.close if response.respond_to?(:close) + response_body end From bf82fc17fe137563cdfe2a1d9e8d63244997e73c Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Wed, 3 Oct 2012 19:05:17 +0200 Subject: [PATCH 2/2] fix oembed onclick behavior + specs --- .../javascripts/app/views/content_view.js | 2 +- .../javascripts/app/views/oembed_view_spec.js | 49 ++++++++++++++----- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index 9017f0508..f8dc39388 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -78,7 +78,7 @@ app.views.ActivityStreams__Photo = app.views.Content.extend({ app.views.OEmbed = app.views.Base.extend({ templateName : "oembed", events : { - "click .oembed .thumb": "showOembedContent" + "click .thumb": "showOembedContent" }, presenter:function () { diff --git a/spec/javascripts/app/views/oembed_view_spec.js b/spec/javascripts/app/views/oembed_view_spec.js index 047433fce..6b635910b 100644 --- a/spec/javascripts/app/views/oembed_view_spec.js +++ b/spec/javascripts/app/views/oembed_view_spec.js @@ -3,29 +3,54 @@ describe("app.views.OEmbed", function(){ this.statusMessage = factory.statusMessage({ "o_embed_cache":{ "data":{ - "html":"some html" + "html":"some html", + "thumbnail_url": "//example.com/thumb.jpg" } } - }) + }); this.view = new app.views.OEmbed({model : this.statusMessage}) - }) + }); describe("rendering", function(){ - it("provides oembed html from the model response", function(){ - this.view.render() - expect(this.view.$el.html()).toContain("some html") - }) - }) + context("with thumb", function() { + it("shows the thumb with overlay", function(){ + this.view.render(); + + expect(this.view.$el.html()).toContain("example.com/thumb"); + expect(this.view.$el.html()).toContain("video-overlay"); + }); + + it("shows the oembed html when clicking the thumb", function() { + this.view.render(); + this.view.$('.thumb').click(); + + _.defer(function() { + expect(this.view.$el.html()).toContain("some html"); + }); + }); + }); + + context("no thumb", function() { + beforeEach(function(){ + this.statusMessage.set({"o_embed_cache" : {"data": {"html": "some html"}}}); + }); + + it("provides oembed html from the model response", function(){ + this.view.render() + expect(this.view.$el.html()).toContain("some html") + }); + }); + }); describe("presenter", function(){ it("provides oembed html from the model", function(){ expect(this.view.presenter().o_embed_html).toContain("some html") - }) + }); it("does not provide oembed html from the model response if none is present", function(){ this.statusMessage.set({"o_embed_cache" : null}) expect(this.view.presenter().o_embed_html).toBe(""); - }) - }) -}) \ No newline at end of file + }); + }); +}); \ No newline at end of file