{"action":"created","comment":{"url":"https://api.github.com/repos/bonobos/spree/pulls/comments/25081431","id":25081431,"diff_hunk":"@@ -57,22 +84,18 @@ def activate(payload)\n       results = actions.map do |action|\n         action.perform(payload)\n       end\n-      # If an action has been taken, report back to whatever activated this promotion.\n-      action_taken = results.include?(true)\n \n-      if action_taken\n-      # connect to the order\n-      # create the join_table entry.\n-        self.orders << order\n-        self.save\n-      end\n+      self.order_promotions.create(order: order, promotion_code: payload[:promotion_code])\n \n-      return action_taken\n+      # If an action has been taken, report back to whatever activated this promotion.\n+      return results.include?(true)","path":"core/app/models/spree/promotion.rb","position":86,"original_position":86,"commit_id":"606aa42145f9e6673ffb7a5b8c3f241a054f2bb9","original_commit_id":"d13bd56508435c4fbfab28ef63cceead2866ff24","user":{"login":"philbirt","id":208828,"avatar_url":"https://avatars.githubusercontent.com/u/208828?v=3","gravatar_id":"","url":"https://api.github.com/users/philbirt","html_url":"https://github.com/philbirt","followers_url":"https://api.github.com/users/philbirt/followers","following_url":"https://api.github.com/users/philbirt/following{/other_user}","gists_url":"https://api.github.com/users/philbirt/gists{/gist_id}","starred_url":"https://api.github.com/users/philbirt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philbirt/subscriptions","organizations_url":"https://api.github.com/users/philbirt/orgs","repos_url":"https://api.github.com/users/philbirt/repos","events_url":"https://api.github.com/users/philbirt/events{/privacy}","received_events_url":"https://api.github.com/users/philbirt/received_events","type":"User","site_admin":false},"body":"Clever, changing","created_at":"2015-02-20T16:26:51Z","updated_at":"2015-02-20T16:26:51Z","html_url":"https://github.com/bonobos/spree/pull/241#discussion_r25081431","pull_request_url":"https://api.github.com/repos/bonobos/spree/pulls/241","_links":{"self":{"href":"https://api.github.com/repos/bonobos/spree/pulls/comments/25081431"},"html":{"href":"https://github.com/bonobos/spree/pull/241#discussion_r25081431"},"pull_request":{"href":"https://api.github.com/repos/bonobos/spree/pulls/241"}}},"pull_request":{"url":"https://api.github.com/repos/bonobos/spree/pulls/241","id":29637081,"html_url":"https://github.com/bonobos/spree/pull/241","diff_url":"https://github.com/bonobos/spree/pull/241.diff","patch_url":"https://github.com/bonobos/spree/pull/241.patch","issue_url":"https://api.github.com/repos/bonobos/spree/issues/241","number":241,"state":"open","locked":false,"title":"Promotion has many codes","user":{"login":"philbirt","id":208828,"avatar_url":"https://avatars.githubusercontent.com/u/208828?v=3","gravatar_id":"","url":"https://api.github.com/users/philbirt","html_url":"https://github.com/philbirt","followers_url":"https://api.github.com/users/philbirt/followers","following_url":"https://api.github.com/users/philbirt/following{/other_user}","gists_url":"https://api.github.com/users/philbirt/gists{/gist_id}","starred_url":"https://api.github.com/users/philbirt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philbirt/subscriptions","organizations_url":"https://api.github.com/users/philbirt/orgs","repos_url":"https://api.github.com/users/philbirt/repos","events_url":"https://api.github.com/users/philbirt/events{/privacy}","received_events_url":"https://api.github.com/users/philbirt/received_events","type":"User","site_admin":false},"body":"This is still a work in progress, but wanted to get some eyes on it.\r\n\r\nFirst commit:\r\n* Initial modeling and migrations. We will need to get this out first, before all of the other bigger logical pieces. Between this commit and the other, we will need to run a rake task to migrate all the associations over so that when we do launch it, everything will be hooked up correctly. There is a migration in here to provide a clear upgrade path for other uses, but for our case a custom rake task seems more viable.\r\n\r\nSecond commit:\r\n* Usage limits and other logic will be pushed down to the child codes for every promotion. Searching in admin will use the promotion codes table. Usages of promotions will start populating the new fields on adjustments and order_promotions tables.\r\n\r\nStill WIP:\r\n* Admin panel for creating promotions\r\n  * With singular codes\r\n  * With many codes\r\n  * With no codes (site wide)\r\n* More tests around usage limit on the per-promotion level (site wide)","created_at":"2015-02-19T18:42:07Z","updated_at":"2015-02-20T16:26:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1267047c898d2429ecc0b37e1df02e6898ff6a15","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bonobos/spree/pulls/241/commits","review_comments_url":"https://api.github.com/repos/bonobos/spree/pulls/241/comments","review_comment_url":"https://api.github.com/repos/bonobos/spree/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bonobos/spree/issues/241/comments","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/606aa42145f9e6673ffb7a5b8c3f241a054f2bb9","head":{"label":"2-2-dev-multicode-promos","ref":"2-2-dev-multicode-promos","sha":"606aa42145f9e6673ffb7a5b8c3f241a054f2bb9","user":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"repo":{"id":12625383,"name":"spree","full_name":"bonobos/spree","owner":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonobos/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/bonobos/spree","forks_url":"https://api.github.com/repos/bonobos/spree/forks","keys_url":"https://api.github.com/repos/bonobos/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonobos/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonobos/spree/teams","hooks_url":"https://api.github.com/repos/bonobos/spree/hooks","issue_events_url":"https://api.github.com/repos/bonobos/spree/issues/events{/number}","events_url":"https://api.github.com/repos/bonobos/spree/events","assignees_url":"https://api.github.com/repos/bonobos/spree/assignees{/user}","branches_url":"https://api.github.com/repos/bonobos/spree/branches{/branch}","tags_url":"https://api.github.com/repos/bonobos/spree/tags","blobs_url":"https://api.github.com/repos/bonobos/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonobos/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonobos/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonobos/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/bonobos/spree/languages","stargazers_url":"https://api.github.com/repos/bonobos/spree/stargazers","contributors_url":"https://api.github.com/repos/bonobos/spree/contributors","subscribers_url":"https://api.github.com/repos/bonobos/spree/subscribers","subscription_url":"https://api.github.com/repos/bonobos/spree/subscription","commits_url":"https://api.github.com/repos/bonobos/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonobos/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonobos/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonobos/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/bonobos/spree/contents/{+path}","compare_url":"https://api.github.com/repos/bonobos/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonobos/spree/merges","archive_url":"https://api.github.com/repos/bonobos/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonobos/spree/downloads","issues_url":"https://api.github.com/repos/bonobos/spree/issues{/number}","pulls_url":"https://api.github.com/repos/bonobos/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/bonobos/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/bonobos/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonobos/spree/labels{/name}","releases_url":"https://api.github.com/repos/bonobos/spree/releases{/id}","created_at":"2013-09-05T18:28:25Z","updated_at":"2015-02-20T14:06:07Z","pushed_at":"2015-02-20T15:52:41Z","git_url":"git://github.com/bonobos/spree.git","ssh_url":"git@github.com:bonobos/spree.git","clone_url":"https://github.com/bonobos/spree.git","svn_url":"https://github.com/bonobos/spree","homepage":"http://spreecommerce.com","size":75816,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":1,"default_branch":"2-2-dev"}},"base":{"label":"2-2-dev","ref":"2-2-dev","sha":"c9d3a7d0da3acb067a3b3ee3613cfcb724ff79c2","user":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"repo":{"id":12625383,"name":"spree","full_name":"bonobos/spree","owner":{"login":"bonobos","id":78914,"avatar_url":"https://avatars.githubusercontent.com/u/78914?v=3","gravatar_id":"","url":"https://api.github.com/users/bonobos","html_url":"https://github.com/bonobos","followers_url":"https://api.github.com/users/bonobos/followers","following_url":"https://api.github.com/users/bonobos/following{/other_user}","gists_url":"https://api.github.com/users/bonobos/gists{/gist_id}","starred_url":"https://api.github.com/users/bonobos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bonobos/subscriptions","organizations_url":"https://api.github.com/users/bonobos/orgs","repos_url":"https://api.github.com/users/bonobos/repos","events_url":"https://api.github.com/users/bonobos/events{/privacy}","received_events_url":"https://api.github.com/users/bonobos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bonobos/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/bonobos/spree","forks_url":"https://api.github.com/repos/bonobos/spree/forks","keys_url":"https://api.github.com/repos/bonobos/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bonobos/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bonobos/spree/teams","hooks_url":"https://api.github.com/repos/bonobos/spree/hooks","issue_events_url":"https://api.github.com/repos/bonobos/spree/issues/events{/number}","events_url":"https://api.github.com/repos/bonobos/spree/events","assignees_url":"https://api.github.com/repos/bonobos/spree/assignees{/user}","branches_url":"https://api.github.com/repos/bonobos/spree/branches{/branch}","tags_url":"https://api.github.com/repos/bonobos/spree/tags","blobs_url":"https://api.github.com/repos/bonobos/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bonobos/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bonobos/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/bonobos/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bonobos/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/bonobos/spree/languages","stargazers_url":"https://api.github.com/repos/bonobos/spree/stargazers","contributors_url":"https://api.github.com/repos/bonobos/spree/contributors","subscribers_url":"https://api.github.com/repos/bonobos/spree/subscribers","subscription_url":"https://api.github.com/repos/bonobos/spree/subscription","commits_url":"https://api.github.com/repos/bonobos/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/bonobos/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/bonobos/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/bonobos/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/bonobos/spree/contents/{+path}","compare_url":"https://api.github.com/repos/bonobos/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bonobos/spree/merges","archive_url":"https://api.github.com/repos/bonobos/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bonobos/spree/downloads","issues_url":"https://api.github.com/repos/bonobos/spree/issues{/number}","pulls_url":"https://api.github.com/repos/bonobos/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/bonobos/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/bonobos/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bonobos/spree/labels{/name}","releases_url":"https://api.github.com/repos/bonobos/spree/releases{/id}","created_at":"2013-09-05T18:28:25Z","updated_at":"2015-02-20T14:06:07Z","pushed_at":"2015-02-20T15:52:41Z","git_url":"git://github.com/bonobos/spree.git","ssh_url":"git@github.com:bonobos/spree.git","clone_url":"https://github.com/bonobos/spree.git","svn_url":"https://github.com/bonobos/spree","homepage":"http://spreecommerce.com","size":75816,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":1,"default_branch":"2-2-dev"}},"_links":{"self":{"href":"https://api.github.com/repos/bonobos/spree/pulls/241"},"html":{"href":"https://github.com/bonobos/spree/pull/241"},"issue":{"href":"https://api.github.com/repos/bonobos/spree/issues/241"},"comments":{"href":"https://api.github.com/repos/bonobos/spree/issues/241/comments"},"review_comments":{"href":"https://api.github.com/repos/bonobos/spree/pulls/241/comments"},"review_comment":{"href":"https://api.github.com/repos/bonobos/spree/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bonobos/spree/pulls/241/commits"},"statuses":{"href":"https://api.github.com/repos/bonobos/spree/statuses/606aa42145f9e6673ffb7a5b8c3f241a054f2bb9"}}}}