{"action":"created","comment":{"url":"https://api.github.com/repos/GLexx909/test_guru/pulls/comments/227428781","pull_request_review_id":167460018,"id":227428781,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzQyODc4MQ==","diff_hunk":"@@ -41,4 +45,56 @@ def find_test_passage\n     @test_passage = TestPassage.find(params[:id])\n   end\n \n+  def find_badge(id)\n+    Badge.find(id)\n+  end\n+\n+  def give_budges\n+\n+    # Giv badge for successfully ended Test with 100% right answers\n+    badge_any_test = find_badge(1)\n+    if @test_passage.success_all?\n+      current_user.badge_issueds.create!(badge: badge_any_test) #Тестовый бадж, будет удалён.\n+      flash[:notice1] = 'Вы получили награду за правильные ответы на все вопросы.'\n+    end  \n+\n+    # Giv badge for successfully ended Test on the first try\n+    if @test_passage.unique?\n+      badge_first_att = find_badge(2)\n+      current_user.badge_issueds.create!(badge: badge_first_att)\n+      flash[:notice2] = 'Вы получили награду за успешно пройденный тест с первой попытки.'\n+    end\n+\n+    # Giv badge for successful completion of all tests of a certain category\n+    current_category = @test_passage.test.category","path":"app/controllers/test_passages_controller.rb","position":36,"original_position":36,"commit_id":"c04c4721d1fa4eed3ea91d1c8a50bbec7e2a3dde","original_commit_id":"c04c4721d1fa4eed3ea91d1c8a50bbec7e2a3dde","user":{"login":"iBublik","id":11278497,"node_id":"MDQ6VXNlcjExMjc4NDk3","avatar_url":"https://avatars1.githubusercontent.com/u/11278497?v=4","gravatar_id":"","url":"https://api.github.com/users/iBublik","html_url":"https://github.com/iBublik","followers_url":"https://api.github.com/users/iBublik/followers","following_url":"https://api.github.com/users/iBublik/following{/other_user}","gists_url":"https://api.github.com/users/iBublik/gists{/gist_id}","starred_url":"https://api.github.com/users/iBublik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iBublik/subscriptions","organizations_url":"https://api.github.com/users/iBublik/orgs","repos_url":"https://api.github.com/users/iBublik/repos","events_url":"https://api.github.com/users/iBublik/events{/privacy}","received_events_url":"https://api.github.com/users/iBublik/received_events","type":"User","site_admin":false},"body":"Категория/уровень тестов, за которые выдается бейдж, должны быть параметром этого бейджа. Т.е. админ должен иметь возможность создать бейдж \"За прохождение всех тестов категории Бэкенд\", \"За прохождение всех тестов категории Фронтенд\" и тд","created_at":"2018-10-23T14:49:42Z","updated_at":"2018-10-23T14:56:02Z","html_url":"https://github.com/GLexx909/test_guru/pull/19#discussion_r227428781","pull_request_url":"https://api.github.com/repos/GLexx909/test_guru/pulls/19","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/comments/227428781"},"html":{"href":"https://github.com/GLexx909/test_guru/pull/19#discussion_r227428781"},"pull_request":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/GLexx909/test_guru/pulls/19","id":225024220,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1MDI0MjIw","html_url":"https://github.com/GLexx909/test_guru/pull/19","diff_url":"https://github.com/GLexx909/test_guru/pull/19.diff","patch_url":"https://github.com/GLexx909/test_guru/pull/19.patch","issue_url":"https://api.github.com/repos/GLexx909/test_guru/issues/19","number":19,"state":"open","locked":false,"title":"Task18","user":{"login":"GLexx909","id":32548156,"node_id":"MDQ6VXNlcjMyNTQ4MTU2","avatar_url":"https://avatars3.githubusercontent.com/u/32548156?v=4","gravatar_id":"","url":"https://api.github.com/users/GLexx909","html_url":"https://github.com/GLexx909","followers_url":"https://api.github.com/users/GLexx909/followers","following_url":"https://api.github.com/users/GLexx909/following{/other_user}","gists_url":"https://api.github.com/users/GLexx909/gists{/gist_id}","starred_url":"https://api.github.com/users/GLexx909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLexx909/subscriptions","organizations_url":"https://api.github.com/users/GLexx909/orgs","repos_url":"https://api.github.com/users/GLexx909/repos","events_url":"https://api.github.com/users/GLexx909/events{/privacy}","received_events_url":"https://api.github.com/users/GLexx909/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-10-23T12:46:58Z","updated_at":"2018-10-23T14:56:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3686de44550341ac50e7bff33a3570d93c8fd30d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GLexx909/test_guru/pulls/19/commits","review_comments_url":"https://api.github.com/repos/GLexx909/test_guru/pulls/19/comments","review_comment_url":"https://api.github.com/repos/GLexx909/test_guru/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GLexx909/test_guru/issues/19/comments","statuses_url":"https://api.github.com/repos/GLexx909/test_guru/statuses/c04c4721d1fa4eed3ea91d1c8a50bbec7e2a3dde","head":{"label":"GLexx909:task18","ref":"task18","sha":"c04c4721d1fa4eed3ea91d1c8a50bbec7e2a3dde","user":{"login":"GLexx909","id":32548156,"node_id":"MDQ6VXNlcjMyNTQ4MTU2","avatar_url":"https://avatars3.githubusercontent.com/u/32548156?v=4","gravatar_id":"","url":"https://api.github.com/users/GLexx909","html_url":"https://github.com/GLexx909","followers_url":"https://api.github.com/users/GLexx909/followers","following_url":"https://api.github.com/users/GLexx909/following{/other_user}","gists_url":"https://api.github.com/users/GLexx909/gists{/gist_id}","starred_url":"https://api.github.com/users/GLexx909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLexx909/subscriptions","organizations_url":"https://api.github.com/users/GLexx909/orgs","repos_url":"https://api.github.com/users/GLexx909/repos","events_url":"https://api.github.com/users/GLexx909/events{/privacy}","received_events_url":"https://api.github.com/users/GLexx909/received_events","type":"User","site_admin":false},"repo":{"id":147381028,"node_id":"MDEwOlJlcG9zaXRvcnkxNDczODEwMjg=","name":"test_guru","full_name":"GLexx909/test_guru","private":false,"owner":{"login":"GLexx909","id":32548156,"node_id":"MDQ6VXNlcjMyNTQ4MTU2","avatar_url":"https://avatars3.githubusercontent.com/u/32548156?v=4","gravatar_id":"","url":"https://api.github.com/users/GLexx909","html_url":"https://github.com/GLexx909","followers_url":"https://api.github.com/users/GLexx909/followers","following_url":"https://api.github.com/users/GLexx909/following{/other_user}","gists_url":"https://api.github.com/users/GLexx909/gists{/gist_id}","starred_url":"https://api.github.com/users/GLexx909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLexx909/subscriptions","organizations_url":"https://api.github.com/users/GLexx909/orgs","repos_url":"https://api.github.com/users/GLexx909/repos","events_url":"https://api.github.com/users/GLexx909/events{/privacy}","received_events_url":"https://api.github.com/users/GLexx909/received_events","type":"User","site_admin":false},"html_url":"https://github.com/GLexx909/test_guru","description":null,"fork":false,"url":"https://api.github.com/repos/GLexx909/test_guru","forks_url":"https://api.github.com/repos/GLexx909/test_guru/forks","keys_url":"https://api.github.com/repos/GLexx909/test_guru/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GLexx909/test_guru/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GLexx909/test_guru/teams","hooks_url":"https://api.github.com/repos/GLexx909/test_guru/hooks","issue_events_url":"https://api.github.com/repos/GLexx909/test_guru/issues/events{/number}","events_url":"https://api.github.com/repos/GLexx909/test_guru/events","assignees_url":"https://api.github.com/repos/GLexx909/test_guru/assignees{/user}","branches_url":"https://api.github.com/repos/GLexx909/test_guru/branches{/branch}","tags_url":"https://api.github.com/repos/GLexx909/test_guru/tags","blobs_url":"https://api.github.com/repos/GLexx909/test_guru/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GLexx909/test_guru/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GLexx909/test_guru/git/refs{/sha}","trees_url":"https://api.github.com/repos/GLexx909/test_guru/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GLexx909/test_guru/statuses/{sha}","languages_url":"https://api.github.com/repos/GLexx909/test_guru/languages","stargazers_url":"https://api.github.com/repos/GLexx909/test_guru/stargazers","contributors_url":"https://api.github.com/repos/GLexx909/test_guru/contributors","subscribers_url":"https://api.github.com/repos/GLexx909/test_guru/subscribers","subscription_url":"https://api.github.com/repos/GLexx909/test_guru/subscription","commits_url":"https://api.github.com/repos/GLexx909/test_guru/commits{/sha}","git_commits_url":"https://api.github.com/repos/GLexx909/test_guru/git/commits{/sha}","comments_url":"https://api.github.com/repos/GLexx909/test_guru/comments{/number}","issue_comment_url":"https://api.github.com/repos/GLexx909/test_guru/issues/comments{/number}","contents_url":"https://api.github.com/repos/GLexx909/test_guru/contents/{+path}","compare_url":"https://api.github.com/repos/GLexx909/test_guru/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GLexx909/test_guru/merges","archive_url":"https://api.github.com/repos/GLexx909/test_guru/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GLexx909/test_guru/downloads","issues_url":"https://api.github.com/repos/GLexx909/test_guru/issues{/number}","pulls_url":"https://api.github.com/repos/GLexx909/test_guru/pulls{/number}","milestones_url":"https://api.github.com/repos/GLexx909/test_guru/milestones{/number}","notifications_url":"https://api.github.com/repos/GLexx909/test_guru/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GLexx909/test_guru/labels{/name}","releases_url":"https://api.github.com/repos/GLexx909/test_guru/releases{/id}","deployments_url":"https://api.github.com/repos/GLexx909/test_guru/deployments","created_at":"2018-09-04T17:10:18Z","updated_at":"2018-10-22T07:35:34Z","pushed_at":"2018-10-23T12:46:58Z","git_url":"git://github.com/GLexx909/test_guru.git","ssh_url":"git@github.com:GLexx909/test_guru.git","clone_url":"https://github.com/GLexx909/test_guru.git","svn_url":"https://github.com/GLexx909/test_guru","homepage":null,"size":5926,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"GLexx909:devel","ref":"devel","sha":"27b54634a06354c78af3059e1ae9a6b1665a7a04","user":{"login":"GLexx909","id":32548156,"node_id":"MDQ6VXNlcjMyNTQ4MTU2","avatar_url":"https://avatars3.githubusercontent.com/u/32548156?v=4","gravatar_id":"","url":"https://api.github.com/users/GLexx909","html_url":"https://github.com/GLexx909","followers_url":"https://api.github.com/users/GLexx909/followers","following_url":"https://api.github.com/users/GLexx909/following{/other_user}","gists_url":"https://api.github.com/users/GLexx909/gists{/gist_id}","starred_url":"https://api.github.com/users/GLexx909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLexx909/subscriptions","organizations_url":"https://api.github.com/users/GLexx909/orgs","repos_url":"https://api.github.com/users/GLexx909/repos","events_url":"https://api.github.com/users/GLexx909/events{/privacy}","received_events_url":"https://api.github.com/users/GLexx909/received_events","type":"User","site_admin":false},"repo":{"id":147381028,"node_id":"MDEwOlJlcG9zaXRvcnkxNDczODEwMjg=","name":"test_guru","full_name":"GLexx909/test_guru","private":false,"owner":{"login":"GLexx909","id":32548156,"node_id":"MDQ6VXNlcjMyNTQ4MTU2","avatar_url":"https://avatars3.githubusercontent.com/u/32548156?v=4","gravatar_id":"","url":"https://api.github.com/users/GLexx909","html_url":"https://github.com/GLexx909","followers_url":"https://api.github.com/users/GLexx909/followers","following_url":"https://api.github.com/users/GLexx909/following{/other_user}","gists_url":"https://api.github.com/users/GLexx909/gists{/gist_id}","starred_url":"https://api.github.com/users/GLexx909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GLexx909/subscriptions","organizations_url":"https://api.github.com/users/GLexx909/orgs","repos_url":"https://api.github.com/users/GLexx909/repos","events_url":"https://api.github.com/users/GLexx909/events{/privacy}","received_events_url":"https://api.github.com/users/GLexx909/received_events","type":"User","site_admin":false},"html_url":"https://github.com/GLexx909/test_guru","description":null,"fork":false,"url":"https://api.github.com/repos/GLexx909/test_guru","forks_url":"https://api.github.com/repos/GLexx909/test_guru/forks","keys_url":"https://api.github.com/repos/GLexx909/test_guru/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GLexx909/test_guru/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GLexx909/test_guru/teams","hooks_url":"https://api.github.com/repos/GLexx909/test_guru/hooks","issue_events_url":"https://api.github.com/repos/GLexx909/test_guru/issues/events{/number}","events_url":"https://api.github.com/repos/GLexx909/test_guru/events","assignees_url":"https://api.github.com/repos/GLexx909/test_guru/assignees{/user}","branches_url":"https://api.github.com/repos/GLexx909/test_guru/branches{/branch}","tags_url":"https://api.github.com/repos/GLexx909/test_guru/tags","blobs_url":"https://api.github.com/repos/GLexx909/test_guru/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GLexx909/test_guru/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GLexx909/test_guru/git/refs{/sha}","trees_url":"https://api.github.com/repos/GLexx909/test_guru/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GLexx909/test_guru/statuses/{sha}","languages_url":"https://api.github.com/repos/GLexx909/test_guru/languages","stargazers_url":"https://api.github.com/repos/GLexx909/test_guru/stargazers","contributors_url":"https://api.github.com/repos/GLexx909/test_guru/contributors","subscribers_url":"https://api.github.com/repos/GLexx909/test_guru/subscribers","subscription_url":"https://api.github.com/repos/GLexx909/test_guru/subscription","commits_url":"https://api.github.com/repos/GLexx909/test_guru/commits{/sha}","git_commits_url":"https://api.github.com/repos/GLexx909/test_guru/git/commits{/sha}","comments_url":"https://api.github.com/repos/GLexx909/test_guru/comments{/number}","issue_comment_url":"https://api.github.com/repos/GLexx909/test_guru/issues/comments{/number}","contents_url":"https://api.github.com/repos/GLexx909/test_guru/contents/{+path}","compare_url":"https://api.github.com/repos/GLexx909/test_guru/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GLexx909/test_guru/merges","archive_url":"https://api.github.com/repos/GLexx909/test_guru/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GLexx909/test_guru/downloads","issues_url":"https://api.github.com/repos/GLexx909/test_guru/issues{/number}","pulls_url":"https://api.github.com/repos/GLexx909/test_guru/pulls{/number}","milestones_url":"https://api.github.com/repos/GLexx909/test_guru/milestones{/number}","notifications_url":"https://api.github.com/repos/GLexx909/test_guru/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GLexx909/test_guru/labels{/name}","releases_url":"https://api.github.com/repos/GLexx909/test_guru/releases{/id}","deployments_url":"https://api.github.com/repos/GLexx909/test_guru/deployments","created_at":"2018-09-04T17:10:18Z","updated_at":"2018-10-22T07:35:34Z","pushed_at":"2018-10-23T12:46:58Z","git_url":"git://github.com/GLexx909/test_guru.git","ssh_url":"git@github.com:GLexx909/test_guru.git","clone_url":"https://github.com/GLexx909/test_guru.git","svn_url":"https://github.com/GLexx909/test_guru","homepage":null,"size":5926,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/19"},"html":{"href":"https://github.com/GLexx909/test_guru/pull/19"},"issue":{"href":"https://api.github.com/repos/GLexx909/test_guru/issues/19"},"comments":{"href":"https://api.github.com/repos/GLexx909/test_guru/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GLexx909/test_guru/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/GLexx909/test_guru/statuses/c04c4721d1fa4eed3ea91d1c8a50bbec7e2a3dde"}},"author_association":"OWNER"}}
{"actor":{"display_login":"iBublik"}}