mirror of https://github.com/kiwix/libkiwix.git
Both Book::update() methods update the category
This commit is contained in:
parent
a870e05621
commit
b7b0bdbdd8
|
@ -61,6 +61,7 @@ bool Book::update(const kiwix::Book& other)
|
|||
m_name = other.m_name;
|
||||
m_flavour = other.m_flavour;
|
||||
m_tags = other.m_tags;
|
||||
m_category = other.m_category;
|
||||
m_origId = other.m_origId;
|
||||
m_articleCount = other.m_articleCount;
|
||||
m_mediaCount = other.m_mediaCount;
|
||||
|
@ -88,6 +89,7 @@ void Book::update(const kiwix::Reader& reader)
|
|||
m_name = reader.getName();
|
||||
m_flavour = reader.getFlavour();
|
||||
m_tags = reader.getTags();
|
||||
m_category = getCategoryFromTags();
|
||||
m_origId = reader.getOrigId();
|
||||
m_articleCount = reader.getArticleCount();
|
||||
m_mediaCount = reader.getMediaCount();
|
||||
|
|
|
@ -144,3 +144,25 @@ TEST(BookTest, updateFromXMLCategoryHandlingTest)
|
|||
EXPECT_EQ(book.getCategory(), "category_attribute_overrides_tags");
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BookTest, setTagsDoesntAffectCategory)
|
||||
{
|
||||
kiwix::Book book;
|
||||
|
||||
book.setTags("_category:youtube");
|
||||
ASSERT_EQ("", book.getCategory());
|
||||
}
|
||||
|
||||
TEST(BookTest, updateCopiesCategory)
|
||||
{
|
||||
const XMLDoc xml(R"(<book id="abcd" category="ted"></book>)");
|
||||
|
||||
kiwix::Book book;
|
||||
book.updateFromXml(xml.child("book"), "");
|
||||
|
||||
kiwix::Book newBook;
|
||||
newBook.setId("abcd");
|
||||
EXPECT_EQ(newBook.getCategory(), "");
|
||||
newBook.update(book);
|
||||
EXPECT_EQ(newBook.getCategory(), "ted");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue