{"action":"created","comment":{"url":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments/56315552","id":56315552,"diff_hunk":"@@ -0,0 +1,113 @@\n+package controllers.rest\n+\n+import EventApi.EventsResponse\n+import model.Eventbrite.{EBAddress, EBEvent, EBRichText, EBVenue}\n+import model.Grid\n+import model.Grid.{Dimensions, Asset}\n+import model.RichEvent.{GridImage, GuLiveEvent}\n+import org.joda.time.DateTimeUtils._\n+import org.joda.time.DateTimeZone.UTC\n+import org.joda.time.format.ISODateTimeFormat.dateTimeNoMillis\n+import org.joda.time.{DateTime, Instant}\n+import org.specs2.execute.{Result, AsResult}\n+import org.specs2.matcher.JsonMatchers\n+import org.specs2.mutable.Specification\n+import org.specs2.specification.AroundEach\n+import play.api.libs.json.Json\n+\n+class EventsResponseTest extends Specification with JsonMatchers with EventFixtures with DateTimeFixed {\n+  \"Event response JSON created from RichEvent\" should {\n+    \"have event id\" in {\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(defaultLiveEvent)))\n+\n+      asJsonString(response) must /(\"events\") /# 0 / (\"id\" -> defaultLiveEvent.id)\n+    }\n+\n+    \"have url\" in {\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(defaultLiveEvent)))\n+\n+      asJsonString(response) must /(\"events\") /# 0 / (\"url\" -> contain(\"/event/\"))\n+    }\n+\n+    \"have title\" in {\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(defaultLiveEvent)))\n+\n+      asJsonString(response) must /(\"events\") /# 0 / (\"title\" -> defaultLiveEvent.name.text)\n+    }\n+\n+    \"have start and dates in utc with timezone\" in {\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(defaultLiveEvent)))\n+\n+      val expectedStartTime = defaultLiveEvent.start\n+        .toDateTime(UTC)\n+        .toString(dateTimeNoMillis())\n+\n+      asJsonString(response) must /(\"events\") /# 0 / \"start\" / (\"time\" -> expectedStartTime)\n+    }\n+\n+    \"have venue\" in {\n+      val venue = EBVenue(\n+        address = Some(EBAddress(\n+          city = Some(\"London\"),\n+          postal_code = Some(\"N1 6GU\"),\n+          country = Some(\"GB\"),\n+          region = None, address_1 = None, address_2 = None)\n+        ),\n+        name = Some(\"Kings Cross\")\n+      )\n+\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(liveEvent(venue))))\n+\n+      asJsonString(response) must /(\"events\") /# 0 / \"venue\" / \"address\" / (\"city\" -> \"London\")\n+      asJsonString(response) must /(\"events\") /# 0 / \"venue\" / \"address\" / (\"postCode\" -> \"N1 6GU\")\n+      asJsonString(response) must /(\"events\") /# 0 / \"venue\" / \"address\" / (\"country\" -> \"GB\")\n+    }\n+\n+    \"have masterImageUrl\" in {\n+      val response = EventsResponse(events = Seq(Event.forRichEvent(defaultLiveEvent)))\n+\n+      asJsonString(response) must /(\"events\") /# 0 / (\"mainImageUrl\" -> \"https://media.guim.co.uk/b7c830bff5104b9ce9951928238fb09004d50335/0_0_1280_768/master/1280.jpg\")\n+    }\n+  }\n+\n+  def asJsonString(response: EventsResponse): String = Json.stringify(Json.toJson(response))\n+}\n+\n+trait DateTimeFixed extends AroundEach {","path":"frontend/test/controllers/rest/EventsResponseTest.scala","position":76,"original_position":76,"commit_id":"e44a812d2ef6298ba523de48680604841ddb693d","original_commit_id":"e44a812d2ef6298ba523de48680604841ddb693d","user":{"login":"rtyley","id":52038,"avatar_url":"https://avatars.githubusercontent.com/u/52038?v=3","gravatar_id":"","url":"https://api.github.com/users/rtyley","html_url":"https://github.com/rtyley","followers_url":"https://api.github.com/users/rtyley/followers","following_url":"https://api.github.com/users/rtyley/following{/other_user}","gists_url":"https://api.github.com/users/rtyley/gists{/gist_id}","starred_url":"https://api.github.com/users/rtyley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtyley/subscriptions","organizations_url":"https://api.github.com/users/rtyley/orgs","repos_url":"https://api.github.com/users/rtyley/repos","events_url":"https://api.github.com/users/rtyley/events{/privacy}","received_events_url":"https://api.github.com/users/rtyley/received_events","type":"User","site_admin":false},"body":"Could you clarify why is this trait necessary? I can't see anything in the JSON of https://mem.thegulocal.com/events.json which looks like it should depend on the invocation time?","created_at":"2016-03-16T11:05:00Z","updated_at":"2016-03-16T11:05:00Z","html_url":"https://github.com/guardian/membership-frontend/pull/1035#discussion_r56315552","pull_request_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035","_links":{"self":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments/56315552"},"html":{"href":"https://github.com/guardian/membership-frontend/pull/1035#discussion_r56315552"},"pull_request":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035"}}},"pull_request":{"url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035","id":62380213,"html_url":"https://github.com/guardian/membership-frontend/pull/1035","diff_url":"https://github.com/guardian/membership-frontend/pull/1035.diff","patch_url":"https://github.com/guardian/membership-frontend/pull/1035.patch","issue_url":"https://api.github.com/repos/guardian/membership-frontend/issues/1035","number":1035,"state":"open","locked":false,"title":"[MMF-37] More data about event ","user":{"login":"agulowaty","id":8526142,"avatar_url":"https://avatars.githubusercontent.com/u/8526142?v=3","gravatar_id":"","url":"https://api.github.com/users/agulowaty","html_url":"https://github.com/agulowaty","followers_url":"https://api.github.com/users/agulowaty/followers","following_url":"https://api.github.com/users/agulowaty/following{/other_user}","gists_url":"https://api.github.com/users/agulowaty/gists{/gist_id}","starred_url":"https://api.github.com/users/agulowaty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agulowaty/subscriptions","organizations_url":"https://api.github.com/users/agulowaty/orgs","repos_url":"https://api.github.com/users/agulowaty/repos","events_url":"https://api.github.com/users/agulowaty/events{/privacy}","received_events_url":"https://api.github.com/users/agulowaty/received_events","type":"User","site_admin":false},"body":"Mobile apps need to have more data about live events. \r\nI moved REST-specific controllers to separate package so that it does not collide with namespace introduced by old controllers.\r\n\r\nUrl returned in mainImageUrl is selected from assets provided by Media API. Firstly master image is being probed, then we're falling back to best (in terms of resolution) asset.\r\n\r\nNew test-scoped dependency added for specs2 JsonMatchers.\r\n\r\nI did small refactoring of `GridService`, but it still needs some refactoring towards usage of new Media API endpoint already introduced in https://github.com/guardian/grid/pull/1794.\r\n\r\ncc @rtyley, @JonNorman, @regiskuckaertz\r\n\r\nShape of JSON:\r\n\r\n```\r\n{\r\n    \"events\": [\r\n    {\r\n        \"id\": \"21081001844\",\r\n            \"url\": \"https://mem.thegulocal.com/event/guardian-live-how-can-we-get-more-people-cycling-in-london-chris-boardman-andrew-gilligan-and-guests-discuss-21081001844\",\r\n            \"mainImageUrl\": \"https://media.guim.co.uk/4c3a44853ff4e41c81d7ba15760657caf8219757/0_0_1920_1152/master/1920.jpg\",\r\n            \"start\": {\r\n                \"time\": \"2016-03-10T19:00:00Z\",\r\n                \"zone\": \"Europe/London\"\r\n            },\r\n            \"end\": {\r\n                \"time\": \"2016-03-10T20:30:00Z\",\r\n                \"zone\": \"Europe/London\"\r\n            },\r\n            \"venue\": {\r\n                \"name\": \"The Guardian\",\r\n                \"address\": {\r\n                    \"city\": \"London\",\r\n                    \"postCode\": \"N1 9GU\",\r\n                    \"country\": \"GB\"\r\n                }\r\n            },\r\n            \"title\": \"Guardian Live | How can we get more people cycling in London? Chris Boardman, Andrew Gilligan and guests discuss\"\r\n    },\r\n   ...\r\n```","created_at":"2016-03-10T12:09:29Z","updated_at":"2016-03-16T11:05:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ed4b109b045b2ce52f3835f59d83d5d1841f0c09","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035/commits","review_comments_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035/comments","review_comment_url":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/issues/1035/comments","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/e44a812d2ef6298ba523de48680604841ddb693d","head":{"label":"guardian:events-json-more-data","ref":"events-json-more-data","sha":"e44a812d2ef6298ba523de48680604841ddb693d","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":28401521,"name":"membership-frontend","full_name":"guardian/membership-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/membership-frontend","description":"Bringing the Guardian to life through live events and meet-ups","fork":false,"url":"https://api.github.com/repos/guardian/membership-frontend","forks_url":"https://api.github.com/repos/guardian/membership-frontend/forks","keys_url":"https://api.github.com/repos/guardian/membership-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/membership-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/membership-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/membership-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/membership-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/membership-frontend/events","assignees_url":"https://api.github.com/repos/guardian/membership-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/membership-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/membership-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/membership-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/membership-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/membership-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/membership-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/membership-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/membership-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/membership-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/membership-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/membership-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/membership-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/membership-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/membership-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/membership-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/membership-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/membership-frontend/merges","archive_url":"https://api.github.com/repos/guardian/membership-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/membership-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/membership-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/membership-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/membership-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/membership-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/membership-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/membership-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/membership-frontend/deployments","created_at":"2014-12-23T14:14:38Z","updated_at":"2016-02-23T04:52:08Z","pushed_at":"2016-03-15T09:42:15Z","git_url":"git://github.com/guardian/membership-frontend.git","ssh_url":"git@github.com:guardian/membership-frontend.git","clone_url":"https://github.com/guardian/membership-frontend.git","svn_url":"https://github.com/guardian/membership-frontend","homepage":"https://membership.theguardian.com/","size":48424,"stargazers_count":22,"watchers_count":22,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":22,"default_branch":"master"}},"base":{"label":"guardian:master","ref":"master","sha":"4c13e0a2f7b43d6a5c6f1530d8ef8c80f0474090","user":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"repo":{"id":28401521,"name":"membership-frontend","full_name":"guardian/membership-frontend","owner":{"login":"guardian","id":164318,"avatar_url":"https://avatars.githubusercontent.com/u/164318?v=3","gravatar_id":"","url":"https://api.github.com/users/guardian","html_url":"https://github.com/guardian","followers_url":"https://api.github.com/users/guardian/followers","following_url":"https://api.github.com/users/guardian/following{/other_user}","gists_url":"https://api.github.com/users/guardian/gists{/gist_id}","starred_url":"https://api.github.com/users/guardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guardian/subscriptions","organizations_url":"https://api.github.com/users/guardian/orgs","repos_url":"https://api.github.com/users/guardian/repos","events_url":"https://api.github.com/users/guardian/events{/privacy}","received_events_url":"https://api.github.com/users/guardian/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/guardian/membership-frontend","description":"Bringing the Guardian to life through live events and meet-ups","fork":false,"url":"https://api.github.com/repos/guardian/membership-frontend","forks_url":"https://api.github.com/repos/guardian/membership-frontend/forks","keys_url":"https://api.github.com/repos/guardian/membership-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/guardian/membership-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/guardian/membership-frontend/teams","hooks_url":"https://api.github.com/repos/guardian/membership-frontend/hooks","issue_events_url":"https://api.github.com/repos/guardian/membership-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/guardian/membership-frontend/events","assignees_url":"https://api.github.com/repos/guardian/membership-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/guardian/membership-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/guardian/membership-frontend/tags","blobs_url":"https://api.github.com/repos/guardian/membership-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/guardian/membership-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/guardian/membership-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/guardian/membership-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/guardian/membership-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/guardian/membership-frontend/languages","stargazers_url":"https://api.github.com/repos/guardian/membership-frontend/stargazers","contributors_url":"https://api.github.com/repos/guardian/membership-frontend/contributors","subscribers_url":"https://api.github.com/repos/guardian/membership-frontend/subscribers","subscription_url":"https://api.github.com/repos/guardian/membership-frontend/subscription","commits_url":"https://api.github.com/repos/guardian/membership-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/guardian/membership-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/guardian/membership-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/guardian/membership-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/guardian/membership-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/guardian/membership-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/guardian/membership-frontend/merges","archive_url":"https://api.github.com/repos/guardian/membership-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/guardian/membership-frontend/downloads","issues_url":"https://api.github.com/repos/guardian/membership-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/guardian/membership-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/guardian/membership-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/guardian/membership-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/guardian/membership-frontend/labels{/name}","releases_url":"https://api.github.com/repos/guardian/membership-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/guardian/membership-frontend/deployments","created_at":"2014-12-23T14:14:38Z","updated_at":"2016-02-23T04:52:08Z","pushed_at":"2016-03-15T09:42:15Z","git_url":"git://github.com/guardian/membership-frontend.git","ssh_url":"git@github.com:guardian/membership-frontend.git","clone_url":"https://github.com/guardian/membership-frontend.git","svn_url":"https://github.com/guardian/membership-frontend","homepage":"https://membership.theguardian.com/","size":48424,"stargazers_count":22,"watchers_count":22,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":3,"forks":12,"open_issues":3,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035"},"html":{"href":"https://github.com/guardian/membership-frontend/pull/1035"},"issue":{"href":"https://api.github.com/repos/guardian/membership-frontend/issues/1035"},"comments":{"href":"https://api.github.com/repos/guardian/membership-frontend/issues/1035/comments"},"review_comments":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035/comments"},"review_comment":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/guardian/membership-frontend/pulls/1035/commits"},"statuses":{"href":"https://api.github.com/repos/guardian/membership-frontend/statuses/e44a812d2ef6298ba523de48680604841ddb693d"}}}}