{"action":"created","comment":{"url":"https://api.github.com/repos/spree/spree/pulls/comments/35930679","id":35930679,"diff_hunk":"@@ -0,0 +1,761 @@\n+require 'spec_helper'\n+\n+describe \"StoreCredit\" do\n+\n+  let(:currency) { \"TEST\" }\n+  let(:store_credit) { build(:store_credit, store_credit_attrs) }\n+  let(:store_credit_attrs) { {} }\n+\n+\n+  describe \"callbacks\" do\n+    subject { store_credit.save }\n+\n+    context \"amount used is greater than zero\" do\n+      let(:store_credit) { create(:store_credit, amount: 100, amount_used: 1) }\n+      subject { store_credit.destroy }\n+\n+      it 'can not delete the store credit' do\n+        subject\n+        expect(store_credit.reload).to eq store_credit\n+        expect(store_credit.errors[:amount_used]).to include(\"is greater than zero. Can not delete store credit\")\n+      end\n+    end\n+\n+    context \"category is a non-expiring type\" do\n+      let!(:secondary_credit_type) { create(:secondary_credit_type) }\n+      let(:store_credit) { build(:store_credit, credit_type: nil)}\n+      before { allow(store_credit.category).to receive_message_chain(:non_expiring?).and_return(true) }\n+\n+      it \"sets the credit type to non-expiring\" do\n+        subject\n+        expect(store_credit.credit_type.name).to eq secondary_credit_type.name\n+      end\n+    end\n+\n+    context \"category is an expiring type\" do\n+      before { allow(store_credit.category).to receive_message_chain(:non_expiring?).and_return(false) }\n+\n+      it \"sets the credit type to non-expiring\" do\n+        subject\n+        expect(store_credit.credit_type.name).to eq \"Expiring\"\n+      end\n+    end\n+\n+    context \"the type is set\" do\n+      let!(:secondary_credit_type) { create(:secondary_credit_type)}","path":"core/spec/models/spree/store_credit_spec.rb","position":45,"original_position":45,"commit_id":"3a0982f7fe0f755b16eb38bf5f203174ecf70323","original_commit_id":"3a0982f7fe0f755b16eb38bf5f203174ecf70323","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":"Space missing inside }.","created_at":"2015-07-30T22:52:32Z","updated_at":"2015-07-30T22:52:32Z","html_url":"https://github.com/spree/spree/pull/5917#discussion_r35930679","pull_request_url":"https://api.github.com/repos/spree/spree/pulls/5917","_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/35930679"},"html":{"href":"https://github.com/spree/spree/pull/5917#discussion_r35930679"},"pull_request":{"href":"https://api.github.com/repos/spree/spree/pulls/5917"}}},"pull_request":{"url":"https://api.github.com/repos/spree/spree/pulls/5917","id":27772029,"html_url":"https://github.com/spree/spree/pull/5917","diff_url":"https://github.com/spree/spree/pull/5917.diff","patch_url":"https://github.com/spree/spree/pull/5917.patch","issue_url":"https://api.github.com/repos/spree/spree/issues/5917","number":5917,"state":"open","locked":false,"title":"Add store credits","user":{"login":"JDutil","id":25104,"avatar_url":"https://avatars.githubusercontent.com/u/25104?v=3","gravatar_id":"","url":"https://api.github.com/users/JDutil","html_url":"https://github.com/JDutil","followers_url":"https://api.github.com/users/JDutil/followers","following_url":"https://api.github.com/users/JDutil/following{/other_user}","gists_url":"https://api.github.com/users/JDutil/gists{/gist_id}","starred_url":"https://api.github.com/users/JDutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDutil/subscriptions","organizations_url":"https://api.github.com/users/JDutil/orgs","repos_url":"https://api.github.com/users/JDutil/repos","events_url":"https://api.github.com/users/JDutil/events{/privacy}","received_events_url":"https://api.github.com/users/JDutil/received_events","type":"User","site_admin":false},"body":"This is an updated branch in favor of https://github.com/spree/spree/pull/5625\r\n\r\n- [ ] Frontend UX\r\n- [ ] Backend UX for creating credit\r\n- [ ] Backend UX for creating credit reasons\r\n- [ ] Final code review & houndci cleanup.","created_at":"2015-01-21T16:15:51Z","updated_at":"2015-07-30T22:52:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c6d1f9031d075459c163eaa9d6df7eed22ae9b24","assignee":{"login":"peterberkenbosch","id":4252,"avatar_url":"https://avatars.githubusercontent.com/u/4252?v=3","gravatar_id":"","url":"https://api.github.com/users/peterberkenbosch","html_url":"https://github.com/peterberkenbosch","followers_url":"https://api.github.com/users/peterberkenbosch/followers","following_url":"https://api.github.com/users/peterberkenbosch/following{/other_user}","gists_url":"https://api.github.com/users/peterberkenbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/peterberkenbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterberkenbosch/subscriptions","organizations_url":"https://api.github.com/users/peterberkenbosch/orgs","repos_url":"https://api.github.com/users/peterberkenbosch/repos","events_url":"https://api.github.com/users/peterberkenbosch/events{/privacy}","received_events_url":"https://api.github.com/users/peterberkenbosch/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/spree/spree/milestones/30","html_url":"https://github.com/spree/spree/milestones/v3.1.x","labels_url":"https://api.github.com/repos/spree/spree/milestones/30/labels","id":984894,"number":30,"title":"v3.1.x","description":"","creator":{"login":"JDutil","id":25104,"avatar_url":"https://avatars.githubusercontent.com/u/25104?v=3","gravatar_id":"","url":"https://api.github.com/users/JDutil","html_url":"https://github.com/JDutil","followers_url":"https://api.github.com/users/JDutil/followers","following_url":"https://api.github.com/users/JDutil/following{/other_user}","gists_url":"https://api.github.com/users/JDutil/gists{/gist_id}","starred_url":"https://api.github.com/users/JDutil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JDutil/subscriptions","organizations_url":"https://api.github.com/users/JDutil/orgs","repos_url":"https://api.github.com/users/JDutil/repos","events_url":"https://api.github.com/users/JDutil/events{/privacy}","received_events_url":"https://api.github.com/users/JDutil/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":3,"state":"open","created_at":"2015-02-18T17:53:10Z","updated_at":"2015-07-25T00:48:43Z","due_on":"2015-03-31T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/spree/spree/pulls/5917/commits","review_comments_url":"https://api.github.com/repos/spree/spree/pulls/5917/comments","review_comment_url":"https://api.github.com/repos/spree/spree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spree/spree/issues/5917/comments","statuses_url":"https://api.github.com/repos/spree/spree/statuses/3a0982f7fe0f755b16eb38bf5f203174ecf70323","head":{"label":"spree:add-store-credits","ref":"add-store-credits","sha":"3a0982f7fe0f755b16eb38bf5f203174ecf70323","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-07-30T20:27:09Z","pushed_at":"2015-07-30T22:52:11Z","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":138876,"stargazers_count":6578,"watchers_count":6578,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3095,"mirror_url":null,"open_issues_count":167,"forks":3095,"open_issues":167,"watchers":6578,"default_branch":"master"}},"base":{"label":"spree:master","ref":"master","sha":"af7617542575fc9f8e55c9e62b1394c6c0837b7a","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-07-30T20:27:09Z","pushed_at":"2015-07-30T22:52:11Z","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":138876,"stargazers_count":6578,"watchers_count":6578,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3095,"mirror_url":null,"open_issues_count":167,"forks":3095,"open_issues":167,"watchers":6578,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/5917"},"html":{"href":"https://github.com/spree/spree/pull/5917"},"issue":{"href":"https://api.github.com/repos/spree/spree/issues/5917"},"comments":{"href":"https://api.github.com/repos/spree/spree/issues/5917/comments"},"review_comments":{"href":"https://api.github.com/repos/spree/spree/pulls/5917/comments"},"review_comment":{"href":"https://api.github.com/repos/spree/spree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spree/spree/pulls/5917/commits"},"statuses":{"href":"https://api.github.com/repos/spree/spree/statuses/3a0982f7fe0f755b16eb38bf5f203174ecf70323"}}}}