{"action":"created","comment":{"url":"https://api.github.com/repos/kelvinr/myflix/pulls/comments/28632001","id":28632001,"diff_hunk":"@@ -0,0 +1,106 @@\n+require 'spec_helper'\n+\n+describe QueueItemsController do\n+  let(:jake) { Fabricate(:user) }\n+\n+  describe \"GET index\" do\n+    it \"sets @queue_items\" do\n+      session[:user_id] = jake.id\n+      queue_item1 = Fabricate(:queue_item, user: jake)\n+      queue_item2 = Fabricate(:queue_item, user: jake)\n+      get :index\n+      expect(assigns(:queue_items)).to eq([queue_item1, queue_item2])\n+    end\n+\n+    it \"redirects to signed in page for unauthenticated users\" do\n+      get :index\n+      expect(response).to redirect_to :login\n+    end\n+  end\n+\n+  describe \"POST create\" do\n+    it \"redirects to my queue page\" do\n+      session[:user_id] = jake.id\n+      video = Fabricate(:video)\n+      post :create, video_id: video.id\n+      expect(response).to redirect_to my_queue_path\n+    end\n+\n+    it \"creates a queue item\" do\n+      session[:user_id] = Fabricate(:user).id\n+      video = Fabricate(:video)\n+      post :create, video_id: video.id\n+      expect(QueueItem.count).to eq(1)\n+    end\n+\n+    it \"queue item is associated with the video\" do\n+      session[:user_id] = Fabricate(:user).id\n+      video = Fabricate(:video)\n+      post :create, video_id: video.id\n+      expect(QueueItem.first.video).to eq(video)\n+    end\n+\n+    it \"creates a queue item associated with the signed in user\" do\n+      session[:user_id] = jake.id\n+      video = Fabricate(:video)\n+      post :create, video_id: video.id\n+      expect(QueueItem.first.user).to eq(jake)\n+    end\n+\n+    it \"puts the video as the last one in the queue\" do\n+      session[:user_id] = jake.id\n+      monk = Fabricate(:video)\n+      Fabricate.create(:queue_item, video: monk, user: jake)\n+      futurama = Fabricate(:video)\n+      post :create, video_id: futurama.id\n+      futurama_queue_item = QueueItem.where(video_id: futurama.id, user_id: jake.id).first\n+      expect(futurama_queue_item.position).to eq(2)\n+    end\n+\n+    it \"does not add the video to the queue if the video is already present\" do\n+      session[:user_id] =  jake.id\n+      monk = Fabricate(:video)\n+      Fabricate(:queue_item, video: monk, user: jake)\n+      post :create, video_id: monk.id\n+      expect(jake.queue_items.count).to eq(1)\n+    end\n+\n+    it \"redirects to the login page for unauthenticated users\" do\n+      post :create, video_id: 3\n+      expect(response).to redirect_to :login\n+    end\n+  end\n+\n+  describe \"DELETE destroy\" do\n+    it \"it redirects to queue page\" do\n+      session[:user_id] = Fabricate(:user).id\n+      delete :destroy, id: Fabricate(:queue_item).id\n+      expect(response).to redirect_to :my_queue\n+    end\n+\n+    it \"it deletes the queue item\" do\n+      session[:user_id] = Fabricate(:user).id\n+      delete :destroy, id: Fabricate(:queue_item).id\n+      expect(QueueItem.count).to eq(0)\n+    end\n+\n+    it \"removes queue item from users queue\" do\n+      session[:user_id] = jake.id\n+      delete :destroy, id: Fabricate(:queue_item, user: jake).id\n+      expect(jake.queue_items).to eq([])\n+    end\n+\n+    it \"adjusts the position of the queue items\" do\n+      session[:user_id] = jake.id\n+      queue_item1 = Fabricate(:queue_item, user: jake, position: 1)\n+      queue_item2 = Fabricate(:queue_item, user: jake, position: 2)\n+      delete :destroy, id: queue_item1.id\n+      expect(jake.queue_items.first.position).to eq(1)","path":"spec/controllers/queue_items_controller_spec.rb","position":98,"original_position":98,"commit_id":"d472ff814d9b64e478d7e031dd15198fd0c2dcc4","original_commit_id":"d472ff814d9b64e478d7e031dd15198fd0c2dcc4","user":{"login":"tomtomecek","id":7385469,"avatar_url":"https://avatars.githubusercontent.com/u/7385469?v=3","gravatar_id":"","url":"https://api.github.com/users/tomtomecek","html_url":"https://github.com/tomtomecek","followers_url":"https://api.github.com/users/tomtomecek/followers","following_url":"https://api.github.com/users/tomtomecek/following{/other_user}","gists_url":"https://api.github.com/users/tomtomecek/gists{/gist_id}","starred_url":"https://api.github.com/users/tomtomecek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomtomecek/subscriptions","organizations_url":"https://api.github.com/users/tomtomecek/orgs","repos_url":"https://api.github.com/users/tomtomecek/repos","events_url":"https://api.github.com/users/tomtomecek/events{/privacy}","received_events_url":"https://api.github.com/users/tomtomecek/received_events","type":"User","site_admin":false},"body":"Hm, this does not prove that the position was changed if the item was deleted. Because if the first item was not deleted then this test is still going to pass. Instead I would assert on queue_item2 directly that the position is 1.","created_at":"2015-04-17T21:33:48Z","updated_at":"2015-04-17T21:33:48Z","html_url":"https://github.com/kelvinr/myflix/pull/2#discussion_r28632001","pull_request_url":"https://api.github.com/repos/kelvinr/myflix/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/comments/28632001"},"html":{"href":"https://github.com/kelvinr/myflix/pull/2#discussion_r28632001"},"pull_request":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/kelvinr/myflix/pulls/2","id":33579086,"html_url":"https://github.com/kelvinr/myflix/pull/2","diff_url":"https://github.com/kelvinr/myflix/pull/2.diff","patch_url":"https://github.com/kelvinr/myflix/pull/2.patch","issue_url":"https://api.github.com/repos/kelvinr/myflix/issues/2","number":2,"state":"open","locked":false,"title":"Video queue and tests","user":{"login":"kelvinr","id":5810191,"avatar_url":"https://avatars.githubusercontent.com/u/5810191?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinr","html_url":"https://github.com/kelvinr","followers_url":"https://api.github.com/users/kelvinr/followers","following_url":"https://api.github.com/users/kelvinr/following{/other_user}","gists_url":"https://api.github.com/users/kelvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinr/subscriptions","organizations_url":"https://api.github.com/users/kelvinr/orgs","repos_url":"https://api.github.com/users/kelvinr/repos","events_url":"https://api.github.com/users/kelvinr/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinr/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-17T20:25:14Z","updated_at":"2015-04-17T21:33:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd84f90489e375e68a637c708c0ec72435253be9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kelvinr/myflix/pulls/2/commits","review_comments_url":"https://api.github.com/repos/kelvinr/myflix/pulls/2/comments","review_comment_url":"https://api.github.com/repos/kelvinr/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kelvinr/myflix/issues/2/comments","statuses_url":"https://api.github.com/repos/kelvinr/myflix/statuses/d472ff814d9b64e478d7e031dd15198fd0c2dcc4","head":{"label":"kelvinr:video_queue","ref":"video_queue","sha":"d472ff814d9b64e478d7e031dd15198fd0c2dcc4","user":{"login":"kelvinr","id":5810191,"avatar_url":"https://avatars.githubusercontent.com/u/5810191?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinr","html_url":"https://github.com/kelvinr","followers_url":"https://api.github.com/users/kelvinr/followers","following_url":"https://api.github.com/users/kelvinr/following{/other_user}","gists_url":"https://api.github.com/users/kelvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinr/subscriptions","organizations_url":"https://api.github.com/users/kelvinr/orgs","repos_url":"https://api.github.com/users/kelvinr/repos","events_url":"https://api.github.com/users/kelvinr/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinr/received_events","type":"User","site_admin":false},"repo":{"id":33289783,"name":"myflix","full_name":"kelvinr/myflix","owner":{"login":"kelvinr","id":5810191,"avatar_url":"https://avatars.githubusercontent.com/u/5810191?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinr","html_url":"https://github.com/kelvinr","followers_url":"https://api.github.com/users/kelvinr/followers","following_url":"https://api.github.com/users/kelvinr/following{/other_user}","gists_url":"https://api.github.com/users/kelvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinr/subscriptions","organizations_url":"https://api.github.com/users/kelvinr/orgs","repos_url":"https://api.github.com/users/kelvinr/repos","events_url":"https://api.github.com/users/kelvinr/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kelvinr/myflix","description":"","fork":false,"url":"https://api.github.com/repos/kelvinr/myflix","forks_url":"https://api.github.com/repos/kelvinr/myflix/forks","keys_url":"https://api.github.com/repos/kelvinr/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kelvinr/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kelvinr/myflix/teams","hooks_url":"https://api.github.com/repos/kelvinr/myflix/hooks","issue_events_url":"https://api.github.com/repos/kelvinr/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/kelvinr/myflix/events","assignees_url":"https://api.github.com/repos/kelvinr/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/kelvinr/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/kelvinr/myflix/tags","blobs_url":"https://api.github.com/repos/kelvinr/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kelvinr/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kelvinr/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/kelvinr/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kelvinr/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/kelvinr/myflix/languages","stargazers_url":"https://api.github.com/repos/kelvinr/myflix/stargazers","contributors_url":"https://api.github.com/repos/kelvinr/myflix/contributors","subscribers_url":"https://api.github.com/repos/kelvinr/myflix/subscribers","subscription_url":"https://api.github.com/repos/kelvinr/myflix/subscription","commits_url":"https://api.github.com/repos/kelvinr/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/kelvinr/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/kelvinr/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/kelvinr/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/kelvinr/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/kelvinr/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kelvinr/myflix/merges","archive_url":"https://api.github.com/repos/kelvinr/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kelvinr/myflix/downloads","issues_url":"https://api.github.com/repos/kelvinr/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/kelvinr/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/kelvinr/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/kelvinr/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kelvinr/myflix/labels{/name}","releases_url":"https://api.github.com/repos/kelvinr/myflix/releases{/id}","created_at":"2015-04-02T04:48:45Z","updated_at":"2015-04-17T00:29:35Z","pushed_at":"2015-04-17T20:25:15Z","git_url":"git://github.com/kelvinr/myflix.git","ssh_url":"git@github.com:kelvinr/myflix.git","clone_url":"https://github.com/kelvinr/myflix.git","svn_url":"https://github.com/kelvinr/myflix","homepage":null,"size":908,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"kelvinr:master","ref":"master","sha":"b673c1e6e0ca0f535a43d331570d748fa98fe66b","user":{"login":"kelvinr","id":5810191,"avatar_url":"https://avatars.githubusercontent.com/u/5810191?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinr","html_url":"https://github.com/kelvinr","followers_url":"https://api.github.com/users/kelvinr/followers","following_url":"https://api.github.com/users/kelvinr/following{/other_user}","gists_url":"https://api.github.com/users/kelvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinr/subscriptions","organizations_url":"https://api.github.com/users/kelvinr/orgs","repos_url":"https://api.github.com/users/kelvinr/repos","events_url":"https://api.github.com/users/kelvinr/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinr/received_events","type":"User","site_admin":false},"repo":{"id":33289783,"name":"myflix","full_name":"kelvinr/myflix","owner":{"login":"kelvinr","id":5810191,"avatar_url":"https://avatars.githubusercontent.com/u/5810191?v=3","gravatar_id":"","url":"https://api.github.com/users/kelvinr","html_url":"https://github.com/kelvinr","followers_url":"https://api.github.com/users/kelvinr/followers","following_url":"https://api.github.com/users/kelvinr/following{/other_user}","gists_url":"https://api.github.com/users/kelvinr/gists{/gist_id}","starred_url":"https://api.github.com/users/kelvinr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kelvinr/subscriptions","organizations_url":"https://api.github.com/users/kelvinr/orgs","repos_url":"https://api.github.com/users/kelvinr/repos","events_url":"https://api.github.com/users/kelvinr/events{/privacy}","received_events_url":"https://api.github.com/users/kelvinr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kelvinr/myflix","description":"","fork":false,"url":"https://api.github.com/repos/kelvinr/myflix","forks_url":"https://api.github.com/repos/kelvinr/myflix/forks","keys_url":"https://api.github.com/repos/kelvinr/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kelvinr/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kelvinr/myflix/teams","hooks_url":"https://api.github.com/repos/kelvinr/myflix/hooks","issue_events_url":"https://api.github.com/repos/kelvinr/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/kelvinr/myflix/events","assignees_url":"https://api.github.com/repos/kelvinr/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/kelvinr/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/kelvinr/myflix/tags","blobs_url":"https://api.github.com/repos/kelvinr/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kelvinr/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kelvinr/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/kelvinr/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kelvinr/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/kelvinr/myflix/languages","stargazers_url":"https://api.github.com/repos/kelvinr/myflix/stargazers","contributors_url":"https://api.github.com/repos/kelvinr/myflix/contributors","subscribers_url":"https://api.github.com/repos/kelvinr/myflix/subscribers","subscription_url":"https://api.github.com/repos/kelvinr/myflix/subscription","commits_url":"https://api.github.com/repos/kelvinr/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/kelvinr/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/kelvinr/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/kelvinr/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/kelvinr/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/kelvinr/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kelvinr/myflix/merges","archive_url":"https://api.github.com/repos/kelvinr/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kelvinr/myflix/downloads","issues_url":"https://api.github.com/repos/kelvinr/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/kelvinr/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/kelvinr/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/kelvinr/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kelvinr/myflix/labels{/name}","releases_url":"https://api.github.com/repos/kelvinr/myflix/releases{/id}","created_at":"2015-04-02T04:48:45Z","updated_at":"2015-04-17T00:29:35Z","pushed_at":"2015-04-17T20:25:15Z","git_url":"git://github.com/kelvinr/myflix.git","ssh_url":"git@github.com:kelvinr/myflix.git","clone_url":"https://github.com/kelvinr/myflix.git","svn_url":"https://github.com/kelvinr/myflix","homepage":null,"size":908,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/2"},"html":{"href":"https://github.com/kelvinr/myflix/pull/2"},"issue":{"href":"https://api.github.com/repos/kelvinr/myflix/issues/2"},"comments":{"href":"https://api.github.com/repos/kelvinr/myflix/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kelvinr/myflix/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/kelvinr/myflix/statuses/d472ff814d9b64e478d7e031dd15198fd0c2dcc4"}}}}