{"action":"created","comment":{"url":"https://api.github.com/repos/amcolling/black_thursday/pulls/comments/191978641","pull_request_review_id":124658464,"id":191978641,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MTk3ODY0MQ==","diff_hunk":"@@ -0,0 +1,179 @@\n+require_relative 'test_helper'\n+require_relative 'test_helper'\n+require_relative '../lib/sales_engine'\n+require_relative '../lib/invoice_repository'\n+require 'minitest/autorun'\n+require 'minitest/pride'\n+class InvoiceRepositoryTest < Minitest::Test\n+  def setup\n+    @engine = SalesEngine.from_csv({\n+      items: './data/items.csv',\n+      merchants: './data/merchants.csv',\n+      customers: './data/customers.csv',\n+      invoices: './data/invoices.csv',\n+      invoice_items: './data/invoice_items.csv',\n+      transactions: './data/transactions.csv'\n+    })\n+  end\n+\n+  def test_it_exists\n+    assert_instance_of InvoiceRepository, @engine.invoices\n+  end\n+\n+  def test_all_returns_all_invoices\n+    expected = @engine.invoices.all\n+\n+    assert_equal 4985, expected.length\n+  end\n+\n+  def test_find_by_id_returns_an_invoice_associated_to_the_given_id\n+    invoice_id = 3452\n+    expected = @engine.invoices.find_by_id(invoice_id)\n+\n+    assert_equal invoice_id, expected.id\n+    assert_equal 12335690, expected.merchant_id\n+    assert_equal 679, expected.customer_id\n+    assert_equal :pending, expected.status\n+\n+    invoice_id = 5000\n+    expected = @engine.invoices.find_by_id(invoice_id)\n+\n+    assert_nil expected\n+  end\n+\n+  def test_find_all_by_customer_id_returns_all_invoices_associated_with_customer\n+    customer_id = 300\n+    expected = @engine.invoices.find_all_by_customer_id(customer_id)\n+\n+    assert_equal 10, expected.length\n+\n+    customer_id = 1000\n+    expected = @engine.invoices.find_all_by_customer_id(customer_id)\n+\n+    assert_equal [], expected\n+  end\n+\n+  def test_find_all_by_merchant_id_returns_all_invoices_associated_with_id\n+    merchant_id = 12335080\n+    expected = @engine.invoices.find_all_by_merchant_id(merchant_id)\n+\n+    assert_equal 7, expected.length\n+\n+    merchant_id = 1000\n+    expected = @engine.invoices.find_all_by_merchant_id(merchant_id)\n+\n+    assert_equal [], expected\n+  end\n+\n+  def test_find_all_by_status_returns_all_invoices_associated_with_status\n+    status = :shipped\n+    expected = @engine.invoices.find_all_by_status(status)\n+\n+    assert_equal 2839, expected.length\n+\n+    status = :pending\n+    expected = @engine.invoices.find_all_by_status(status)\n+\n+    assert_equal 1473, expected.length\n+\n+    status = :sold\n+    expected = @engine.invoices.find_all_by_status(status)\n+\n+    assert_equal [], expected\n+  end\n+\n+  def test_create_creates_a_new_invoice_instance\n+    attributes = {\n+      :customer_id => 7,\n+      :merchant_id => 8,\n+      :status      => 'pending',\n+      :created_at  => Time.now,\n+      :updated_at  => Time.now,\n+    }\n+    @engine.invoices.create(attributes)\n+    expected = @engine.invoices.find_by_id(4986)\n+\n+    assert_equal 7, expected.customer_id\n+    assert_equal 8, expected.merchant_id\n+    assert_equal :pending, expected.status\n+  end\n+\n+  def test_update_updates_an_invoice\n+    attributes = {\n+      :customer_id => 7,\n+      :merchant_id => 8,\n+      :status      => :pending,\n+      :created_at  => Time.now,\n+      :updated_at  => Time.now,\n+    }\n+    @engine.invoices.create(attributes)\n+    original_time = @engine.invoices.find_by_id(4986).updated_at\n+    attributes = {\n+      status: :success\n+    }\n+    @engine.invoices.update(4986, attributes)\n+    expected = @engine.invoices.find_by_id(4986)\n+\n+    assert_equal :success, expected.status\n+    assert_equal 7, expected.customer_id\n+    assert expected.updated_at > original_time\n+  end\n+\n+  def test_update_cannot_update_id_customer_id_merchant_id_or_created_at\n+    attributes = {\n+      :customer_id => 7,\n+      :merchant_id => 8,\n+      :status      => 'pending',\n+      :created_at  => Time.now,\n+      :updated_at  => Time.now,\n+    }\n+    updated_attributes = {\n+      id: 5000,\n+      customer_id: 2,\n+      merchant_id: 3,\n+      created_at: Time.now\n+    }\n+    @engine.invoices.create(attributes)\n+    @engine.invoices.update(4986, updated_attributes)\n+    expected = @engine.invoices.find_by_id(5000)\n+\n+    assert_nil expected\n+\n+    expected = @engine.invoices.find_by_id(4986)\n+\n+    assert updated_attributes[:customer_id] != expected.customer_id\n+    assert updated_attributes[:merchant_id] != expected.customer_id\n+    assert updated_attributes[:created_at] != expected.created_at\n+  end\n+\n+  def test_update_on_unkown_invoice_does_nothing\n+    expected = @engine.invoices.update(5000, {})\n+\n+    assert_nil expected\n+  end\n+\n+  def test_delete_deletes_the_specified_invoice\n+    attributes = {\n+      :customer_id => 7,\n+      :merchant_id => 8,\n+      :status      => 'pending',\n+      :created_at  => Time.now,\n+      :updated_at  => Time.now,\n+    }\n+\n+    @engine.invoices.create(attributes)\n+\n+    assert @engine.invoices.find_by_id(4986)\n+\n+    @engine.invoices.delete(4986)\n+\n+    refute @engine.invoices.find_by_id(4986)\n+  end\n+\n+  def test_delete_on_unknown_invoice_does_nothing\n+    expected = @engine.invoices.delete(5000)\n+\n+    assert_nil expected\n+  end\n+","path":"test/invoice_repository_test.rb","position":178,"original_position":178,"commit_id":"681cba4a3d02349e3c7c6c4589a06a09ddea27f4","original_commit_id":"681cba4a3d02349e3c7c6c4589a06a09ddea27f4","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end.","created_at":"2018-05-31T03:06:00Z","updated_at":"2018-05-31T03:06:01Z","html_url":"https://github.com/amcolling/black_thursday/pull/9#discussion_r191978641","pull_request_url":"https://api.github.com/repos/amcolling/black_thursday/pulls/9","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/comments/191978641"},"html":{"href":"https://github.com/amcolling/black_thursday/pull/9#discussion_r191978641"},"pull_request":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/amcolling/black_thursday/pulls/9","id":191632226,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxNjMyMjI2","html_url":"https://github.com/amcolling/black_thursday/pull/9","diff_url":"https://github.com/amcolling/black_thursday/pull/9.diff","patch_url":"https://github.com/amcolling/black_thursday/pull/9.patch","issue_url":"https://api.github.com/repos/amcolling/black_thursday/issues/9","number":9,"state":"open","locked":false,"title":"Improves tests to better match spec harness requirements.","user":{"login":"colinwarmstrong","id":37191523,"node_id":"MDQ6VXNlcjM3MTkxNTIz","avatar_url":"https://avatars0.githubusercontent.com/u/37191523?v=4","gravatar_id":"","url":"https://api.github.com/users/colinwarmstrong","html_url":"https://github.com/colinwarmstrong","followers_url":"https://api.github.com/users/colinwarmstrong/followers","following_url":"https://api.github.com/users/colinwarmstrong/following{/other_user}","gists_url":"https://api.github.com/users/colinwarmstrong/gists{/gist_id}","starred_url":"https://api.github.com/users/colinwarmstrong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colinwarmstrong/subscriptions","organizations_url":"https://api.github.com/users/colinwarmstrong/orgs","repos_url":"https://api.github.com/users/colinwarmstrong/repos","events_url":"https://api.github.com/users/colinwarmstrong/events{/privacy}","received_events_url":"https://api.github.com/users/colinwarmstrong/received_events","type":"User","site_admin":false},"body":"Fixes some tests to better align with the spec harness requirements.","created_at":"2018-05-31T03:05:16Z","updated_at":"2018-05-31T03:06:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"000cb094e11059e0196b9468cc7a86d70ce4bbf5","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/amcolling/black_thursday/pulls/9/commits","review_comments_url":"https://api.github.com/repos/amcolling/black_thursday/pulls/9/comments","review_comment_url":"https://api.github.com/repos/amcolling/black_thursday/pulls/comments{/number}","comments_url":"https://api.github.com/repos/amcolling/black_thursday/issues/9/comments","statuses_url":"https://api.github.com/repos/amcolling/black_thursday/statuses/681cba4a3d02349e3c7c6c4589a06a09ddea27f4","head":{"label":"amcolling:colin","ref":"colin","sha":"681cba4a3d02349e3c7c6c4589a06a09ddea27f4","user":{"login":"amcolling","id":34872234,"node_id":"MDQ6VXNlcjM0ODcyMjM0","avatar_url":"https://avatars1.githubusercontent.com/u/34872234?v=4","gravatar_id":"","url":"https://api.github.com/users/amcolling","html_url":"https://github.com/amcolling","followers_url":"https://api.github.com/users/amcolling/followers","following_url":"https://api.github.com/users/amcolling/following{/other_user}","gists_url":"https://api.github.com/users/amcolling/gists{/gist_id}","starred_url":"https://api.github.com/users/amcolling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcolling/subscriptions","organizations_url":"https://api.github.com/users/amcolling/orgs","repos_url":"https://api.github.com/users/amcolling/repos","events_url":"https://api.github.com/users/amcolling/events{/privacy}","received_events_url":"https://api.github.com/users/amcolling/received_events","type":"User","site_admin":false},"repo":{"id":134900117,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ5MDAxMTc=","name":"black_thursday","full_name":"amcolling/black_thursday","owner":{"login":"amcolling","id":34872234,"node_id":"MDQ6VXNlcjM0ODcyMjM0","avatar_url":"https://avatars1.githubusercontent.com/u/34872234?v=4","gravatar_id":"","url":"https://api.github.com/users/amcolling","html_url":"https://github.com/amcolling","followers_url":"https://api.github.com/users/amcolling/followers","following_url":"https://api.github.com/users/amcolling/following{/other_user}","gists_url":"https://api.github.com/users/amcolling/gists{/gist_id}","starred_url":"https://api.github.com/users/amcolling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcolling/subscriptions","organizations_url":"https://api.github.com/users/amcolling/orgs","repos_url":"https://api.github.com/users/amcolling/repos","events_url":"https://api.github.com/users/amcolling/events{/privacy}","received_events_url":"https://api.github.com/users/amcolling/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amcolling/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/amcolling/black_thursday","forks_url":"https://api.github.com/repos/amcolling/black_thursday/forks","keys_url":"https://api.github.com/repos/amcolling/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amcolling/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amcolling/black_thursday/teams","hooks_url":"https://api.github.com/repos/amcolling/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/amcolling/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/amcolling/black_thursday/events","assignees_url":"https://api.github.com/repos/amcolling/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/amcolling/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/amcolling/black_thursday/tags","blobs_url":"https://api.github.com/repos/amcolling/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amcolling/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amcolling/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/amcolling/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amcolling/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/amcolling/black_thursday/languages","stargazers_url":"https://api.github.com/repos/amcolling/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/amcolling/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/amcolling/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/amcolling/black_thursday/subscription","commits_url":"https://api.github.com/repos/amcolling/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/amcolling/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/amcolling/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/amcolling/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/amcolling/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/amcolling/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amcolling/black_thursday/merges","archive_url":"https://api.github.com/repos/amcolling/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amcolling/black_thursday/downloads","issues_url":"https://api.github.com/repos/amcolling/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/amcolling/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/amcolling/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/amcolling/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amcolling/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/amcolling/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/amcolling/black_thursday/deployments","created_at":"2018-05-25T20:07:34Z","updated_at":"2018-05-30T23:57:16Z","pushed_at":"2018-05-31T03:05:17Z","git_url":"git://github.com/amcolling/black_thursday.git","ssh_url":"git@github.com:amcolling/black_thursday.git","clone_url":"https://github.com/amcolling/black_thursday.git","svn_url":"https://github.com/amcolling/black_thursday","homepage":null,"size":1710,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"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":1,"default_branch":"master"}},"base":{"label":"amcolling:master","ref":"master","sha":"939015939448c3910b76adce3457416032c1b1ea","user":{"login":"amcolling","id":34872234,"node_id":"MDQ6VXNlcjM0ODcyMjM0","avatar_url":"https://avatars1.githubusercontent.com/u/34872234?v=4","gravatar_id":"","url":"https://api.github.com/users/amcolling","html_url":"https://github.com/amcolling","followers_url":"https://api.github.com/users/amcolling/followers","following_url":"https://api.github.com/users/amcolling/following{/other_user}","gists_url":"https://api.github.com/users/amcolling/gists{/gist_id}","starred_url":"https://api.github.com/users/amcolling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcolling/subscriptions","organizations_url":"https://api.github.com/users/amcolling/orgs","repos_url":"https://api.github.com/users/amcolling/repos","events_url":"https://api.github.com/users/amcolling/events{/privacy}","received_events_url":"https://api.github.com/users/amcolling/received_events","type":"User","site_admin":false},"repo":{"id":134900117,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ5MDAxMTc=","name":"black_thursday","full_name":"amcolling/black_thursday","owner":{"login":"amcolling","id":34872234,"node_id":"MDQ6VXNlcjM0ODcyMjM0","avatar_url":"https://avatars1.githubusercontent.com/u/34872234?v=4","gravatar_id":"","url":"https://api.github.com/users/amcolling","html_url":"https://github.com/amcolling","followers_url":"https://api.github.com/users/amcolling/followers","following_url":"https://api.github.com/users/amcolling/following{/other_user}","gists_url":"https://api.github.com/users/amcolling/gists{/gist_id}","starred_url":"https://api.github.com/users/amcolling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amcolling/subscriptions","organizations_url":"https://api.github.com/users/amcolling/orgs","repos_url":"https://api.github.com/users/amcolling/repos","events_url":"https://api.github.com/users/amcolling/events{/privacy}","received_events_url":"https://api.github.com/users/amcolling/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amcolling/black_thursday","description":null,"fork":true,"url":"https://api.github.com/repos/amcolling/black_thursday","forks_url":"https://api.github.com/repos/amcolling/black_thursday/forks","keys_url":"https://api.github.com/repos/amcolling/black_thursday/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amcolling/black_thursday/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amcolling/black_thursday/teams","hooks_url":"https://api.github.com/repos/amcolling/black_thursday/hooks","issue_events_url":"https://api.github.com/repos/amcolling/black_thursday/issues/events{/number}","events_url":"https://api.github.com/repos/amcolling/black_thursday/events","assignees_url":"https://api.github.com/repos/amcolling/black_thursday/assignees{/user}","branches_url":"https://api.github.com/repos/amcolling/black_thursday/branches{/branch}","tags_url":"https://api.github.com/repos/amcolling/black_thursday/tags","blobs_url":"https://api.github.com/repos/amcolling/black_thursday/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amcolling/black_thursday/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amcolling/black_thursday/git/refs{/sha}","trees_url":"https://api.github.com/repos/amcolling/black_thursday/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amcolling/black_thursday/statuses/{sha}","languages_url":"https://api.github.com/repos/amcolling/black_thursday/languages","stargazers_url":"https://api.github.com/repos/amcolling/black_thursday/stargazers","contributors_url":"https://api.github.com/repos/amcolling/black_thursday/contributors","subscribers_url":"https://api.github.com/repos/amcolling/black_thursday/subscribers","subscription_url":"https://api.github.com/repos/amcolling/black_thursday/subscription","commits_url":"https://api.github.com/repos/amcolling/black_thursday/commits{/sha}","git_commits_url":"https://api.github.com/repos/amcolling/black_thursday/git/commits{/sha}","comments_url":"https://api.github.com/repos/amcolling/black_thursday/comments{/number}","issue_comment_url":"https://api.github.com/repos/amcolling/black_thursday/issues/comments{/number}","contents_url":"https://api.github.com/repos/amcolling/black_thursday/contents/{+path}","compare_url":"https://api.github.com/repos/amcolling/black_thursday/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amcolling/black_thursday/merges","archive_url":"https://api.github.com/repos/amcolling/black_thursday/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amcolling/black_thursday/downloads","issues_url":"https://api.github.com/repos/amcolling/black_thursday/issues{/number}","pulls_url":"https://api.github.com/repos/amcolling/black_thursday/pulls{/number}","milestones_url":"https://api.github.com/repos/amcolling/black_thursday/milestones{/number}","notifications_url":"https://api.github.com/repos/amcolling/black_thursday/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amcolling/black_thursday/labels{/name}","releases_url":"https://api.github.com/repos/amcolling/black_thursday/releases{/id}","deployments_url":"https://api.github.com/repos/amcolling/black_thursday/deployments","created_at":"2018-05-25T20:07:34Z","updated_at":"2018-05-30T23:57:16Z","pushed_at":"2018-05-31T03:05:17Z","git_url":"git://github.com/amcolling/black_thursday.git","ssh_url":"git@github.com:amcolling/black_thursday.git","clone_url":"https://github.com/amcolling/black_thursday.git","svn_url":"https://github.com/amcolling/black_thursday","homepage":null,"size":1710,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"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":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/9"},"html":{"href":"https://github.com/amcolling/black_thursday/pull/9"},"issue":{"href":"https://api.github.com/repos/amcolling/black_thursday/issues/9"},"comments":{"href":"https://api.github.com/repos/amcolling/black_thursday/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/amcolling/black_thursday/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/amcolling/black_thursday/statuses/681cba4a3d02349e3c7c6c4589a06a09ddea27f4"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}