{"action":"created","comment":{"url":"https://api.github.com/repos/Shkrt/flashcards/pulls/comments/45510067","id":45510067,"diff_hunk":"@@ -16,21 +16,69 @@\n     expect(user_4).to be_valid\n   end\n \n-  it '.current_cards returns empty collection when there is no current deck' do\n+  it \".take_card returns card belonging to review_expired scope\" do\n     deck = create(:deck, name: 'Test', user: user)\n-    card = create(:card, original_text: 'A', translated_text: 'B', review_date: 3.days.from_now, user: user, deck: deck)\n-    expect(user.current_cards).to eq([])\n+    card = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck)\n+    expect(user.take_card).to eq(card)\n   end\n \n-  it '.current_cards returns empty collection when current deck is empty' do\n-    deck = create(:deck, name: 'Test', user: user, current: true)\n-    expect(user.current_cards).to eq([])\n+  it \".take_card returns card for later repeating session when all today's cards already reviewed\" do\n+    deck = create(:deck, name: 'Test', user: user)\n+    card = create(:card, original_text: 'A', translated_text: 'B', repeat_later: true, review_date: (3).days.from_now, user: user, deck: deck)\n+    user.review_complete\n+    expect(user.take_card).to eq(card)\n+  end\n+\n+  it \".take_card takes card from current deck, when it's not empty\" do\n+    deck_1 = create(:deck, name: 'Test', user: user, current: true)\n+    deck_2 = create(:deck, name: 'Test', user: user)\n+    card_1 = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck_1)\n+    card_2 = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck_2)\n+    expect(user.take_card).to eq(card_1)\n+  end\n+\n+  it \".take_card takes any expired card, when current deck is empty\" do\n+    deck_1 = create(:deck, name: 'Test', user: user, current: true)\n+    deck_2 = create(:deck, name: 'Test', user: user)\n+    card = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck_2)\n+    expect(user.take_card).to eq(card)\n+  end\n+\n+  it \".take_card takes any expired card, when there is no deck marked as current\" do\n+    deck_1 = create(:deck, name: 'Test', user: user)\n+    deck_2 = create(:deck, name: 'Test', user: user)\n+    card_1 = create(:card, original_text: 'A', translated_text: 'B', review_date: (3).days.from_now, user: user, deck: deck_1)\n+    card_2 = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck_2)\n+    expect(user.take_card).to eq(card_2)\n+  end\n+\n+  it \".take_card doesn't touch other users' cards\" do\n+    user_1 = create(:user, email: \"exa@mp.le\", password: \"qwerty\")\n+    deck = create(:deck, name: 'Test', user: user)\n+    deck_1 = create(:deck, name: 'Test', user: user_1)\n+    card = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user, deck: deck)\n+    card_1 = create(:card, original_text: 'A', translated_text: 'B', review_date: (-1).days.from_now, user: user_1, deck: deck_1)\n+    expect(user.take_card).to eq(card)\n+    expect(user_1.take_card).to eq(card_1)\n+  end\n+\n+  it \".take_card returns nil when review and later repeating are both complete\" do\n+    deck = create(:deck, name: 'Test', user: user)\n+    card = create(:card, original_text: 'A', translated_text: 'B', review_date: (3).days.from_now, user: user, deck: deck)\n+    expect(user.take_card).to be nil\n   end\n \n-  it '.current_cards returns cards collection when current deck is not empty' do\n-    deck = create(:deck, name: 'Test', user: user, current: true)\n-    card = create(:card, original_text: 'A', translated_text: 'B', review_date: 3.days.from_now, user: user, deck: deck)\n-    expect(user.current_cards).to include(card)\n+  it \".review_complete sets review_is_over to true when no more cards for review\" do\n+    deck = create(:deck, name: 'Test', user: user)\n+    card = create(:card, original_text: 'A', translated_text: 'B', review_date: (3).days.from_now, user: user, deck: deck)\n+    user.review_complete\n+    expect(user.review_is_over).to be true\n   end\n \n+  it \".review_complete doesn't change review_is_over when there are cards for review\" do\n+    deck = create(:deck, name: 'Test', user: user)","path":"spec/models/user_spec.rb","position":74,"original_position":74,"commit_id":"3031285736e9979c97883f2cae54d5c74f6f5c11","original_commit_id":"3031285736e9979c97883f2cae54d5c74f6f5c11","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":"Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.","created_at":"2015-11-20T19:48:19Z","updated_at":"2015-11-20T19:48:19Z","html_url":"https://github.com/Shkrt/flashcards/pull/19#discussion_r45510067","pull_request_url":"https://api.github.com/repos/Shkrt/flashcards/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/Shkrt/flashcards/pulls/comments/45510067"},"html":{"href":"https://github.com/Shkrt/flashcards/pull/19#discussion_r45510067"},"pull_request":{"href":"https://api.github.com/repos/Shkrt/flashcards/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/Shkrt/flashcards/pulls/19","id":51250932,"html_url":"https://github.com/Shkrt/flashcards/pull/19","diff_url":"https://github.com/Shkrt/flashcards/pull/19.diff","patch_url":"https://github.com/Shkrt/flashcards/pull/19.patch","issue_url":"https://api.github.com/repos/Shkrt/flashcards/issues/19","number":19,"state":"open","locked":false,"title":"checking cards without page reloading","user":{"login":"Shkrt","id":10468452,"avatar_url":"https://avatars.githubusercontent.com/u/10468452?v=3","gravatar_id":"","url":"https://api.github.com/users/Shkrt","html_url":"https://github.com/Shkrt","followers_url":"https://api.github.com/users/Shkrt/followers","following_url":"https://api.github.com/users/Shkrt/following{/other_user}","gists_url":"https://api.github.com/users/Shkrt/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkrt/subscriptions","organizations_url":"https://api.github.com/users/Shkrt/orgs","repos_url":"https://api.github.com/users/Shkrt/repos","events_url":"https://api.github.com/users/Shkrt/events{/privacy}","received_events_url":"https://api.github.com/users/Shkrt/received_events","type":"User","site_admin":false},"body":"климат пока поправил до 4.00\r\nhttps://codeclimate.com/github/Shkrt/flashcards/compare/jquery-ujs#all","created_at":"2015-11-19T17:04:54Z","updated_at":"2015-11-20T19:48:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c59cf9d8913c0c9511fcf46b92f2611cf496d7b4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shkrt/flashcards/pulls/19/commits","review_comments_url":"https://api.github.com/repos/Shkrt/flashcards/pulls/19/comments","review_comment_url":"https://api.github.com/repos/Shkrt/flashcards/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shkrt/flashcards/issues/19/comments","statuses_url":"https://api.github.com/repos/Shkrt/flashcards/statuses/3031285736e9979c97883f2cae54d5c74f6f5c11","head":{"label":"Shkrt:jquery-ujs","ref":"jquery-ujs","sha":"3031285736e9979c97883f2cae54d5c74f6f5c11","user":{"login":"Shkrt","id":10468452,"avatar_url":"https://avatars.githubusercontent.com/u/10468452?v=3","gravatar_id":"","url":"https://api.github.com/users/Shkrt","html_url":"https://github.com/Shkrt","followers_url":"https://api.github.com/users/Shkrt/followers","following_url":"https://api.github.com/users/Shkrt/following{/other_user}","gists_url":"https://api.github.com/users/Shkrt/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkrt/subscriptions","organizations_url":"https://api.github.com/users/Shkrt/orgs","repos_url":"https://api.github.com/users/Shkrt/repos","events_url":"https://api.github.com/users/Shkrt/events{/privacy}","received_events_url":"https://api.github.com/users/Shkrt/received_events","type":"User","site_admin":false},"repo":{"id":44377779,"name":"flashcards","full_name":"Shkrt/flashcards","owner":{"login":"Shkrt","id":10468452,"avatar_url":"https://avatars.githubusercontent.com/u/10468452?v=3","gravatar_id":"","url":"https://api.github.com/users/Shkrt","html_url":"https://github.com/Shkrt","followers_url":"https://api.github.com/users/Shkrt/followers","following_url":"https://api.github.com/users/Shkrt/following{/other_user}","gists_url":"https://api.github.com/users/Shkrt/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkrt/subscriptions","organizations_url":"https://api.github.com/users/Shkrt/orgs","repos_url":"https://api.github.com/users/Shkrt/repos","events_url":"https://api.github.com/users/Shkrt/events{/privacy}","received_events_url":"https://api.github.com/users/Shkrt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shkrt/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/Shkrt/flashcards","forks_url":"https://api.github.com/repos/Shkrt/flashcards/forks","keys_url":"https://api.github.com/repos/Shkrt/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shkrt/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shkrt/flashcards/teams","hooks_url":"https://api.github.com/repos/Shkrt/flashcards/hooks","issue_events_url":"https://api.github.com/repos/Shkrt/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/Shkrt/flashcards/events","assignees_url":"https://api.github.com/repos/Shkrt/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/Shkrt/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/Shkrt/flashcards/tags","blobs_url":"https://api.github.com/repos/Shkrt/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shkrt/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shkrt/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shkrt/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shkrt/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/Shkrt/flashcards/languages","stargazers_url":"https://api.github.com/repos/Shkrt/flashcards/stargazers","contributors_url":"https://api.github.com/repos/Shkrt/flashcards/contributors","subscribers_url":"https://api.github.com/repos/Shkrt/flashcards/subscribers","subscription_url":"https://api.github.com/repos/Shkrt/flashcards/subscription","commits_url":"https://api.github.com/repos/Shkrt/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shkrt/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shkrt/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shkrt/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shkrt/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/Shkrt/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shkrt/flashcards/merges","archive_url":"https://api.github.com/repos/Shkrt/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shkrt/flashcards/downloads","issues_url":"https://api.github.com/repos/Shkrt/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/Shkrt/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/Shkrt/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/Shkrt/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shkrt/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/Shkrt/flashcards/releases{/id}","created_at":"2015-10-16T10:13:22Z","updated_at":"2015-10-16T16:14:42Z","pushed_at":"2015-11-20T19:48:15Z","git_url":"git://github.com/Shkrt/flashcards.git","ssh_url":"git@github.com:Shkrt/flashcards.git","clone_url":"https://github.com/Shkrt/flashcards.git","svn_url":"https://github.com/Shkrt/flashcards","homepage":null,"size":217,"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":"Shkrt:master","ref":"master","sha":"adc67380f2535f13e3f08c4c829bf93b230fa2f3","user":{"login":"Shkrt","id":10468452,"avatar_url":"https://avatars.githubusercontent.com/u/10468452?v=3","gravatar_id":"","url":"https://api.github.com/users/Shkrt","html_url":"https://github.com/Shkrt","followers_url":"https://api.github.com/users/Shkrt/followers","following_url":"https://api.github.com/users/Shkrt/following{/other_user}","gists_url":"https://api.github.com/users/Shkrt/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkrt/subscriptions","organizations_url":"https://api.github.com/users/Shkrt/orgs","repos_url":"https://api.github.com/users/Shkrt/repos","events_url":"https://api.github.com/users/Shkrt/events{/privacy}","received_events_url":"https://api.github.com/users/Shkrt/received_events","type":"User","site_admin":false},"repo":{"id":44377779,"name":"flashcards","full_name":"Shkrt/flashcards","owner":{"login":"Shkrt","id":10468452,"avatar_url":"https://avatars.githubusercontent.com/u/10468452?v=3","gravatar_id":"","url":"https://api.github.com/users/Shkrt","html_url":"https://github.com/Shkrt","followers_url":"https://api.github.com/users/Shkrt/followers","following_url":"https://api.github.com/users/Shkrt/following{/other_user}","gists_url":"https://api.github.com/users/Shkrt/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkrt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkrt/subscriptions","organizations_url":"https://api.github.com/users/Shkrt/orgs","repos_url":"https://api.github.com/users/Shkrt/repos","events_url":"https://api.github.com/users/Shkrt/events{/privacy}","received_events_url":"https://api.github.com/users/Shkrt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shkrt/flashcards","description":"","fork":false,"url":"https://api.github.com/repos/Shkrt/flashcards","forks_url":"https://api.github.com/repos/Shkrt/flashcards/forks","keys_url":"https://api.github.com/repos/Shkrt/flashcards/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shkrt/flashcards/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shkrt/flashcards/teams","hooks_url":"https://api.github.com/repos/Shkrt/flashcards/hooks","issue_events_url":"https://api.github.com/repos/Shkrt/flashcards/issues/events{/number}","events_url":"https://api.github.com/repos/Shkrt/flashcards/events","assignees_url":"https://api.github.com/repos/Shkrt/flashcards/assignees{/user}","branches_url":"https://api.github.com/repos/Shkrt/flashcards/branches{/branch}","tags_url":"https://api.github.com/repos/Shkrt/flashcards/tags","blobs_url":"https://api.github.com/repos/Shkrt/flashcards/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shkrt/flashcards/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shkrt/flashcards/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shkrt/flashcards/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shkrt/flashcards/statuses/{sha}","languages_url":"https://api.github.com/repos/Shkrt/flashcards/languages","stargazers_url":"https://api.github.com/repos/Shkrt/flashcards/stargazers","contributors_url":"https://api.github.com/repos/Shkrt/flashcards/contributors","subscribers_url":"https://api.github.com/repos/Shkrt/flashcards/subscribers","subscription_url":"https://api.github.com/repos/Shkrt/flashcards/subscription","commits_url":"https://api.github.com/repos/Shkrt/flashcards/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shkrt/flashcards/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shkrt/flashcards/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shkrt/flashcards/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shkrt/flashcards/contents/{+path}","compare_url":"https://api.github.com/repos/Shkrt/flashcards/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shkrt/flashcards/merges","archive_url":"https://api.github.com/repos/Shkrt/flashcards/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shkrt/flashcards/downloads","issues_url":"https://api.github.com/repos/Shkrt/flashcards/issues{/number}","pulls_url":"https://api.github.com/repos/Shkrt/flashcards/pulls{/number}","milestones_url":"https://api.github.com/repos/Shkrt/flashcards/milestones{/number}","notifications_url":"https://api.github.com/repos/Shkrt/flashcards/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shkrt/flashcards/labels{/name}","releases_url":"https://api.github.com/repos/Shkrt/flashcards/releases{/id}","created_at":"2015-10-16T10:13:22Z","updated_at":"2015-10-16T16:14:42Z","pushed_at":"2015-11-20T19:48:15Z","git_url":"git://github.com/Shkrt/flashcards.git","ssh_url":"git@github.com:Shkrt/flashcards.git","clone_url":"https://github.com/Shkrt/flashcards.git","svn_url":"https://github.com/Shkrt/flashcards","homepage":null,"size":217,"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/Shkrt/flashcards/pulls/19"},"html":{"href":"https://github.com/Shkrt/flashcards/pull/19"},"issue":{"href":"https://api.github.com/repos/Shkrt/flashcards/issues/19"},"comments":{"href":"https://api.github.com/repos/Shkrt/flashcards/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/Shkrt/flashcards/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/Shkrt/flashcards/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shkrt/flashcards/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/Shkrt/flashcards/statuses/3031285736e9979c97883f2cae54d5c74f6f5c11"}}}}