{"action":"created","comment":{"url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/comments/45058796","id":45058796,"diff_hunk":"@@ -0,0 +1,148 @@\n+require \"rails_helper\"\n+require \"shared_examples/shared_examples_for_api_controllers\"\n+require \"support/helpers/api_helper.rb\"\n+include ApiHelper\n+\n+module ApiFlashcards\n+  RSpec.describe Api::V1::ReviewController, type: :controller do\n+    routes { ApiFlashcards::Engine.routes }\n+\n+    describe \"GET#index\" do\n+      context \"without credentials\" do\n+        before { get :index }\n+        it_behaves_like \"not authorized\"\n+      end\n+\n+      context \"with incorrect credentials\" do\n+        before do\n+          get :index,\n+              request.headers[\"Authorization\"] = encode(\"some@test.com\",\n+                                                        \"nopass\")\n+        end\n+        it_behaves_like \"not authorized\"\n+      end\n+\n+      context \"with correct credentials\" do\n+        include_context \"with correct credentials\" do\n+          let(:endpoint) do\n+            {\n+              verb: \"get\",\n+              method: \"index\"\n+            }\n+          end\n+        end\n+        it \"responds with 200 status code\" do\n+          expect(response.status).to eq(200)\n+        end\n+        it \"responds with \\'card_review\\' key in response\" do\n+          expect(json_response.key?(\"card_review\")).to eq(true)\n+        end\n+        it \"responds with only one card\" do\n+          expect(json_response[\"card_review\"]).not_to be_kind_of Array\n+        end\n+\n+        %w(id original_text).each do |field|\n+          it \"contains \\'#{field}\\' key inside \\'card_review\\'\" do\n+            expect(json_response[\"card_review\"].key?(field)).to eq(true)\n+          end\n+        end\n+\n+        it \"does NOT contain \\'translated_text\\' key inside \\'card_review\\'\" do\n+          expect(json_response[\"card_review\"].\n+            key?(\"translated_text\")).to eq(false)\n+        end\n+      end\n+    end\n+\n+    describe \"PUT#check\" do\n+      context \"without credentials\" do\n+        before { put :check }\n+        it_behaves_like \"not authorized\"\n+      end\n+\n+      context \"with incorrect credentials\" do\n+        before do\n+          put :check,\n+              request.headers[\"Authorization\"] = encode(\"some@test.com\",\n+                                                        \"nopass\")\n+        end\n+        it_behaves_like \"not authorized\"\n+      end\n+\n+      context \"with correct credentials\" do\n+        include_context \"with correct credentials\" do\n+          let(:endpoint) do\n+            { verb: \"put\", method: \"check\" }\n+          end\n+          let(:params) do\n+            {\n+              card_id: card.id,\n+              translated_text: \"Translation\"\n+            }\n+          end\n+        end\n+\n+        shared_examples \"common response\" do\n+          it \"responds with 200 status code\" do\n+            expect(response.status).to eq(200)\n+          end\n+          it \"contains \\'result\\' key in response\" do\n+            expect(json_response.key?(\"result\")).to eq(true)\n+          end\n+        end\n+\n+        context \"when user provides correct translation\" do\n+          let(:stub) do\n+            allow_any_instance_of(Card).to receive(:check_translation).with(any_args).\n+              and_return({ state: true, distance: 0 })\n+          end\n+          let(:params) do\n+            {\n+              card_id: card.id,\n+              translated_text: \"Translation\"\n+            }\n+          end\n+          it_behaves_like \"common response\"\n+          it \"responds with successful message\" do\n+            expect(json_response[\"result\"]).to eq(\"Your answer is correct\")\n+          end\n+        end\n+\n+        context \"when user made a typo\" do\n+          let(:stub) do\n+            allow_any_instance_of(Card).to receive(:check_translation).with(any_args).\n+              and_return({ state: true, distance: 1 })","path":"spec/controllers/api_flashcards/api/v1/review_controller_spec.rb","position":114,"original_position":114,"commit_id":"d4bb43af4fc1dc021dc2eb4a136c079065cdca09","original_commit_id":"d4bb43af4fc1dc021dc2eb4a136c079065cdca09","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Redundant curly braces around a hash parameter.","created_at":"2015-11-17T13:26:17Z","updated_at":"2015-11-17T13:26:17Z","html_url":"https://github.com/ArmadilloXX/api_flashcards/pull/3#discussion_r45058796","pull_request_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/comments/45058796"},"html":{"href":"https://github.com/ArmadilloXX/api_flashcards/pull/3#discussion_r45058796"},"pull_request":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3","id":50641317,"html_url":"https://github.com/ArmadilloXX/api_flashcards/pull/3","diff_url":"https://github.com/ArmadilloXX/api_flashcards/pull/3.diff","patch_url":"https://github.com/ArmadilloXX/api_flashcards/pull/3.patch","issue_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/3","number":3,"state":"open","locked":false,"title":"Sixth task","user":{"login":"ArmadilloXX","id":6916657,"avatar_url":"https://avatars.githubusercontent.com/u/6916657?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmadilloXX","html_url":"https://github.com/ArmadilloXX","followers_url":"https://api.github.com/users/ArmadilloXX/followers","following_url":"https://api.github.com/users/ArmadilloXX/following{/other_user}","gists_url":"https://api.github.com/users/ArmadilloXX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmadilloXX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmadilloXX/subscriptions","organizations_url":"https://api.github.com/users/ArmadilloXX/orgs","repos_url":"https://api.github.com/users/ArmadilloXX/repos","events_url":"https://api.github.com/users/ArmadilloXX/events{/privacy}","received_events_url":"https://api.github.com/users/ArmadilloXX/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-13T13:36:07Z","updated_at":"2015-11-17T13:26:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"809c0fa6e034882cda11fdca75657d6507b61ba5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3/commits","review_comments_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3/comments","review_comment_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/3/comments","statuses_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/statuses/d4bb43af4fc1dc021dc2eb4a136c079065cdca09","head":{"label":"ArmadilloXX:sixth_task","ref":"sixth_task","sha":"d4bb43af4fc1dc021dc2eb4a136c079065cdca09","user":{"login":"ArmadilloXX","id":6916657,"avatar_url":"https://avatars.githubusercontent.com/u/6916657?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmadilloXX","html_url":"https://github.com/ArmadilloXX","followers_url":"https://api.github.com/users/ArmadilloXX/followers","following_url":"https://api.github.com/users/ArmadilloXX/following{/other_user}","gists_url":"https://api.github.com/users/ArmadilloXX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmadilloXX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmadilloXX/subscriptions","organizations_url":"https://api.github.com/users/ArmadilloXX/orgs","repos_url":"https://api.github.com/users/ArmadilloXX/repos","events_url":"https://api.github.com/users/ArmadilloXX/events{/privacy}","received_events_url":"https://api.github.com/users/ArmadilloXX/received_events","type":"User","site_admin":false},"repo":{"id":45540542,"name":"api_flashcards","full_name":"ArmadilloXX/api_flashcards","owner":{"login":"ArmadilloXX","id":6916657,"avatar_url":"https://avatars.githubusercontent.com/u/6916657?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmadilloXX","html_url":"https://github.com/ArmadilloXX","followers_url":"https://api.github.com/users/ArmadilloXX/followers","following_url":"https://api.github.com/users/ArmadilloXX/following{/other_user}","gists_url":"https://api.github.com/users/ArmadilloXX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmadilloXX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmadilloXX/subscriptions","organizations_url":"https://api.github.com/users/ArmadilloXX/orgs","repos_url":"https://api.github.com/users/ArmadilloXX/repos","events_url":"https://api.github.com/users/ArmadilloXX/events{/privacy}","received_events_url":"https://api.github.com/users/ArmadilloXX/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ArmadilloXX/api_flashcards","description":"","fork":false,"url":"https://api.github.com/repos/ArmadilloXX/api_flashcards","forks_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/forks","keys_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/teams","hooks_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/hooks","issue_events_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/events","assignees_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/tags","blobs_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/languages","stargazers_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/stargazers","contributors_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/contributors","subscribers_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/subscribers","subscription_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/subscription","commits_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/merges","archive_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/downloads","issues_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/labels{/name}","releases_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/releases{/id}","created_at":"2015-11-04T13:26:22Z","updated_at":"2015-11-04T13:32:02Z","pushed_at":"2015-11-17T13:26:07Z","git_url":"git://github.com/ArmadilloXX/api_flashcards.git","ssh_url":"git@github.com:ArmadilloXX/api_flashcards.git","clone_url":"https://github.com/ArmadilloXX/api_flashcards.git","svn_url":"https://github.com/ArmadilloXX/api_flashcards","homepage":null,"size":91,"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":"ArmadilloXX:master","ref":"master","sha":"eeaa08cb7fb53cf5f166c68d480abe5bdec61639","user":{"login":"ArmadilloXX","id":6916657,"avatar_url":"https://avatars.githubusercontent.com/u/6916657?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmadilloXX","html_url":"https://github.com/ArmadilloXX","followers_url":"https://api.github.com/users/ArmadilloXX/followers","following_url":"https://api.github.com/users/ArmadilloXX/following{/other_user}","gists_url":"https://api.github.com/users/ArmadilloXX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmadilloXX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmadilloXX/subscriptions","organizations_url":"https://api.github.com/users/ArmadilloXX/orgs","repos_url":"https://api.github.com/users/ArmadilloXX/repos","events_url":"https://api.github.com/users/ArmadilloXX/events{/privacy}","received_events_url":"https://api.github.com/users/ArmadilloXX/received_events","type":"User","site_admin":false},"repo":{"id":45540542,"name":"api_flashcards","full_name":"ArmadilloXX/api_flashcards","owner":{"login":"ArmadilloXX","id":6916657,"avatar_url":"https://avatars.githubusercontent.com/u/6916657?v=3","gravatar_id":"","url":"https://api.github.com/users/ArmadilloXX","html_url":"https://github.com/ArmadilloXX","followers_url":"https://api.github.com/users/ArmadilloXX/followers","following_url":"https://api.github.com/users/ArmadilloXX/following{/other_user}","gists_url":"https://api.github.com/users/ArmadilloXX/gists{/gist_id}","starred_url":"https://api.github.com/users/ArmadilloXX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArmadilloXX/subscriptions","organizations_url":"https://api.github.com/users/ArmadilloXX/orgs","repos_url":"https://api.github.com/users/ArmadilloXX/repos","events_url":"https://api.github.com/users/ArmadilloXX/events{/privacy}","received_events_url":"https://api.github.com/users/ArmadilloXX/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ArmadilloXX/api_flashcards","description":"","fork":false,"url":"https://api.github.com/repos/ArmadilloXX/api_flashcards","forks_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/forks","keys_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/teams","hooks_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/hooks","issue_events_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/events","assignees_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/tags","blobs_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/languages","stargazers_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/stargazers","contributors_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/contributors","subscribers_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/subscribers","subscription_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/subscription","commits_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/merges","archive_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/downloads","issues_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/labels{/name}","releases_url":"https://api.github.com/repos/ArmadilloXX/api_flashcards/releases{/id}","created_at":"2015-11-04T13:26:22Z","updated_at":"2015-11-04T13:32:02Z","pushed_at":"2015-11-17T13:26:07Z","git_url":"git://github.com/ArmadilloXX/api_flashcards.git","ssh_url":"git@github.com:ArmadilloXX/api_flashcards.git","clone_url":"https://github.com/ArmadilloXX/api_flashcards.git","svn_url":"https://github.com/ArmadilloXX/api_flashcards","homepage":null,"size":91,"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/ArmadilloXX/api_flashcards/pulls/3"},"html":{"href":"https://github.com/ArmadilloXX/api_flashcards/pull/3"},"issue":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/3"},"comments":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/ArmadilloXX/api_flashcards/statuses/d4bb43af4fc1dc021dc2eb4a136c079065cdca09"}}}}