From 361062d53eedd9edbffbe3c12ab91ffa3f639a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 24 Jun 2013 02:10:21 +0200 Subject: [PATCH] do not lightbox oneboxed images --- lib/cooked_post_processor.rb | 2 +- spec/components/cooked_post_processor_spec.rb | 15 +++++++++++++++ spec/fabricators/post_fabricator.rb | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index ab9c8c3fc..f8bceebad 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -22,7 +22,7 @@ class CookedPostProcessor end def post_process_images - images = @doc.search("img") + images = @doc.css("img") - @doc.css(".onebox-result img") return unless images.present? images.each do |img| diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index 6ace798c3..6ba31a6ea 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -111,6 +111,21 @@ describe CookedPostProcessor do end end + context 'with a oneboxed image' do + let(:user) { Fabricate(:user) } + let(:topic) { Fabricate(:topic, user: user) } + let(:post) { Fabricate.build(:post_with_oneboxed_image, topic: topic, user: user) } + let(:processor) { CookedPostProcessor.new(post) } + + before do + processor.post_process_images + end + + it "doesn't lightbox" do + processor.html.should_not =~ /class="lightbox"/ + end + end + end context 'link convertor' do diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb index 132a942c5..28bdfa49c 100644 --- a/spec/fabricators/post_fabricator.rb +++ b/spec/fabricators/post_fabricator.rb @@ -46,6 +46,14 @@ Fabricator(:post_with_uploads, from: :post) do " end +Fabricator(:post_with_oneboxed_image, from: :post) do + cooked " +
+ +
+ " +end + Fabricator(:basic_reply, from: :post) do user(:coding_horror)