From b862ad8c733ac59ee89180c677887ae0ce2cc7d2 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Mon, 20 Nov 2017 12:41:14 +0100 Subject: [PATCH] Add test for rebasing over multiple revisions --- src/state.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/state.rs b/src/state.rs index 111829e..725bc8b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -499,4 +499,22 @@ mod test { assert_eq!("a\nx\nb\ny\nc\n", second_edit.body); } + + #[test] + fn update_article_when_edit_conflict_then_rebase_over_multiple_revisions() { + init!(state); + + let article = state.create_article(None, "Title".into(), "a\nb\nc\n".into(), None).unwrap(); + + let edit = state.update_article(article.article_id, article.revision, article.title.clone(), "a\nx1\nb\nc\n".into(), None).unwrap(); + let edit = state.update_article(article.article_id, edit.revision, article.title.clone(), "a\nx1\nx2\nb\nc\n".into(), None).unwrap(); + let edit = state.update_article(article.article_id, edit.revision, article.title.clone(), "a\nx1\nx2\nx3\nb\nc\n".into(), None).unwrap(); + + let rebase_edit = state.update_article(article.article_id, article.revision, article.title.clone(), "a\nb\ny\nc\n".into(), None).unwrap(); + + assert!(article.revision < edit.revision); + assert!(edit.revision < rebase_edit.revision); + + assert_eq!("a\nx1\nx2\nx3\nb\ny\nc\n", rebase_edit.body); + } }