mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	 36b6c0cb9c
			
		
	
	36b6c0cb9c
	
	
	
		
			
			- This PR adds BaseMarkdownRenderer, it takes all the required attributes from the image node, parses the cw_image_height query and renders it.
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| require 'rails_helper'
 | |
| 
 | |
| describe BaseMarkdownRenderer do
 | |
|   let(:renderer) { described_class.new }
 | |
| 
 | |
|   def render_markdown(markdown)
 | |
|     doc = CommonMarker.render_doc(markdown, :DEFAULT)
 | |
|     renderer.render(doc)
 | |
|   end
 | |
| 
 | |
|   describe '#image' do
 | |
|     context 'when image has a height' do
 | |
|       it 'renders the img tag with the correct attributes' do
 | |
|         markdown = ''
 | |
|         expect(render_markdown(markdown)).to include('<img src="https://example.com/image.jpg?cw_image_height=100" height="100" width="auto" />')
 | |
|       end
 | |
|     end
 | |
| 
 | |
|     context 'when image does not have a height' do
 | |
|       it 'renders the img tag without the height attribute' do
 | |
|         markdown = ''
 | |
|         expect(render_markdown(markdown)).to include('<img src="https://example.com/image.jpg" />')
 | |
|       end
 | |
|     end
 | |
| 
 | |
|     context 'when image has an invalid URL' do
 | |
|       it 'renders the img tag without crashing' do
 | |
|         markdown = ''
 | |
|         expect { render_markdown(markdown) }.not_to raise_error
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |