{"action":"created","issue":{"url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/6","repository_url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api","labels_url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/6/comments","events_url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/6/events","html_url":"https://github.com/learn-co-curriculum/js-tictactoe-rails-api/issues/6","id":138334764,"number":6,"title":"Listing old games (works in browser)","user":{"login":"onyoo","id":14326883,"avatar_url":"https://avatars.githubusercontent.com/u/14326883?v=3","gravatar_id":"","url":"https://api.github.com/users/onyoo","html_url":"https://github.com/onyoo","followers_url":"https://api.github.com/users/onyoo/followers","following_url":"https://api.github.com/users/onyoo/following{/other_user}","gists_url":"https://api.github.com/users/onyoo/gists{/gist_id}","starred_url":"https://api.github.com/users/onyoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onyoo/subscriptions","organizations_url":"https://api.github.com/users/onyoo/orgs","repos_url":"https://api.github.com/users/onyoo/repos","events_url":"https://api.github.com/users/onyoo/events{/privacy}","received_events_url":"https://api.github.com/users/onyoo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-04T00:02:26Z","updated_at":"2016-03-04T00:06:00Z","closed_at":null,"body":"Ok, this all started with the following error. I pushed a commit at the spot where I encountered the issue. It should be the first commit (called `errors on list prev games`): https://github.com/onyoo/js-tictactoe-rails-api-v-000\r\n\r\n```\r\n#integration tests of persistence if i click the previous game button and a game has already been saved it should add the previous game to the DOM\r\nExpected 0 to be 1.\r\nError: Expected 0 to be 1.\r\n    at stack (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1293:17)\r\n    at buildExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1270:14)\r\n    at Spec.Env.expectationResultFactory (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:484:18)\r\n    at Spec.addExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:260:46)\r\n    at Expectation.addExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:442:21)\r\n    at Expectation.toBe (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1209:12)\r\n    at file:///Users/Roberto/Development/code/js-tictactoe-rails-api-v-000/spec/tictactoe.spec.js:323:45\r\n    at MockAjax.withMock (file:///Users/Roberto/Development/code/js-tictactoe-rails-api-v-000/spec/lib/mock-ajax.js:499:17)\r\n    at Object.<anonymous> (file:///Users/Roberto/Development/code/js-tictactoe-rails-api-v-000/spec/tictactoe.spec.js:308:18)\r\n    at attemptSync (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1510:12)\r\n```\r\n\r\nThe problem is that when I play and save games in the browser, I can list them with no problem:\r\n<img width=\"184\" alt=\"screen shot 2016-03-04 at 12 16 59 am\" src=\"https://cloud.githubusercontent.com/assets/14326883/13513508/a48bf90c-e1a1-11e5-84ca-7c3ba1c5a760.png\">\r\n\r\nAfter a bit of poking around, I put a debugger in the test and found that the request for a game was coming back correctly (debugger put at line tictactoe.spec.js:322):\r\n```\r\nresponse\r\nObject {status: 200, contentType: \"application/json\", responseText: \"{\"games\":[{\"id\":1,\"state\":[\"X\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]}]}\"}\r\n```\r\nThey are simply not loading correctly. At that same debugger break-point, the dom is visibly missing an empty space for the list div. I checked to see the setFixtures() parameters in the test, and they were indeed missing the ul.\r\n\r\nFix:\r\nAdd `<ul id=\"list\"></ul>` to the `#games` div, or just replace line 305 with:\r\n```\r\n    setFixtures('<body><table border=\"1\" cellpadding=\"40\"><tr><td data-x=\"0\", data-y=\"0\">X</td><td data-x=\"1\", data-y=\"0\"></td><td data-x=\"2\", data-y=\"0\"></td></tr><tr><td data-x=\"0\", data-y=\"1\">O</td><td data-x=\"1\", data-y=\"1\"></td><td data-x=\"2\", data-y=\"1\"></td></tr><tr><td data-x=\"0\", data-y=\"2\"></td><td data-x=\"1\", data-y=\"2\"></td><td data-x=\"2\", data-y=\"2\"></td></tr></table><div id=\"games\"><ul id=\"list\"></ul></div><div id=\"message\"></div><button id=\"save\">Save Game</button><button id=\"previous\">Show Previous Games</button></body>');\r\n\r\n```\r\n\r\nBut now that the div has a permanent child, we just created a new problem with line 307:\r\n```\r\n#integration tests of persistence if i click the previous game button and a game has already been saved it should add the previous game to the DOM\r\nExpected 1 to be 0.\r\nError: Expected 1 to be 0.\r\n    at stack (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1293:17)\r\n    at buildExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1270:14)\r\n    at Spec.Env.expectationResultFactory (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:484:18)\r\n    at Spec.addExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:260:46)\r\n    at Expectation.addExpectationResult (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:442:21)\r\n    at Expectation.toBe (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1209:12)\r\n    at Object.<anonymous> (file:///Users/Roberto/Development/code/js-tictactoe-rails-api-v-000/spec/tictactoe.spec.js:307:43)\r\n    at attemptSync (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1510:12)\r\n    at QueueRunner.run (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1498:9)\r\n    at QueueRunner.execute (file:///Users/Roberto/.rvm/gems/ruby-2.2.3/gems/learn-test-1.2.26/lib/learn_test/jasmine/jasmine.js:1485:10)\r\n```\r\nFix:\r\nChange line 307: `expect($(\"#games\").children().length).toBe(0);` to `expect($(\"ul#list\").children().length).toBe(0);`\r\n\r\nChange line 322: `expect($(\"#games\").children().length).toBe(1);` to `expect($(\"ul#list\").children().length).toBe(1);`\r\n\r\nThat is, assuming the ul originally has an id = list. I can't remember if I added that attribute."},"comment":{"url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/comments/192029131","html_url":"https://github.com/learn-co-curriculum/js-tictactoe-rails-api/issues/6#issuecomment-192029131","issue_url":"https://api.github.com/repos/learn-co-curriculum/js-tictactoe-rails-api/issues/6","id":192029131,"user":{"login":"onyoo","id":14326883,"avatar_url":"https://avatars.githubusercontent.com/u/14326883?v=3","gravatar_id":"","url":"https://api.github.com/users/onyoo","html_url":"https://github.com/onyoo","followers_url":"https://api.github.com/users/onyoo/followers","following_url":"https://api.github.com/users/onyoo/following{/other_user}","gists_url":"https://api.github.com/users/onyoo/gists{/gist_id}","starred_url":"https://api.github.com/users/onyoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onyoo/subscriptions","organizations_url":"https://api.github.com/users/onyoo/orgs","repos_url":"https://api.github.com/users/onyoo/repos","events_url":"https://api.github.com/users/onyoo/events{/privacy}","received_events_url":"https://api.github.com/users/onyoo/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T00:06:00Z","updated_at":"2016-03-04T00:06:00Z","body":"Same issue line 329, 344, 364, 371,  and 391."}}