mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 21:14:41 +08:00
FIX: picture would be hidden when [details] block was closed in the composer
This commit is contained in:
@ -40,20 +40,48 @@ describe CookedPostProcessor do
|
||||
|
||||
context ".post_process_images" do
|
||||
|
||||
context "with image_sizes" do
|
||||
|
||||
let(:post) { build(:post_with_image_urls) }
|
||||
let(:cpp) { CookedPostProcessor.new(post, image_sizes: {"http://foo.bar/image.png" => {"width" => 111, "height" => 222}}) }
|
||||
|
||||
before { cpp.post_process_images }
|
||||
|
||||
it "works" do
|
||||
shared_examples "leave dimensions alone" do
|
||||
it "doesn't use them" do
|
||||
# adds the width from the image sizes provided when no dimension is provided
|
||||
expect(cpp.html).to match(/src="http:\/\/foo.bar\/image.png" width="111" height="222"/)
|
||||
expect(cpp.html).to match(/src="http:\/\/foo.bar\/image.png" width="" height=""/)
|
||||
# adds the width from the image sizes provided
|
||||
expect(cpp.html).to match(/src="http:\/\/domain.com\/picture.jpg" width="50" height="42"/)
|
||||
expect(cpp).to be_dirty
|
||||
end
|
||||
end
|
||||
|
||||
context "with image_sizes" do
|
||||
let(:post) { build(:post_with_image_urls) }
|
||||
let(:cpp) { CookedPostProcessor.new(post, image_sizes: image_sizes) }
|
||||
|
||||
before { cpp.post_process_images }
|
||||
|
||||
context "valid" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 111, "height" => 222}} }
|
||||
|
||||
it "use them" do
|
||||
# adds the width from the image sizes provided when no dimension is provided
|
||||
expect(cpp.html).to match(/src="http:\/\/foo.bar\/image.png" width="111" height="222"/)
|
||||
# adds the width from the image sizes provided
|
||||
expect(cpp.html).to match(/src="http:\/\/domain.com\/picture.jpg" width="50" height="42"/)
|
||||
expect(cpp).to be_dirty
|
||||
end
|
||||
end
|
||||
|
||||
context "invalid width" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 0, "height" => 222}} }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
context "invalid height" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 111, "height" => 0}} }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
context "invalid width & height" do
|
||||
let(:image_sizes) { {"http://foo.bar/image.png" => {"width" => 0, "height" => 0}} }
|
||||
include_examples "leave dimensions alone"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user