Fixed markdown content not stored on first page save
HTML content was still saved. This changes makes the back-end check for md content instead of html to ensure that gets stored in cases where both are sent to the system. Closes #2446
This commit is contained in:
		
							parent
							
								
									14ea6c9de3
								
							
						
					
					
						commit
						20729a618f
					
				| 
						 | 
					@ -210,10 +210,10 @@ class PageRepo
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $pageContent = new PageContent($page);
 | 
					        $pageContent = new PageContent($page);
 | 
				
			||||||
        if (isset($input['html'])) {
 | 
					        if (isset($input['markdown'])) {
 | 
				
			||||||
            $pageContent->setNewHTML($input['html']);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            $pageContent->setNewMarkdown($input['markdown']);
 | 
					            $pageContent->setNewMarkdown($input['markdown']);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $pageContent->setNewHTML($input['html']);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,40 @@
 | 
				
			||||||
<?php namespace Tests\Entity;
 | 
					<?php namespace Tests\Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use BookStack\Entities\Models\Book;
 | 
				
			||||||
use BookStack\Entities\Models\Page;
 | 
					use BookStack\Entities\Models\Page;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PageTest extends TestCase
 | 
					class PageTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    public function test_page_creation_with_markdown_content()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->setSettings(['app-editor' => 'markdown']);
 | 
				
			||||||
 | 
					        $book = Book::query()->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->asEditor()->get($book->getUrl('/create-page'));
 | 
				
			||||||
 | 
					        $draft = Page::query()->where('book_id', '=', $book->id)
 | 
				
			||||||
 | 
					            ->where('draft', '=', true)->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $details = [
 | 
				
			||||||
 | 
					            'markdown' => '# a title',
 | 
				
			||||||
 | 
					            'html' => '<h1>a title</h1>',
 | 
				
			||||||
 | 
					            'name' => 'my page',
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					        $resp = $this->post($book->getUrl("/draft/{$draft->id}"), $details);
 | 
				
			||||||
 | 
					        $resp->assertRedirect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->assertDatabaseHas('pages', [
 | 
				
			||||||
 | 
					            'markdown' => $details['markdown'],
 | 
				
			||||||
 | 
					            'name' => $details['name'],
 | 
				
			||||||
 | 
					            'id' => $draft->id,
 | 
				
			||||||
 | 
					            'draft' => false
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $draft->refresh();
 | 
				
			||||||
 | 
					        $resp = $this->get($draft->getUrl("/edit"));
 | 
				
			||||||
 | 
					        $resp->assertSee("# a title");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function test_page_delete()
 | 
					    public function test_page_delete()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $page = Page::query()->first();
 | 
					        $page = Page::query()->first();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue