{"action":"created","comment":{"url":"https://api.github.com/repos/Ada-C4/betsy/pulls/comments/49519955","id":49519955,"diff_hunk":"@@ -0,0 +1,51 @@\n+class Order < ActiveRecord::Base\n+  has_many :order_items\n+\n+  validates :status, presence: true\n+  [:email, :mailing_address, :zip, :name_on_card, :last_four, :card_exp].each do |attribute|\n+    validates attribute, presence: true, on: :update\n+  end\n+  validates :last_four, numericality: { only_integer: true }, on: :update\n+  validates :zip, length: { is: 5 }, on: :update\n+  validate :card_exp_cannot_be_in_the_past\n+\n+  # validate :still_in_stock, on: :update\n+  #\n+  # def still_in_stock\n+  #   errors.add(:stock, \"Some items have gone out of stock\") unless Order.find(cookies.signed[:order]).instock\n+  # end\n+\n+  def card_exp_cannot_be_in_the_past\n+    if card_exp.present? && card_exp < Date.today\n+      errors.add(:exp, \"Can't be in the past\")\n+    end\n+  end\n+\n+  def total(user_id)\n+    revenue = 0\n+    order_items.each do |oi|\n+      if oi.product.user.id == user_id\n+        revenue += (oi.product.price * oi.quantity)\n+      end\n+    end\n+    return revenue\n+  end\n+\n+  def instock\n+    self.order_items.enough_inventory","path":"app/models/order.rb","position":35,"original_position":35,"commit_id":"2665fcc6f309912905ad1109abfcc1428eb25387","original_commit_id":"2665fcc6f309912905ad1109abfcc1428eb25387","user":{"login":"carjug","id":10871517,"avatar_url":"https://avatars.githubusercontent.com/u/10871517?v=3","gravatar_id":"","url":"https://api.github.com/users/carjug","html_url":"https://github.com/carjug","followers_url":"https://api.github.com/users/carjug/followers","following_url":"https://api.github.com/users/carjug/following{/other_user}","gists_url":"https://api.github.com/users/carjug/gists{/gist_id}","starred_url":"https://api.github.com/users/carjug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carjug/subscriptions","organizations_url":"https://api.github.com/users/carjug/orgs","repos_url":"https://api.github.com/users/carjug/repos","events_url":"https://api.github.com/users/carjug/events{/privacy}","received_events_url":"https://api.github.com/users/carjug/received_events","type":"User","site_admin":false},"body":"Same thing here: it's good to note where this `enough_inventory` method is defined, just to make things easier on the person inheriting/reviewing your code. ","created_at":"2016-01-12T21:55:41Z","updated_at":"2016-01-12T21:55:41Z","html_url":"https://github.com/Ada-C4/betsy/pull/12#discussion_r49519955","pull_request_url":"https://api.github.com/repos/Ada-C4/betsy/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/comments/49519955"},"html":{"href":"https://github.com/Ada-C4/betsy/pull/12#discussion_r49519955"},"pull_request":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/Ada-C4/betsy/pulls/12","id":54163168,"html_url":"https://github.com/Ada-C4/betsy/pull/12","diff_url":"https://github.com/Ada-C4/betsy/pull/12.diff","patch_url":"https://github.com/Ada-C4/betsy/pull/12.patch","issue_url":"https://api.github.com/repos/Ada-C4/betsy/issues/12","number":12,"state":"open","locked":false,"title":"Betsy Complete - Team Fuzzy","user":{"login":"noglows","id":3345580,"avatar_url":"https://avatars.githubusercontent.com/u/3345580?v=3","gravatar_id":"","url":"https://api.github.com/users/noglows","html_url":"https://github.com/noglows","followers_url":"https://api.github.com/users/noglows/followers","following_url":"https://api.github.com/users/noglows/following{/other_user}","gists_url":"https://api.github.com/users/noglows/gists{/gist_id}","starred_url":"https://api.github.com/users/noglows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noglows/subscriptions","organizations_url":"https://api.github.com/users/noglows/orgs","repos_url":"https://api.github.com/users/noglows/repos","events_url":"https://api.github.com/users/noglows/events{/privacy}","received_events_url":"https://api.github.com/users/noglows/received_events","type":"User","site_admin":false},"body":"Project complete. Heroku link provided in the ReadMe file.\r\n\r\nA couple little bugs but mostly functional.","created_at":"2015-12-18T23:53:52Z","updated_at":"2016-01-12T21:55:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a154183227fe8b0e1865d77696e818a881148cc4","assignee":{"login":"lilagrc","id":7612874,"avatar_url":"https://avatars.githubusercontent.com/u/7612874?v=3","gravatar_id":"","url":"https://api.github.com/users/lilagrc","html_url":"https://github.com/lilagrc","followers_url":"https://api.github.com/users/lilagrc/followers","following_url":"https://api.github.com/users/lilagrc/following{/other_user}","gists_url":"https://api.github.com/users/lilagrc/gists{/gist_id}","starred_url":"https://api.github.com/users/lilagrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lilagrc/subscriptions","organizations_url":"https://api.github.com/users/lilagrc/orgs","repos_url":"https://api.github.com/users/lilagrc/repos","events_url":"https://api.github.com/users/lilagrc/events{/privacy}","received_events_url":"https://api.github.com/users/lilagrc/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Ada-C4/betsy/pulls/12/commits","review_comments_url":"https://api.github.com/repos/Ada-C4/betsy/pulls/12/comments","review_comment_url":"https://api.github.com/repos/Ada-C4/betsy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Ada-C4/betsy/issues/12/comments","statuses_url":"https://api.github.com/repos/Ada-C4/betsy/statuses/2665fcc6f309912905ad1109abfcc1428eb25387","head":{"label":"noglows:fuzzy/master","ref":"fuzzy/master","sha":"2665fcc6f309912905ad1109abfcc1428eb25387","user":{"login":"noglows","id":3345580,"avatar_url":"https://avatars.githubusercontent.com/u/3345580?v=3","gravatar_id":"","url":"https://api.github.com/users/noglows","html_url":"https://github.com/noglows","followers_url":"https://api.github.com/users/noglows/followers","following_url":"https://api.github.com/users/noglows/following{/other_user}","gists_url":"https://api.github.com/users/noglows/gists{/gist_id}","starred_url":"https://api.github.com/users/noglows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noglows/subscriptions","organizations_url":"https://api.github.com/users/noglows/orgs","repos_url":"https://api.github.com/users/noglows/repos","events_url":"https://api.github.com/users/noglows/events{/privacy}","received_events_url":"https://api.github.com/users/noglows/received_events","type":"User","site_admin":false},"repo":{"id":47582606,"name":"betsy","full_name":"noglows/betsy","owner":{"login":"noglows","id":3345580,"avatar_url":"https://avatars.githubusercontent.com/u/3345580?v=3","gravatar_id":"","url":"https://api.github.com/users/noglows","html_url":"https://github.com/noglows","followers_url":"https://api.github.com/users/noglows/followers","following_url":"https://api.github.com/users/noglows/following{/other_user}","gists_url":"https://api.github.com/users/noglows/gists{/gist_id}","starred_url":"https://api.github.com/users/noglows/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noglows/subscriptions","organizations_url":"https://api.github.com/users/noglows/orgs","repos_url":"https://api.github.com/users/noglows/repos","events_url":"https://api.github.com/users/noglows/events{/privacy}","received_events_url":"https://api.github.com/users/noglows/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/noglows/betsy","description":"","fork":true,"url":"https://api.github.com/repos/noglows/betsy","forks_url":"https://api.github.com/repos/noglows/betsy/forks","keys_url":"https://api.github.com/repos/noglows/betsy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/noglows/betsy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/noglows/betsy/teams","hooks_url":"https://api.github.com/repos/noglows/betsy/hooks","issue_events_url":"https://api.github.com/repos/noglows/betsy/issues/events{/number}","events_url":"https://api.github.com/repos/noglows/betsy/events","assignees_url":"https://api.github.com/repos/noglows/betsy/assignees{/user}","branches_url":"https://api.github.com/repos/noglows/betsy/branches{/branch}","tags_url":"https://api.github.com/repos/noglows/betsy/tags","blobs_url":"https://api.github.com/repos/noglows/betsy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/noglows/betsy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/noglows/betsy/git/refs{/sha}","trees_url":"https://api.github.com/repos/noglows/betsy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/noglows/betsy/statuses/{sha}","languages_url":"https://api.github.com/repos/noglows/betsy/languages","stargazers_url":"https://api.github.com/repos/noglows/betsy/stargazers","contributors_url":"https://api.github.com/repos/noglows/betsy/contributors","subscribers_url":"https://api.github.com/repos/noglows/betsy/subscribers","subscription_url":"https://api.github.com/repos/noglows/betsy/subscription","commits_url":"https://api.github.com/repos/noglows/betsy/commits{/sha}","git_commits_url":"https://api.github.com/repos/noglows/betsy/git/commits{/sha}","comments_url":"https://api.github.com/repos/noglows/betsy/comments{/number}","issue_comment_url":"https://api.github.com/repos/noglows/betsy/issues/comments{/number}","contents_url":"https://api.github.com/repos/noglows/betsy/contents/{+path}","compare_url":"https://api.github.com/repos/noglows/betsy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/noglows/betsy/merges","archive_url":"https://api.github.com/repos/noglows/betsy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/noglows/betsy/downloads","issues_url":"https://api.github.com/repos/noglows/betsy/issues{/number}","pulls_url":"https://api.github.com/repos/noglows/betsy/pulls{/number}","milestones_url":"https://api.github.com/repos/noglows/betsy/milestones{/number}","notifications_url":"https://api.github.com/repos/noglows/betsy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/noglows/betsy/labels{/name}","releases_url":"https://api.github.com/repos/noglows/betsy/releases{/id}","created_at":"2015-12-07T22:14:42Z","updated_at":"2015-12-04T19:18:12Z","pushed_at":"2015-12-18T23:51:51Z","git_url":"git://github.com/noglows/betsy.git","ssh_url":"git@github.com:noglows/betsy.git","clone_url":"https://github.com/noglows/betsy.git","svn_url":"https://github.com/noglows/betsy","homepage":null,"size":302,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Ada-C4:fuzzy/master","ref":"fuzzy/master","sha":"edf96c24fb0d41bd3e52e886264c655b6901171e","user":{"login":"Ada-C4","id":14096372,"avatar_url":"https://avatars.githubusercontent.com/u/14096372?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-C4","html_url":"https://github.com/Ada-C4","followers_url":"https://api.github.com/users/Ada-C4/followers","following_url":"https://api.github.com/users/Ada-C4/following{/other_user}","gists_url":"https://api.github.com/users/Ada-C4/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-C4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-C4/subscriptions","organizations_url":"https://api.github.com/users/Ada-C4/orgs","repos_url":"https://api.github.com/users/Ada-C4/repos","events_url":"https://api.github.com/users/Ada-C4/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-C4/received_events","type":"Organization","site_admin":false},"repo":{"id":47570026,"name":"betsy","full_name":"Ada-C4/betsy","owner":{"login":"Ada-C4","id":14096372,"avatar_url":"https://avatars.githubusercontent.com/u/14096372?v=3","gravatar_id":"","url":"https://api.github.com/users/Ada-C4","html_url":"https://github.com/Ada-C4","followers_url":"https://api.github.com/users/Ada-C4/followers","following_url":"https://api.github.com/users/Ada-C4/following{/other_user}","gists_url":"https://api.github.com/users/Ada-C4/gists{/gist_id}","starred_url":"https://api.github.com/users/Ada-C4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ada-C4/subscriptions","organizations_url":"https://api.github.com/users/Ada-C4/orgs","repos_url":"https://api.github.com/users/Ada-C4/repos","events_url":"https://api.github.com/users/Ada-C4/events{/privacy}","received_events_url":"https://api.github.com/users/Ada-C4/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Ada-C4/betsy","description":"","fork":true,"url":"https://api.github.com/repos/Ada-C4/betsy","forks_url":"https://api.github.com/repos/Ada-C4/betsy/forks","keys_url":"https://api.github.com/repos/Ada-C4/betsy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ada-C4/betsy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ada-C4/betsy/teams","hooks_url":"https://api.github.com/repos/Ada-C4/betsy/hooks","issue_events_url":"https://api.github.com/repos/Ada-C4/betsy/issues/events{/number}","events_url":"https://api.github.com/repos/Ada-C4/betsy/events","assignees_url":"https://api.github.com/repos/Ada-C4/betsy/assignees{/user}","branches_url":"https://api.github.com/repos/Ada-C4/betsy/branches{/branch}","tags_url":"https://api.github.com/repos/Ada-C4/betsy/tags","blobs_url":"https://api.github.com/repos/Ada-C4/betsy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ada-C4/betsy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ada-C4/betsy/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ada-C4/betsy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ada-C4/betsy/statuses/{sha}","languages_url":"https://api.github.com/repos/Ada-C4/betsy/languages","stargazers_url":"https://api.github.com/repos/Ada-C4/betsy/stargazers","contributors_url":"https://api.github.com/repos/Ada-C4/betsy/contributors","subscribers_url":"https://api.github.com/repos/Ada-C4/betsy/subscribers","subscription_url":"https://api.github.com/repos/Ada-C4/betsy/subscription","commits_url":"https://api.github.com/repos/Ada-C4/betsy/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ada-C4/betsy/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ada-C4/betsy/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ada-C4/betsy/issues/comments{/number}","contents_url":"https://api.github.com/repos/Ada-C4/betsy/contents/{+path}","compare_url":"https://api.github.com/repos/Ada-C4/betsy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ada-C4/betsy/merges","archive_url":"https://api.github.com/repos/Ada-C4/betsy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ada-C4/betsy/downloads","issues_url":"https://api.github.com/repos/Ada-C4/betsy/issues{/number}","pulls_url":"https://api.github.com/repos/Ada-C4/betsy/pulls{/number}","milestones_url":"https://api.github.com/repos/Ada-C4/betsy/milestones{/number}","notifications_url":"https://api.github.com/repos/Ada-C4/betsy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ada-C4/betsy/labels{/name}","releases_url":"https://api.github.com/repos/Ada-C4/betsy/releases{/id}","created_at":"2015-12-07T18:06:57Z","updated_at":"2015-12-04T19:18:12Z","pushed_at":"2015-12-21T18:06:37Z","git_url":"git://github.com/Ada-C4/betsy.git","ssh_url":"git@github.com:Ada-C4/betsy.git","clone_url":"https://github.com/Ada-C4/betsy.git","svn_url":"https://github.com/Ada-C4/betsy","homepage":null,"size":61,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/12"},"html":{"href":"https://github.com/Ada-C4/betsy/pull/12"},"issue":{"href":"https://api.github.com/repos/Ada-C4/betsy/issues/12"},"comments":{"href":"https://api.github.com/repos/Ada-C4/betsy/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Ada-C4/betsy/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/Ada-C4/betsy/statuses/2665fcc6f309912905ad1109abfcc1428eb25387"}}}}