{"action":"created","comment":{"url":"https://api.github.com/repos/spree/spree/pulls/comments/32575966","id":32575966,"diff_hunk":"@@ -0,0 +1,63 @@\n+module Spree\n+  class OrderMerge\n+    attr_accessor :destination, :source\n+\n+    def initialize(destination, source, user = nil)\n+      @destination = destination\n+      @source = source\n+      merge!(user)\n+    end\n+\n+    def merge!(user = nil)\n+      source.line_items.each do |other_order_line_item|\n+        next unless other_order_line_item.currency == destination.currency\n+\n+        # Compare the line items of the other order with mine.\n+        # Make sure you allow any extensions to chime in on whether or\n+        # not the extension-specific parts of the line item match\n+        current_line_item = destination.line_items.detect { |my_li|\n+          my_li.variant == other_order_line_item.variant &&\n+            destination.line_item_comparison_hooks.all? { |hook|\n+              destination.send(hook, my_li, other_order_line_item.serializable_hash)\n+            }\n+        }\n+\n+        handle_merge(current_line_item, other_order_line_item)\n+      end\n+\n+","path":"core/app/models/spree/order_merge.rb","position":28,"original_position":28,"commit_id":"7faa3764318b0edf9d37102ecc8c1eb7ca84ab1d","original_commit_id":"7faa3764318b0edf9d37102ecc8c1eb7ca84ab1d","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":"Extra blank line detected.","created_at":"2015-06-16T21:57:00Z","updated_at":"2015-06-16T21:57:00Z","html_url":"https://github.com/spree/spree/pull/6493#discussion_r32575966","pull_request_url":"https://api.github.com/repos/spree/spree/pulls/6493","_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/32575966"},"html":{"href":"https://github.com/spree/spree/pull/6493#discussion_r32575966"},"pull_request":{"href":"https://api.github.com/repos/spree/spree/pulls/6493"}}},"pull_request":{"url":"https://api.github.com/repos/spree/spree/pulls/6493","id":37846216,"html_url":"https://github.com/spree/spree/pull/6493","diff_url":"https://github.com/spree/spree/pull/6493.diff","patch_url":"https://github.com/spree/spree/pull/6493.patch","issue_url":"https://api.github.com/repos/spree/spree/issues/6493","number":6493,"state":"open","locked":false,"title":"Refactor order.merge! to Spree::OrderMerge","user":{"login":"darbs","id":1442142,"avatar_url":"https://avatars.githubusercontent.com/u/1442142?v=3","gravatar_id":"","url":"https://api.github.com/users/darbs","html_url":"https://github.com/darbs","followers_url":"https://api.github.com/users/darbs/followers","following_url":"https://api.github.com/users/darbs/following{/other_user}","gists_url":"https://api.github.com/users/darbs/gists{/gist_id}","starred_url":"https://api.github.com/users/darbs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darbs/subscriptions","organizations_url":"https://api.github.com/users/darbs/orgs","repos_url":"https://api.github.com/users/darbs/repos","events_url":"https://api.github.com/users/darbs/events{/privacy}","received_events_url":"https://api.github.com/users/darbs/received_events","type":"User","site_admin":false},"body":"This creates a new class that handles merging different orders. Currently an invalid order\r\nis merged with a valid one then the entire merge fails. This is is frequently seen when a\r\nnon-logged in user creates an order with valid line_items then logs in with a previous order\r\n that has now invalid line_items. E.g. Variant is deleted, combined quantity > available, etc.\r\n This resolves that by silently merging and appending the appropriate errors to the destination\r\n order.\r\n\r\nThis should resolve #5717, #5976 as well as any invalid line_item merges.","created_at":"2015-06-16T21:56:53Z","updated_at":"2015-06-16T21:57:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1c4f0526cd869b90cf4f3acda15260364e6e756","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spree/spree/pulls/6493/commits","review_comments_url":"https://api.github.com/repos/spree/spree/pulls/6493/comments","review_comment_url":"https://api.github.com/repos/spree/spree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spree/spree/issues/6493/comments","statuses_url":"https://api.github.com/repos/spree/spree/statuses/7faa3764318b0edf9d37102ecc8c1eb7ca84ab1d","head":{"label":"pervino:master","ref":"master","sha":"7faa3764318b0edf9d37102ecc8c1eb7ca84ab1d","user":{"login":"pervino","id":12450484,"avatar_url":"https://avatars.githubusercontent.com/u/12450484?v=3","gravatar_id":"","url":"https://api.github.com/users/pervino","html_url":"https://github.com/pervino","followers_url":"https://api.github.com/users/pervino/followers","following_url":"https://api.github.com/users/pervino/following{/other_user}","gists_url":"https://api.github.com/users/pervino/gists{/gist_id}","starred_url":"https://api.github.com/users/pervino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pervino/subscriptions","organizations_url":"https://api.github.com/users/pervino/orgs","repos_url":"https://api.github.com/users/pervino/repos","events_url":"https://api.github.com/users/pervino/events{/privacy}","received_events_url":"https://api.github.com/users/pervino/received_events","type":"Organization","site_admin":false},"repo":{"id":37550031,"name":"spree","full_name":"pervino/spree","owner":{"login":"pervino","id":12450484,"avatar_url":"https://avatars.githubusercontent.com/u/12450484?v=3","gravatar_id":"","url":"https://api.github.com/users/pervino","html_url":"https://github.com/pervino","followers_url":"https://api.github.com/users/pervino/followers","following_url":"https://api.github.com/users/pervino/following{/other_user}","gists_url":"https://api.github.com/users/pervino/gists{/gist_id}","starred_url":"https://api.github.com/users/pervino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pervino/subscriptions","organizations_url":"https://api.github.com/users/pervino/orgs","repos_url":"https://api.github.com/users/pervino/repos","events_url":"https://api.github.com/users/pervino/events{/privacy}","received_events_url":"https://api.github.com/users/pervino/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pervino/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/pervino/spree","forks_url":"https://api.github.com/repos/pervino/spree/forks","keys_url":"https://api.github.com/repos/pervino/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pervino/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pervino/spree/teams","hooks_url":"https://api.github.com/repos/pervino/spree/hooks","issue_events_url":"https://api.github.com/repos/pervino/spree/issues/events{/number}","events_url":"https://api.github.com/repos/pervino/spree/events","assignees_url":"https://api.github.com/repos/pervino/spree/assignees{/user}","branches_url":"https://api.github.com/repos/pervino/spree/branches{/branch}","tags_url":"https://api.github.com/repos/pervino/spree/tags","blobs_url":"https://api.github.com/repos/pervino/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pervino/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pervino/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/pervino/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pervino/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/pervino/spree/languages","stargazers_url":"https://api.github.com/repos/pervino/spree/stargazers","contributors_url":"https://api.github.com/repos/pervino/spree/contributors","subscribers_url":"https://api.github.com/repos/pervino/spree/subscribers","subscription_url":"https://api.github.com/repos/pervino/spree/subscription","commits_url":"https://api.github.com/repos/pervino/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/pervino/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/pervino/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/pervino/spree/issues/comments{/number}","contents_url":"https://api.github.com/repos/pervino/spree/contents/{+path}","compare_url":"https://api.github.com/repos/pervino/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pervino/spree/merges","archive_url":"https://api.github.com/repos/pervino/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pervino/spree/downloads","issues_url":"https://api.github.com/repos/pervino/spree/issues{/number}","pulls_url":"https://api.github.com/repos/pervino/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/pervino/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/pervino/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pervino/spree/labels{/name}","releases_url":"https://api.github.com/repos/pervino/spree/releases{/id}","created_at":"2015-06-16T19:00:42Z","updated_at":"2015-06-16T19:00:49Z","pushed_at":"2015-06-16T21:49:18Z","git_url":"git://github.com/pervino/spree.git","ssh_url":"git@github.com:pervino/spree.git","clone_url":"https://github.com/pervino/spree.git","svn_url":"https://github.com/pervino/spree","homepage":"http://spreecommerce.com","size":135416,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"spree:master","ref":"master","sha":"964cf6bd876d5895f273fa893ce0c6aa90667b8f","user":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"repo":{"id":3314,"name":"spree","full_name":"spree/spree","owner":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spree/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":false,"url":"https://api.github.com/repos/spree/spree","forks_url":"https://api.github.com/repos/spree/spree/forks","keys_url":"https://api.github.com/repos/spree/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spree/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spree/spree/teams","hooks_url":"https://api.github.com/repos/spree/spree/hooks","issue_events_url":"https://api.github.com/repos/spree/spree/issues/events{/number}","events_url":"https://api.github.com/repos/spree/spree/events","assignees_url":"https://api.github.com/repos/spree/spree/assignees{/user}","branches_url":"https://api.github.com/repos/spree/spree/branches{/branch}","tags_url":"https://api.github.com/repos/spree/spree/tags","blobs_url":"https://api.github.com/repos/spree/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spree/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spree/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/spree/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spree/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/spree/spree/languages","stargazers_url":"https://api.github.com/repos/spree/spree/stargazers","contributors_url":"https://api.github.com/repos/spree/spree/contributors","subscribers_url":"https://api.github.com/repos/spree/spree/subscribers","subscription_url":"https://api.github.com/repos/spree/spree/subscription","commits_url":"https://api.github.com/repos/spree/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/spree/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/spree/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/spree/spree/issues/comments{/number}","contents_url":"https://api.github.com/repos/spree/spree/contents/{+path}","compare_url":"https://api.github.com/repos/spree/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spree/spree/merges","archive_url":"https://api.github.com/repos/spree/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spree/spree/downloads","issues_url":"https://api.github.com/repos/spree/spree/issues{/number}","pulls_url":"https://api.github.com/repos/spree/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/spree/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/spree/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spree/spree/labels{/name}","releases_url":"https://api.github.com/repos/spree/spree/releases{/id}","created_at":"2008-03-10T14:45:35Z","updated_at":"2015-06-16T20:41:35Z","pushed_at":"2015-06-16T21:56:53Z","git_url":"git://github.com/spree/spree.git","ssh_url":"git@github.com:spree/spree.git","clone_url":"https://github.com/spree/spree.git","svn_url":"https://github.com/spree/spree","homepage":"http://spreecommerce.com","size":135416,"stargazers_count":6432,"watchers_count":6432,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3024,"mirror_url":null,"open_issues_count":130,"forks":3024,"open_issues":130,"watchers":6432,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/6493"},"html":{"href":"https://github.com/spree/spree/pull/6493"},"issue":{"href":"https://api.github.com/repos/spree/spree/issues/6493"},"comments":{"href":"https://api.github.com/repos/spree/spree/issues/6493/comments"},"review_comments":{"href":"https://api.github.com/repos/spree/spree/pulls/6493/comments"},"review_comment":{"href":"https://api.github.com/repos/spree/spree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spree/spree/pulls/6493/commits"},"statuses":{"href":"https://api.github.com/repos/spree/spree/statuses/7faa3764318b0edf9d37102ecc8c1eb7ca84ab1d"}}}}