{"action":"created","comment":{"url":"https://api.github.com/repos/tommotaylor/myflix/pulls/comments/34278846","id":34278846,"diff_hunk":"@@ -100,17 +102,111 @@\n       delete :destroy, id: queue_item.id\n       expect(response).to redirect_to sign_in_path\n     end\n+    it \"normalises the queue after delete\" do\n+      queue_item1 = Fabricate(:queue_item, user_id: session[:user_id], list_order: 1)\n+      queue_item2 = Fabricate(:queue_item, user_id: session[:user_id], list_order: 2)\n+      queue_item3 = Fabricate(:queue_item, user_id: session[:user_id], list_order: 3)\n+      delete :destroy, id: queue_item2.id\n+      expect(queue_item3.reload.list_order).to eq(2)\n+    end\n   end\n \n-  describe \"PATCH update_list_order\" do\n-    before do\n-      session[:user_id] = Fabricate(:user).id\n-    end\n-    it \"redirects to my_queue\" do\n-      patch :update_list_order\n-      expect(response).to redirect_to my_queue_path\n+  describe \"POST update_list_order\" do\n+    context \"with valid inputs\" do\n+\n+      let(:video1) {Fabricate(:video)}\n+      let(:video2) {Fabricate(:video)}\n+      let(:queue_item_one) {Fabricate(:queue_item, user_id: session[:user_id], list_order: 1, video_id: video1.id)}\n+      let(:queue_item_two) {Fabricate(:queue_item, user_id: session[:user_id], list_order: 2, video_id: video2.id)}\n+\n+      before do\n+        session[:user_id] = Fabricate(:user).id\n+      end\n+\n+      it \"redirects to my_queue\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, \"list_order\"=>\"2\"}, {id: queue_item_two.id, \"list_order\"=>\"1\"}]\n+        expect(response).to redirect_to my_queue_path\n+      end\n+      it \"saves the queue items' new list_order\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 2}, {id: queue_item_two.id, list_order: 1}]\n+        expect(queue_item_one.reload.list_order).to eq(2)\n+      end\n+      it \"normalises the list_order\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 5}, {id: queue_item_two.id, list_order: 4}]\n+        expect(queue_item_one.reload.list_order).to eq(2)\n+      end\n+      it \"updates the rating of the user\" do\n+        review = Fabricate(:review, video_id: video1.id, user_id: session[:user_id], rating: 1)\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 1, rating: 5}]\n+        expect(review.reload.rating).to eq(5)\n+      end\n+      it \"creates a new rating if none exists\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 1, rating: 5}]\n+        expect(queue_item_one.reload.rating).to eq(5)\n+      end\n+      \n     end\n-    it \"updates the list_order of the queue item\"\n+    context \"with invalid inputs\" do\n+\n+      let(:video1) {Fabricate(:video)}\n+      let(:video2) {Fabricate(:video)}\n+      let(:queue_item_one) {Fabricate(:queue_item, user_id: session[:user_id], list_order: 1, video_id: video1.id)}\n+      let(:queue_item_two) {Fabricate(:queue_item, user_id: session[:user_id], list_order: 2, video_id: video2.id)}\n \n+      before do\n+        session[:user_id] = Fabricate(:user).id\n+      end\n+\n+      it \"doesn't update the list order if the data is a string\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 3}, {id: queue_item_two.id, list_order: \"foobar\"}]\n+        expect(queue_item_one.reload.list_order).to eq(1)\n+      end\n+      it \"doesn't update the list order if the data is a float\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 3.5}, {id: queue_item_two.id, list_order: 2}]\n+        expect(queue_item_one.reload.list_order).to eq(1)\n+      end\n+      it \"flashes an error\" do\n+        post :update_queue_items, queue_items: [{id: queue_item_one.id, list_order: 3.5}, {id: queue_item_two.id, list_order: 2}]\n+        expect(flash[:error]).to be_present","path":"spec/controllers/queue_items_controller_spec.rb","position":84,"original_position":84,"commit_id":"f261c5f77af70c1cbea3c1f6e5137df7f7d740b6","original_commit_id":"f261c5f77af70c1cbea3c1f6e5137df7f7d740b6","user":{"login":"brandoncc","id":543973,"avatar_url":"https://avatars.githubusercontent.com/u/543973?v=3","gravatar_id":"","url":"https://api.github.com/users/brandoncc","html_url":"https://github.com/brandoncc","followers_url":"https://api.github.com/users/brandoncc/followers","following_url":"https://api.github.com/users/brandoncc/following{/other_user}","gists_url":"https://api.github.com/users/brandoncc/gists{/gist_id}","starred_url":"https://api.github.com/users/brandoncc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandoncc/subscriptions","organizations_url":"https://api.github.com/users/brandoncc/orgs","repos_url":"https://api.github.com/users/brandoncc/repos","events_url":"https://api.github.com/users/brandoncc/events{/privacy}","received_events_url":"https://api.github.com/users/brandoncc/received_events","type":"User","site_admin":false},"body":"This is why your alert probably doesn't look right.","created_at":"2015-07-09T17:16:34Z","updated_at":"2015-07-09T17:16:34Z","html_url":"https://github.com/tommotaylor/myflix/pull/4#discussion_r34278846","pull_request_url":"https://api.github.com/repos/tommotaylor/myflix/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/tommotaylor/myflix/pulls/comments/34278846"},"html":{"href":"https://github.com/tommotaylor/myflix/pull/4#discussion_r34278846"},"pull_request":{"href":"https://api.github.com/repos/tommotaylor/myflix/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/tommotaylor/myflix/pulls/4","id":39601200,"html_url":"https://github.com/tommotaylor/myflix/pull/4","diff_url":"https://github.com/tommotaylor/myflix/pull/4.diff","patch_url":"https://github.com/tommotaylor/myflix/pull/4.patch","issue_url":"https://api.github.com/repos/tommotaylor/myflix/issues/4","number":4,"state":"open","locked":false,"title":"Week three work","user":{"login":"tommotaylor","id":2160769,"avatar_url":"https://avatars.githubusercontent.com/u/2160769?v=3","gravatar_id":"","url":"https://api.github.com/users/tommotaylor","html_url":"https://github.com/tommotaylor","followers_url":"https://api.github.com/users/tommotaylor/followers","following_url":"https://api.github.com/users/tommotaylor/following{/other_user}","gists_url":"https://api.github.com/users/tommotaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/tommotaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommotaylor/subscriptions","organizations_url":"https://api.github.com/users/tommotaylor/orgs","repos_url":"https://api.github.com/users/tommotaylor/repos","events_url":"https://api.github.com/users/tommotaylor/events{/privacy}","received_events_url":"https://api.github.com/users/tommotaylor/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-09T16:17:20Z","updated_at":"2015-07-09T17:16:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"99d379034def47240b45c900480e3b44cbc72c9f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tommotaylor/myflix/pulls/4/commits","review_comments_url":"https://api.github.com/repos/tommotaylor/myflix/pulls/4/comments","review_comment_url":"https://api.github.com/repos/tommotaylor/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tommotaylor/myflix/issues/4/comments","statuses_url":"https://api.github.com/repos/tommotaylor/myflix/statuses/f261c5f77af70c1cbea3c1f6e5137df7f7d740b6","head":{"label":"tommotaylor:week_three_work","ref":"week_three_work","sha":"f261c5f77af70c1cbea3c1f6e5137df7f7d740b6","user":{"login":"tommotaylor","id":2160769,"avatar_url":"https://avatars.githubusercontent.com/u/2160769?v=3","gravatar_id":"","url":"https://api.github.com/users/tommotaylor","html_url":"https://github.com/tommotaylor","followers_url":"https://api.github.com/users/tommotaylor/followers","following_url":"https://api.github.com/users/tommotaylor/following{/other_user}","gists_url":"https://api.github.com/users/tommotaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/tommotaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommotaylor/subscriptions","organizations_url":"https://api.github.com/users/tommotaylor/orgs","repos_url":"https://api.github.com/users/tommotaylor/repos","events_url":"https://api.github.com/users/tommotaylor/events{/privacy}","received_events_url":"https://api.github.com/users/tommotaylor/received_events","type":"User","site_admin":false},"repo":{"id":34522229,"name":"myflix","full_name":"tommotaylor/myflix","owner":{"login":"tommotaylor","id":2160769,"avatar_url":"https://avatars.githubusercontent.com/u/2160769?v=3","gravatar_id":"","url":"https://api.github.com/users/tommotaylor","html_url":"https://github.com/tommotaylor","followers_url":"https://api.github.com/users/tommotaylor/followers","following_url":"https://api.github.com/users/tommotaylor/following{/other_user}","gists_url":"https://api.github.com/users/tommotaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/tommotaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommotaylor/subscriptions","organizations_url":"https://api.github.com/users/tommotaylor/orgs","repos_url":"https://api.github.com/users/tommotaylor/repos","events_url":"https://api.github.com/users/tommotaylor/events{/privacy}","received_events_url":"https://api.github.com/users/tommotaylor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tommotaylor/myflix","description":"","fork":false,"url":"https://api.github.com/repos/tommotaylor/myflix","forks_url":"https://api.github.com/repos/tommotaylor/myflix/forks","keys_url":"https://api.github.com/repos/tommotaylor/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tommotaylor/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tommotaylor/myflix/teams","hooks_url":"https://api.github.com/repos/tommotaylor/myflix/hooks","issue_events_url":"https://api.github.com/repos/tommotaylor/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/tommotaylor/myflix/events","assignees_url":"https://api.github.com/repos/tommotaylor/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/tommotaylor/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/tommotaylor/myflix/tags","blobs_url":"https://api.github.com/repos/tommotaylor/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tommotaylor/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tommotaylor/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/tommotaylor/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tommotaylor/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/tommotaylor/myflix/languages","stargazers_url":"https://api.github.com/repos/tommotaylor/myflix/stargazers","contributors_url":"https://api.github.com/repos/tommotaylor/myflix/contributors","subscribers_url":"https://api.github.com/repos/tommotaylor/myflix/subscribers","subscription_url":"https://api.github.com/repos/tommotaylor/myflix/subscription","commits_url":"https://api.github.com/repos/tommotaylor/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/tommotaylor/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/tommotaylor/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/tommotaylor/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/tommotaylor/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/tommotaylor/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tommotaylor/myflix/merges","archive_url":"https://api.github.com/repos/tommotaylor/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tommotaylor/myflix/downloads","issues_url":"https://api.github.com/repos/tommotaylor/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/tommotaylor/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/tommotaylor/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/tommotaylor/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tommotaylor/myflix/labels{/name}","releases_url":"https://api.github.com/repos/tommotaylor/myflix/releases{/id}","created_at":"2015-04-24T14:07:36Z","updated_at":"2015-05-13T13:30:13Z","pushed_at":"2015-07-09T16:17:20Z","git_url":"git://github.com/tommotaylor/myflix.git","ssh_url":"git@github.com:tommotaylor/myflix.git","clone_url":"https://github.com/tommotaylor/myflix.git","svn_url":"https://github.com/tommotaylor/myflix","homepage":null,"size":544,"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":"tommotaylor:master","ref":"master","sha":"fd54832043de9cfa56c990b8596e0b436be05470","user":{"login":"tommotaylor","id":2160769,"avatar_url":"https://avatars.githubusercontent.com/u/2160769?v=3","gravatar_id":"","url":"https://api.github.com/users/tommotaylor","html_url":"https://github.com/tommotaylor","followers_url":"https://api.github.com/users/tommotaylor/followers","following_url":"https://api.github.com/users/tommotaylor/following{/other_user}","gists_url":"https://api.github.com/users/tommotaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/tommotaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommotaylor/subscriptions","organizations_url":"https://api.github.com/users/tommotaylor/orgs","repos_url":"https://api.github.com/users/tommotaylor/repos","events_url":"https://api.github.com/users/tommotaylor/events{/privacy}","received_events_url":"https://api.github.com/users/tommotaylor/received_events","type":"User","site_admin":false},"repo":{"id":34522229,"name":"myflix","full_name":"tommotaylor/myflix","owner":{"login":"tommotaylor","id":2160769,"avatar_url":"https://avatars.githubusercontent.com/u/2160769?v=3","gravatar_id":"","url":"https://api.github.com/users/tommotaylor","html_url":"https://github.com/tommotaylor","followers_url":"https://api.github.com/users/tommotaylor/followers","following_url":"https://api.github.com/users/tommotaylor/following{/other_user}","gists_url":"https://api.github.com/users/tommotaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/tommotaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommotaylor/subscriptions","organizations_url":"https://api.github.com/users/tommotaylor/orgs","repos_url":"https://api.github.com/users/tommotaylor/repos","events_url":"https://api.github.com/users/tommotaylor/events{/privacy}","received_events_url":"https://api.github.com/users/tommotaylor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tommotaylor/myflix","description":"","fork":false,"url":"https://api.github.com/repos/tommotaylor/myflix","forks_url":"https://api.github.com/repos/tommotaylor/myflix/forks","keys_url":"https://api.github.com/repos/tommotaylor/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tommotaylor/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tommotaylor/myflix/teams","hooks_url":"https://api.github.com/repos/tommotaylor/myflix/hooks","issue_events_url":"https://api.github.com/repos/tommotaylor/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/tommotaylor/myflix/events","assignees_url":"https://api.github.com/repos/tommotaylor/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/tommotaylor/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/tommotaylor/myflix/tags","blobs_url":"https://api.github.com/repos/tommotaylor/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tommotaylor/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tommotaylor/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/tommotaylor/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tommotaylor/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/tommotaylor/myflix/languages","stargazers_url":"https://api.github.com/repos/tommotaylor/myflix/stargazers","contributors_url":"https://api.github.com/repos/tommotaylor/myflix/contributors","subscribers_url":"https://api.github.com/repos/tommotaylor/myflix/subscribers","subscription_url":"https://api.github.com/repos/tommotaylor/myflix/subscription","commits_url":"https://api.github.com/repos/tommotaylor/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/tommotaylor/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/tommotaylor/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/tommotaylor/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/tommotaylor/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/tommotaylor/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tommotaylor/myflix/merges","archive_url":"https://api.github.com/repos/tommotaylor/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tommotaylor/myflix/downloads","issues_url":"https://api.github.com/repos/tommotaylor/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/tommotaylor/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/tommotaylor/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/tommotaylor/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tommotaylor/myflix/labels{/name}","releases_url":"https://api.github.com/repos/tommotaylor/myflix/releases{/id}","created_at":"2015-04-24T14:07:36Z","updated_at":"2015-05-13T13:30:13Z","pushed_at":"2015-07-09T16:17:20Z","git_url":"git://github.com/tommotaylor/myflix.git","ssh_url":"git@github.com:tommotaylor/myflix.git","clone_url":"https://github.com/tommotaylor/myflix.git","svn_url":"https://github.com/tommotaylor/myflix","homepage":null,"size":544,"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/tommotaylor/myflix/pulls/4"},"html":{"href":"https://github.com/tommotaylor/myflix/pull/4"},"issue":{"href":"https://api.github.com/repos/tommotaylor/myflix/issues/4"},"comments":{"href":"https://api.github.com/repos/tommotaylor/myflix/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/tommotaylor/myflix/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/tommotaylor/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tommotaylor/myflix/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/tommotaylor/myflix/statuses/f261c5f77af70c1cbea3c1f6e5137df7f7d740b6"}}}}