Skip to content

Commit

Permalink
Merge pull request #1500 from mozilla/rnewman/bug-1245976-livemarks
Browse files Browse the repository at this point in the history
Bug 1245976 - Allow livemarks to have no title. r=sleroux
  • Loading branch information
rnewman committed Feb 5, 2016
2 parents 9ddaf8a + 73ae1da commit 876a5d9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Storage/Bookmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public struct BookmarkMirrorItem {
children: children)
}

public static func livemark(guid: GUID, modified: Timestamp, hasDupe: Bool, parentID: GUID, parentName: String, title: String, description: String?, feedURI: String, siteURI: String) -> BookmarkMirrorItem {
public static func livemark(guid: GUID, modified: Timestamp, hasDupe: Bool, parentID: GUID, parentName: String?, title: String?, description: String?, feedURI: String, siteURI: String) -> BookmarkMirrorItem {
let id = BookmarkRoots.translateIncomingRootGUID(guid)
let parent = BookmarkRoots.translateIncomingRootGUID(parentID)

Expand Down
4 changes: 2 additions & 2 deletions Sync/BookmarkPayload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ extension LivemarkPayload: MirrorItemable {
hasDupe: self.hasDupe,
// TODO: these might need to be weakened if real-world data is dirty.
parentID: self["parentid"].asString!,
parentName: self["parentName"].asString!,
title: self["title"].asString!,
parentName: self["parentName"].asString,
title: self["title"].asString,
description: self["description"].asString,
feedURI: self.feedURI!,
siteURI: self.siteURI!
Expand Down
25 changes: 25 additions & 0 deletions SyncTests/RecordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,31 @@ class RecordTests: XCTestCase {
XCTAssertTrue(bookmark?.isValid() ?? false)
}

func testLivemarkMissingFields() {
let json = JSON([
"id": "M5bwUKK8hPyF",
"type": "livemark",
"siteUri": "http://www.bbc.co.uk/go/rss/int/news/-/news/",
"feedUri": "http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
"parentName": "Bookmarks Toolbar",
"parentid": "toolbar",
"children": ["3Qr13GucOtEh"]])

let bookmark = BookmarkType.payloadFromJSON(json)
XCTAssertTrue(bookmark is LivemarkPayload)

let livemark = bookmark as! LivemarkPayload
XCTAssertTrue(livemark.isValid() ?? false)
let siteURI = "http://www.bbc.co.uk/go/rss/int/news/-/news/"
let feedURI = "http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml"
XCTAssertEqual(feedURI, livemark.feedURI)
XCTAssertEqual(siteURI, livemark.siteURI)

let m = (livemark as MirrorItemable).toMirrorItem(NSDate.now())
XCTAssertEqual("http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml", m.feedURI)
XCTAssertEqual("http://www.bbc.co.uk/go/rss/int/news/-/news/", m.siteURI)
}

func testLivemark() {
let json = JSON([
"id": "M5bwUKK8hPyF",
Expand Down

0 comments on commit 876a5d9

Please sign in to comment.