{"action":"created","comment":{"url":"https://api.github.com/repos/rbndickson/bookchange/pulls/comments/53737906","id":53737906,"diff_hunk":"@@ -19,170 +18,291 @@\n \n   # shoulda matcher alone throws error due to null: false validation\n   it 'validates uniqueness of email' do\n-    User.new(password_digest: 'whatever', email: 'something', username: 'alice').save!(validate: false)\n+    User.new(password_digest: 'whatever', email: 'something', username: 'alice').\n+    save!(validate: false)\n     is_expected.to validate_uniqueness_of(:email)\n   end\n \n   it 'validates uniqueness of username' do\n-    User.new(password_digest: 'whatever', email: 'something', username: 'alice').save!(validate: false)\n+    User.new(password_digest: 'whatever', email: 'something', username: 'alice').\n+    save!(validate: false)\n     is_expected.to validate_uniqueness_of(:username)\n   end\n \n-  it { is_expected.to validate_confirmation_of(:password) }\n   it { is_expected.to validate_length_of(:password).is_at_least(8) }\n-\n-  let(:alice) { Fabricate(:user) }\n-  let(:bob) { Fabricate(:user) }\n-  let(:charlie) { Fabricate(:user) }\n-  let(:alices_book) { Fabricate(:book, owner: alice) }\n-  let(:bobs_book) { Fabricate(:book, owner: bob) }\n-  let(:charlies_book) { Fabricate(:book, owner: charlie) }\n+  it { is_expected.to validate_confirmation_of(:password) }\n \n   describe '#exchanges' do\n-    it_behaves_like 'an empty array is returned when no results' do\n-      let(:query) { alice.exchanges }\n+    let(:user) { Fabricate.build(:alice) }\n+    let(:exchange_1) { double('Exchange') }\n+    let(:exchange_2) { double('Exchange') }\n+\n+    it 'includes exchanges where the user is the initiator or responder' do\n+      allow(user).to receive(:initiated_exchanges).and_return([exchange_1])\n+      allow(user).to receive(:responded_exchanges).and_return([exchange_2])\n+      expect(user.exchanges).to match_array([exchange_1, exchange_2])\n+    end\n+  end\n+\n+  describe '#confirmed_exchanges' do\n+    let(:user) { Fabricate.build(:alice) }\n+    let(:confirmed_exchange) { double('Exchange', :confirmed? => true) }\n+    let(:unconfirmed_exchange) { double('Exchange', :confirmed? => false) }\n+\n+    it 'incudes confirmed exchanges' do\n+      allow(user).to receive(:exchanges) { [confirmed_exchange] }\n+      expect(user.confirmed_exchanges).to match_array([confirmed_exchange])\n     end\n \n-    context 'when the user has exchanges' do\n-      it 'returns all exchanges' do\n-        exchange_1 = Exchange.create(initiator: alice, responder: bob)\n-        ExchangeBook.create(user: alice, exchange: exchange_1, book: alices_book)\n-        exchange_2 = Exchange.create(initiator: charlie, responder: alice)\n-        ExchangeBook.create(user: alice, exchange: exchange_2, book: charlies_book)\n-        expect(alice.exchanges).to match_array([exchange_1, exchange_2])\n-      end\n+    it 'does not incude confirmed exchanges' do\n+      allow(user).to receive(:exchanges) { [unconfirmed_exchange] }\n+      expect(user.confirmed_exchanges).to be_empty\n+    end\n+  end\n+\n+  describe '#unconfirmed_exchanges' do\n+    let(:user) { Fabricate.build(:alice) }\n+    let(:confirmed_exchange) { double('Exchange', :confirmed? => true) }","path":"spec/models/user_spec.rb","position":76,"original_position":76,"commit_id":"49bff3f79c0f3ac7762a6281c1f4a3167d8eed6e","original_commit_id":"49bff3f79c0f3ac7762a6281c1f4a3167d8eed6e","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","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":"Use the new Ruby 1.9 hash syntax.","created_at":"2016-02-23T05:30:31Z","updated_at":"2016-02-23T05:30:31Z","html_url":"https://github.com/rbndickson/bookchange/pull/9#discussion_r53737906","pull_request_url":"https://api.github.com/repos/rbndickson/bookchange/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/comments/53737906"},"html":{"href":"https://github.com/rbndickson/bookchange/pull/9#discussion_r53737906"},"pull_request":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/rbndickson/bookchange/pulls/9","id":60290186,"html_url":"https://github.com/rbndickson/bookchange/pull/9","diff_url":"https://github.com/rbndickson/bookchange/pull/9.diff","patch_url":"https://github.com/rbndickson/bookchange/pull/9.patch","issue_url":"https://api.github.com/repos/rbndickson/bookchange/issues/9","number":9,"state":"open","locked":false,"title":"Exchange processing","user":{"login":"rbndickson","id":8252439,"avatar_url":"https://avatars.githubusercontent.com/u/8252439?v=3","gravatar_id":"","url":"https://api.github.com/users/rbndickson","html_url":"https://github.com/rbndickson","followers_url":"https://api.github.com/users/rbndickson/followers","following_url":"https://api.github.com/users/rbndickson/following{/other_user}","gists_url":"https://api.github.com/users/rbndickson/gists{/gist_id}","starred_url":"https://api.github.com/users/rbndickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbndickson/subscriptions","organizations_url":"https://api.github.com/users/rbndickson/orgs","repos_url":"https://api.github.com/users/rbndickson/repos","events_url":"https://api.github.com/users/rbndickson/events{/privacy}","received_events_url":"https://api.github.com/users/rbndickson/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-23T05:30:09Z","updated_at":"2016-02-23T05:30:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"83c7032d420f98fac9a9a280bb3bfd79d6a02908","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rbndickson/bookchange/pulls/9/commits","review_comments_url":"https://api.github.com/repos/rbndickson/bookchange/pulls/9/comments","review_comment_url":"https://api.github.com/repos/rbndickson/bookchange/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rbndickson/bookchange/issues/9/comments","statuses_url":"https://api.github.com/repos/rbndickson/bookchange/statuses/49bff3f79c0f3ac7762a6281c1f4a3167d8eed6e","head":{"label":"rbndickson:staging","ref":"staging","sha":"49bff3f79c0f3ac7762a6281c1f4a3167d8eed6e","user":{"login":"rbndickson","id":8252439,"avatar_url":"https://avatars.githubusercontent.com/u/8252439?v=3","gravatar_id":"","url":"https://api.github.com/users/rbndickson","html_url":"https://github.com/rbndickson","followers_url":"https://api.github.com/users/rbndickson/followers","following_url":"https://api.github.com/users/rbndickson/following{/other_user}","gists_url":"https://api.github.com/users/rbndickson/gists{/gist_id}","starred_url":"https://api.github.com/users/rbndickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbndickson/subscriptions","organizations_url":"https://api.github.com/users/rbndickson/orgs","repos_url":"https://api.github.com/users/rbndickson/repos","events_url":"https://api.github.com/users/rbndickson/events{/privacy}","received_events_url":"https://api.github.com/users/rbndickson/received_events","type":"User","site_admin":false},"repo":{"id":50706967,"name":"bookchange","full_name":"rbndickson/bookchange","owner":{"login":"rbndickson","id":8252439,"avatar_url":"https://avatars.githubusercontent.com/u/8252439?v=3","gravatar_id":"","url":"https://api.github.com/users/rbndickson","html_url":"https://github.com/rbndickson","followers_url":"https://api.github.com/users/rbndickson/followers","following_url":"https://api.github.com/users/rbndickson/following{/other_user}","gists_url":"https://api.github.com/users/rbndickson/gists{/gist_id}","starred_url":"https://api.github.com/users/rbndickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbndickson/subscriptions","organizations_url":"https://api.github.com/users/rbndickson/orgs","repos_url":"https://api.github.com/users/rbndickson/repos","events_url":"https://api.github.com/users/rbndickson/events{/privacy}","received_events_url":"https://api.github.com/users/rbndickson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rbndickson/bookchange","description":"","fork":false,"url":"https://api.github.com/repos/rbndickson/bookchange","forks_url":"https://api.github.com/repos/rbndickson/bookchange/forks","keys_url":"https://api.github.com/repos/rbndickson/bookchange/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rbndickson/bookchange/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rbndickson/bookchange/teams","hooks_url":"https://api.github.com/repos/rbndickson/bookchange/hooks","issue_events_url":"https://api.github.com/repos/rbndickson/bookchange/issues/events{/number}","events_url":"https://api.github.com/repos/rbndickson/bookchange/events","assignees_url":"https://api.github.com/repos/rbndickson/bookchange/assignees{/user}","branches_url":"https://api.github.com/repos/rbndickson/bookchange/branches{/branch}","tags_url":"https://api.github.com/repos/rbndickson/bookchange/tags","blobs_url":"https://api.github.com/repos/rbndickson/bookchange/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rbndickson/bookchange/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rbndickson/bookchange/git/refs{/sha}","trees_url":"https://api.github.com/repos/rbndickson/bookchange/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rbndickson/bookchange/statuses/{sha}","languages_url":"https://api.github.com/repos/rbndickson/bookchange/languages","stargazers_url":"https://api.github.com/repos/rbndickson/bookchange/stargazers","contributors_url":"https://api.github.com/repos/rbndickson/bookchange/contributors","subscribers_url":"https://api.github.com/repos/rbndickson/bookchange/subscribers","subscription_url":"https://api.github.com/repos/rbndickson/bookchange/subscription","commits_url":"https://api.github.com/repos/rbndickson/bookchange/commits{/sha}","git_commits_url":"https://api.github.com/repos/rbndickson/bookchange/git/commits{/sha}","comments_url":"https://api.github.com/repos/rbndickson/bookchange/comments{/number}","issue_comment_url":"https://api.github.com/repos/rbndickson/bookchange/issues/comments{/number}","contents_url":"https://api.github.com/repos/rbndickson/bookchange/contents/{+path}","compare_url":"https://api.github.com/repos/rbndickson/bookchange/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rbndickson/bookchange/merges","archive_url":"https://api.github.com/repos/rbndickson/bookchange/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rbndickson/bookchange/downloads","issues_url":"https://api.github.com/repos/rbndickson/bookchange/issues{/number}","pulls_url":"https://api.github.com/repos/rbndickson/bookchange/pulls{/number}","milestones_url":"https://api.github.com/repos/rbndickson/bookchange/milestones{/number}","notifications_url":"https://api.github.com/repos/rbndickson/bookchange/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rbndickson/bookchange/labels{/name}","releases_url":"https://api.github.com/repos/rbndickson/bookchange/releases{/id}","deployments_url":"https://api.github.com/repos/rbndickson/bookchange/deployments","created_at":"2016-01-30T03:31:21Z","updated_at":"2016-01-30T03:36:12Z","pushed_at":"2016-02-23T05:30:10Z","git_url":"git://github.com/rbndickson/bookchange.git","ssh_url":"git@github.com:rbndickson/bookchange.git","clone_url":"https://github.com/rbndickson/bookchange.git","svn_url":"https://github.com/rbndickson/bookchange","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rbndickson:master","ref":"master","sha":"09cbfc69f2f78d8eb52e268d656cf0fb9af1aec6","user":{"login":"rbndickson","id":8252439,"avatar_url":"https://avatars.githubusercontent.com/u/8252439?v=3","gravatar_id":"","url":"https://api.github.com/users/rbndickson","html_url":"https://github.com/rbndickson","followers_url":"https://api.github.com/users/rbndickson/followers","following_url":"https://api.github.com/users/rbndickson/following{/other_user}","gists_url":"https://api.github.com/users/rbndickson/gists{/gist_id}","starred_url":"https://api.github.com/users/rbndickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbndickson/subscriptions","organizations_url":"https://api.github.com/users/rbndickson/orgs","repos_url":"https://api.github.com/users/rbndickson/repos","events_url":"https://api.github.com/users/rbndickson/events{/privacy}","received_events_url":"https://api.github.com/users/rbndickson/received_events","type":"User","site_admin":false},"repo":{"id":50706967,"name":"bookchange","full_name":"rbndickson/bookchange","owner":{"login":"rbndickson","id":8252439,"avatar_url":"https://avatars.githubusercontent.com/u/8252439?v=3","gravatar_id":"","url":"https://api.github.com/users/rbndickson","html_url":"https://github.com/rbndickson","followers_url":"https://api.github.com/users/rbndickson/followers","following_url":"https://api.github.com/users/rbndickson/following{/other_user}","gists_url":"https://api.github.com/users/rbndickson/gists{/gist_id}","starred_url":"https://api.github.com/users/rbndickson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbndickson/subscriptions","organizations_url":"https://api.github.com/users/rbndickson/orgs","repos_url":"https://api.github.com/users/rbndickson/repos","events_url":"https://api.github.com/users/rbndickson/events{/privacy}","received_events_url":"https://api.github.com/users/rbndickson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rbndickson/bookchange","description":"","fork":false,"url":"https://api.github.com/repos/rbndickson/bookchange","forks_url":"https://api.github.com/repos/rbndickson/bookchange/forks","keys_url":"https://api.github.com/repos/rbndickson/bookchange/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rbndickson/bookchange/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rbndickson/bookchange/teams","hooks_url":"https://api.github.com/repos/rbndickson/bookchange/hooks","issue_events_url":"https://api.github.com/repos/rbndickson/bookchange/issues/events{/number}","events_url":"https://api.github.com/repos/rbndickson/bookchange/events","assignees_url":"https://api.github.com/repos/rbndickson/bookchange/assignees{/user}","branches_url":"https://api.github.com/repos/rbndickson/bookchange/branches{/branch}","tags_url":"https://api.github.com/repos/rbndickson/bookchange/tags","blobs_url":"https://api.github.com/repos/rbndickson/bookchange/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rbndickson/bookchange/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rbndickson/bookchange/git/refs{/sha}","trees_url":"https://api.github.com/repos/rbndickson/bookchange/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rbndickson/bookchange/statuses/{sha}","languages_url":"https://api.github.com/repos/rbndickson/bookchange/languages","stargazers_url":"https://api.github.com/repos/rbndickson/bookchange/stargazers","contributors_url":"https://api.github.com/repos/rbndickson/bookchange/contributors","subscribers_url":"https://api.github.com/repos/rbndickson/bookchange/subscribers","subscription_url":"https://api.github.com/repos/rbndickson/bookchange/subscription","commits_url":"https://api.github.com/repos/rbndickson/bookchange/commits{/sha}","git_commits_url":"https://api.github.com/repos/rbndickson/bookchange/git/commits{/sha}","comments_url":"https://api.github.com/repos/rbndickson/bookchange/comments{/number}","issue_comment_url":"https://api.github.com/repos/rbndickson/bookchange/issues/comments{/number}","contents_url":"https://api.github.com/repos/rbndickson/bookchange/contents/{+path}","compare_url":"https://api.github.com/repos/rbndickson/bookchange/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rbndickson/bookchange/merges","archive_url":"https://api.github.com/repos/rbndickson/bookchange/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rbndickson/bookchange/downloads","issues_url":"https://api.github.com/repos/rbndickson/bookchange/issues{/number}","pulls_url":"https://api.github.com/repos/rbndickson/bookchange/pulls{/number}","milestones_url":"https://api.github.com/repos/rbndickson/bookchange/milestones{/number}","notifications_url":"https://api.github.com/repos/rbndickson/bookchange/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rbndickson/bookchange/labels{/name}","releases_url":"https://api.github.com/repos/rbndickson/bookchange/releases{/id}","deployments_url":"https://api.github.com/repos/rbndickson/bookchange/deployments","created_at":"2016-01-30T03:31:21Z","updated_at":"2016-01-30T03:36:12Z","pushed_at":"2016-02-23T05:30:10Z","git_url":"git://github.com/rbndickson/bookchange.git","ssh_url":"git@github.com:rbndickson/bookchange.git","clone_url":"https://github.com/rbndickson/bookchange.git","svn_url":"https://github.com/rbndickson/bookchange","homepage":null,"size":225,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/9"},"html":{"href":"https://github.com/rbndickson/bookchange/pull/9"},"issue":{"href":"https://api.github.com/repos/rbndickson/bookchange/issues/9"},"comments":{"href":"https://api.github.com/repos/rbndickson/bookchange/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rbndickson/bookchange/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/rbndickson/bookchange/statuses/49bff3f79c0f3ac7762a6281c1f4a3167d8eed6e"}}}}