{"action":"created","comment":{"url":"https://api.github.com/repos/shved/qna/pulls/comments/30657375","id":30657375,"diff_hunk":"@@ -0,0 +1,77 @@\n+require 'rails_helper'\n+\n+RSpec.describe Vote, type: :model do\n+  it { should validate_presence_of :user_id }\n+  it { should validate_inclusion_of(:votable_type).in_array ['Question', 'Answer'] }\n+  it { should validate_inclusion_of(:value).in_array [-1, 1] }\n+\n+  it { should belong_to :user }\n+  it { should belong_to :votable }\n+\n+  let(:users) { create_list(:user, 2) }\n+  let(:user) { users.at(0) }\n+  let(:other_user) { users.at(1) }\n+  let(:question) { create(:question) }\n+  let(:answer) { create(:answer, question: question) }\n+\n+  [:question, :answer].each do |votable_name|\n+    before { @votable = send votable_name }\n+\n+    describe \"vote for #{ votable_name }\" do\n+      it \"voted up by user\" do\n+        expect{ @votable.vote user, 1 }.to change(@votable.votes, :count).by(1)\n+        expect( @votable.voted_by? user ).to be true\n+      end\n+\n+      it \"voted down by user\" do\n+        expect{ @votable.vote user, -1 }.to change(@votable.votes, :count).by(1)","path":"spec/models/vote_spec.rb","position":27,"original_position":27,"commit_id":"caaa787fede4196b69fa25ce86d580265b557d94","original_commit_id":"caaa787fede4196b69fa25ce86d580265b557d94","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":"Space missing to the left of {.","created_at":"2015-05-19T23:05:27Z","updated_at":"2015-05-19T23:05:27Z","html_url":"https://github.com/shved/qna/pull/21#discussion_r30657375","pull_request_url":"https://api.github.com/repos/shved/qna/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/shved/qna/pulls/comments/30657375"},"html":{"href":"https://github.com/shved/qna/pull/21#discussion_r30657375"},"pull_request":{"href":"https://api.github.com/repos/shved/qna/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/shved/qna/pulls/21","id":35771028,"html_url":"https://github.com/shved/qna/pull/21","diff_url":"https://github.com/shved/qna/pull/21.diff","patch_url":"https://github.com/shved/qna/pull/21.patch","issue_url":"https://api.github.com/repos/shved/qna/issues/21","number":21,"state":"open","locked":false,"title":"Unit9","user":{"login":"shved","id":321163,"avatar_url":"https://avatars.githubusercontent.com/u/321163?v=3","gravatar_id":"","url":"https://api.github.com/users/shved","html_url":"https://github.com/shved","followers_url":"https://api.github.com/users/shved/followers","following_url":"https://api.github.com/users/shved/following{/other_user}","gists_url":"https://api.github.com/users/shved/gists{/gist_id}","starred_url":"https://api.github.com/users/shved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shved/subscriptions","organizations_url":"https://api.github.com/users/shved/orgs","repos_url":"https://api.github.com/users/shved/repos","events_url":"https://api.github.com/users/shved/events{/privacy}","received_events_url":"https://api.github.com/users/shved/received_events","type":"User","site_admin":false},"body":"Голосования сделал полностью через concerns, и включил их код в вопросы и ответы. Для работы через json использовал jbuilder и skim. ","created_at":"2015-05-19T20:26:34Z","updated_at":"2015-05-19T23:05:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6acda7164c64d4861bf15069d4efed9b3f2e4562","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shved/qna/pulls/21/commits","review_comments_url":"https://api.github.com/repos/shved/qna/pulls/21/comments","review_comment_url":"https://api.github.com/repos/shved/qna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shved/qna/issues/21/comments","statuses_url":"https://api.github.com/repos/shved/qna/statuses/caaa787fede4196b69fa25ce86d580265b557d94","head":{"label":"shved:unit9","ref":"unit9","sha":"caaa787fede4196b69fa25ce86d580265b557d94","user":{"login":"shved","id":321163,"avatar_url":"https://avatars.githubusercontent.com/u/321163?v=3","gravatar_id":"","url":"https://api.github.com/users/shved","html_url":"https://github.com/shved","followers_url":"https://api.github.com/users/shved/followers","following_url":"https://api.github.com/users/shved/following{/other_user}","gists_url":"https://api.github.com/users/shved/gists{/gist_id}","starred_url":"https://api.github.com/users/shved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shved/subscriptions","organizations_url":"https://api.github.com/users/shved/orgs","repos_url":"https://api.github.com/users/shved/repos","events_url":"https://api.github.com/users/shved/events{/privacy}","received_events_url":"https://api.github.com/users/shved/received_events","type":"User","site_admin":false},"repo":{"id":31972290,"name":"qna","full_name":"shved/qna","owner":{"login":"shved","id":321163,"avatar_url":"https://avatars.githubusercontent.com/u/321163?v=3","gravatar_id":"","url":"https://api.github.com/users/shved","html_url":"https://github.com/shved","followers_url":"https://api.github.com/users/shved/followers","following_url":"https://api.github.com/users/shved/following{/other_user}","gists_url":"https://api.github.com/users/shved/gists{/gist_id}","starred_url":"https://api.github.com/users/shved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shved/subscriptions","organizations_url":"https://api.github.com/users/shved/orgs","repos_url":"https://api.github.com/users/shved/repos","events_url":"https://api.github.com/users/shved/events{/privacy}","received_events_url":"https://api.github.com/users/shved/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shved/qna","description":"Учебный проект Thinknetica","fork":false,"url":"https://api.github.com/repos/shved/qna","forks_url":"https://api.github.com/repos/shved/qna/forks","keys_url":"https://api.github.com/repos/shved/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shved/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shved/qna/teams","hooks_url":"https://api.github.com/repos/shved/qna/hooks","issue_events_url":"https://api.github.com/repos/shved/qna/issues/events{/number}","events_url":"https://api.github.com/repos/shved/qna/events","assignees_url":"https://api.github.com/repos/shved/qna/assignees{/user}","branches_url":"https://api.github.com/repos/shved/qna/branches{/branch}","tags_url":"https://api.github.com/repos/shved/qna/tags","blobs_url":"https://api.github.com/repos/shved/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shved/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shved/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/shved/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shved/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/shved/qna/languages","stargazers_url":"https://api.github.com/repos/shved/qna/stargazers","contributors_url":"https://api.github.com/repos/shved/qna/contributors","subscribers_url":"https://api.github.com/repos/shved/qna/subscribers","subscription_url":"https://api.github.com/repos/shved/qna/subscription","commits_url":"https://api.github.com/repos/shved/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/shved/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/shved/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/shved/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/shved/qna/contents/{+path}","compare_url":"https://api.github.com/repos/shved/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shved/qna/merges","archive_url":"https://api.github.com/repos/shved/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shved/qna/downloads","issues_url":"https://api.github.com/repos/shved/qna/issues{/number}","pulls_url":"https://api.github.com/repos/shved/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/shved/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/shved/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shved/qna/labels{/name}","releases_url":"https://api.github.com/repos/shved/qna/releases{/id}","created_at":"2015-03-10T17:44:42Z","updated_at":"2015-04-24T08:18:52Z","pushed_at":"2015-05-19T23:05:20Z","git_url":"git://github.com/shved/qna.git","ssh_url":"git@github.com:shved/qna.git","clone_url":"https://github.com/shved/qna.git","svn_url":"https://github.com/shved/qna","homepage":null,"size":724,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"base":{"label":"shved:master","ref":"master","sha":"d0070e3c35b1b7a5c78c02fc9931e819885eefd4","user":{"login":"shved","id":321163,"avatar_url":"https://avatars.githubusercontent.com/u/321163?v=3","gravatar_id":"","url":"https://api.github.com/users/shved","html_url":"https://github.com/shved","followers_url":"https://api.github.com/users/shved/followers","following_url":"https://api.github.com/users/shved/following{/other_user}","gists_url":"https://api.github.com/users/shved/gists{/gist_id}","starred_url":"https://api.github.com/users/shved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shved/subscriptions","organizations_url":"https://api.github.com/users/shved/orgs","repos_url":"https://api.github.com/users/shved/repos","events_url":"https://api.github.com/users/shved/events{/privacy}","received_events_url":"https://api.github.com/users/shved/received_events","type":"User","site_admin":false},"repo":{"id":31972290,"name":"qna","full_name":"shved/qna","owner":{"login":"shved","id":321163,"avatar_url":"https://avatars.githubusercontent.com/u/321163?v=3","gravatar_id":"","url":"https://api.github.com/users/shved","html_url":"https://github.com/shved","followers_url":"https://api.github.com/users/shved/followers","following_url":"https://api.github.com/users/shved/following{/other_user}","gists_url":"https://api.github.com/users/shved/gists{/gist_id}","starred_url":"https://api.github.com/users/shved/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shved/subscriptions","organizations_url":"https://api.github.com/users/shved/orgs","repos_url":"https://api.github.com/users/shved/repos","events_url":"https://api.github.com/users/shved/events{/privacy}","received_events_url":"https://api.github.com/users/shved/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shved/qna","description":"Учебный проект Thinknetica","fork":false,"url":"https://api.github.com/repos/shved/qna","forks_url":"https://api.github.com/repos/shved/qna/forks","keys_url":"https://api.github.com/repos/shved/qna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shved/qna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shved/qna/teams","hooks_url":"https://api.github.com/repos/shved/qna/hooks","issue_events_url":"https://api.github.com/repos/shved/qna/issues/events{/number}","events_url":"https://api.github.com/repos/shved/qna/events","assignees_url":"https://api.github.com/repos/shved/qna/assignees{/user}","branches_url":"https://api.github.com/repos/shved/qna/branches{/branch}","tags_url":"https://api.github.com/repos/shved/qna/tags","blobs_url":"https://api.github.com/repos/shved/qna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shved/qna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shved/qna/git/refs{/sha}","trees_url":"https://api.github.com/repos/shved/qna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shved/qna/statuses/{sha}","languages_url":"https://api.github.com/repos/shved/qna/languages","stargazers_url":"https://api.github.com/repos/shved/qna/stargazers","contributors_url":"https://api.github.com/repos/shved/qna/contributors","subscribers_url":"https://api.github.com/repos/shved/qna/subscribers","subscription_url":"https://api.github.com/repos/shved/qna/subscription","commits_url":"https://api.github.com/repos/shved/qna/commits{/sha}","git_commits_url":"https://api.github.com/repos/shved/qna/git/commits{/sha}","comments_url":"https://api.github.com/repos/shved/qna/comments{/number}","issue_comment_url":"https://api.github.com/repos/shved/qna/issues/comments{/number}","contents_url":"https://api.github.com/repos/shved/qna/contents/{+path}","compare_url":"https://api.github.com/repos/shved/qna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shved/qna/merges","archive_url":"https://api.github.com/repos/shved/qna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shved/qna/downloads","issues_url":"https://api.github.com/repos/shved/qna/issues{/number}","pulls_url":"https://api.github.com/repos/shved/qna/pulls{/number}","milestones_url":"https://api.github.com/repos/shved/qna/milestones{/number}","notifications_url":"https://api.github.com/repos/shved/qna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shved/qna/labels{/name}","releases_url":"https://api.github.com/repos/shved/qna/releases{/id}","created_at":"2015-03-10T17:44:42Z","updated_at":"2015-04-24T08:18:52Z","pushed_at":"2015-05-19T23:05:20Z","git_url":"git://github.com/shved/qna.git","ssh_url":"git@github.com:shved/qna.git","clone_url":"https://github.com/shved/qna.git","svn_url":"https://github.com/shved/qna","homepage":null,"size":724,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":15,"forks":0,"open_issues":15,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shved/qna/pulls/21"},"html":{"href":"https://github.com/shved/qna/pull/21"},"issue":{"href":"https://api.github.com/repos/shved/qna/issues/21"},"comments":{"href":"https://api.github.com/repos/shved/qna/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/shved/qna/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/shved/qna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shved/qna/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/shved/qna/statuses/caaa787fede4196b69fa25ce86d580265b557d94"}}}}