Merge pull request #3612 from ByteHamster/fix-feed-date-update

Fix feed date update
This commit is contained in:
H. Lehmann 2019-11-15 17:08:27 +01:00 committed by GitHub
commit 85091175a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -185,7 +185,7 @@ public class FeedItem extends FeedComponent implements ShownotesProvider, ImageR
if (other.link != null) {
link = other.link;
}
if (other.pubDate != null && other.pubDate.equals(pubDate)) {
if (other.pubDate != null && !other.pubDate.equals(pubDate)) {
pubDate = other.pubDate;
}
if (other.media != null) {

View File

@ -3,6 +3,9 @@ package de.danoeh.antennapod.core.feed;
import org.junit.Before;
import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
import static de.danoeh.antennapod.core.feed.FeedItemMother.anyFeedItemWithImage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -40,6 +43,16 @@ public class FeedItemTest {
assertFeedItemImageWasUpdated();
}
@Test
public void testUpdateFromOther_dateChanged() throws Exception {
Date originalDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1952-03-11 00:00:00");
Date changedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1952-03-11 00:42:42");
original.setPubDate(originalDate);
changedFeedItem.setPubDate(changedDate);
original.updateFromOther(changedFeedItem);
assertEquals(changedDate.getTime(), original.getPubDate().getTime());
}
/**
* Test that a played item loses that state after being marked as new.
*/