{"action":"created","comment":{"url":"https://api.github.com/repos/fsek/web/pulls/comments/40646418","id":40646418,"diff_hunk":"@@ -0,0 +1,81 @@\n+require 'rails_helper'\n+\n+describe RentService do\n+  let(:user) { create(:user) }\n+  let(:council) { create(:council) }\n+  let(:other) { build(:user) }\n+  let(:rent) { build(:rent) }\n+  let(:admin) { build(:admin) }\n+  let(:overbook) { build(:rent) }\n+  let(:council_rent) { build(:rent, council: council) }\n+  let(:booked_council) { create(:rent, council: council, user: user) }\n+\n+  describe :make_reservation do\n+    it :valid_reservation do\n+      RentService.reservation(user,rent).should be_truthy\n+    end\n+\n+    it :invalid_reservation do\n+      rent.d_from = nil\n+      begin\n+        RentService.reservation(user, rent)\n+      rescue ActiveRecord::RecordInvalid => error\n+        error.message.should include(t('activerecord.errors.messages.blank', attribute: Rent.human_attribute_name(:d_from)))\n+      end\n+    end\n+  end\n+\n+  describe :overbook do\n+    before do\n+      other.save!\n+      overbook.save!\n+    end\n+\n+    it :overbook do\n+      RentService.reservation(user, council_rent).should be_truthy\n+      overbook.reload\n+      overbook.aktiv.should be_falsey\n+    end\n+\n+    it :not_overbook do\n+      begin\n+        RentService.reservation(user, rent)\n+      rescue ActiveRecord::RecordInvalid => error\n+        error.message.should include(t('rent.validation.overlap'))\n+      end\n+    end\n+\n+    it :not_overbook do\n+      booked_council.reload\n+      begin\n+        RentService.reservation(user, council_rent)\n+      rescue ActiveRecord::RecordInvalid => error\n+        error.message.should include(t('rent.validation.overlap_council'))\n+      end\n+    end\n+  end\n+\n+  describe :authorized_update do\n+    before do\n+      rent.user = user\n+      rent.save!\n+      other.save!\n+    end\n+\n+    it :valid_update do\n+      RentService.update({purpose: 'A test'}, user, rent).should be_truthy\n+      Rent.first.purpose.should eq('A test')\n+    end\n+\n+    it :invalid_update do\n+      rent.owner?(other).should be_falsey\n+      RentService.update({purpose: 'A test'}, other, rent).should be_falsey","path":"spec/services/rent_service_spec.rb","position":72,"original_position":72,"commit_id":"7277e7542175b5ae5616d6069296e9f18d8c41d0","original_commit_id":"7277e7542175b5ae5616d6069296e9f18d8c41d0","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 inside { missing.<br>Space inside } missing.","created_at":"2015-09-29T08:34:28Z","updated_at":"2015-09-29T08:34:28Z","html_url":"https://github.com/fsek/web/pull/247#discussion_r40646418","pull_request_url":"https://api.github.com/repos/fsek/web/pulls/247","_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/comments/40646418"},"html":{"href":"https://github.com/fsek/web/pull/247#discussion_r40646418"},"pull_request":{"href":"https://api.github.com/repos/fsek/web/pulls/247"}}},"pull_request":{"url":"https://api.github.com/repos/fsek/web/pulls/247","id":46249319,"html_url":"https://github.com/fsek/web/pull/247","diff_url":"https://github.com/fsek/web/pull/247.diff","patch_url":"https://github.com/fsek/web/pull/247.patch","issue_url":"https://api.github.com/repos/fsek/web/issues/247","number":247,"state":"open","locked":false,"title":"Rental system","user":{"login":"davidwessman","id":6763624,"avatar_url":"https://avatars.githubusercontent.com/u/6763624?v=3","gravatar_id":"","url":"https://api.github.com/users/davidwessman","html_url":"https://github.com/davidwessman","followers_url":"https://api.github.com/users/davidwessman/followers","following_url":"https://api.github.com/users/davidwessman/following{/other_user}","gists_url":"https://api.github.com/users/davidwessman/gists{/gist_id}","starred_url":"https://api.github.com/users/davidwessman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidwessman/subscriptions","organizations_url":"https://api.github.com/users/davidwessman/orgs","repos_url":"https://api.github.com/users/davidwessman/repos","events_url":"https://api.github.com/users/davidwessman/events{/privacy}","received_events_url":"https://api.github.com/users/davidwessman/received_events","type":"User","site_admin":false},"body":"Rewrote a lot of the code.\r\nSplit model logic into a (unfortunately large) validator and a slim service.\r\n\r\nRefactored a lot of views, added I18n for most views.","created_at":"2015-09-29T08:34:09Z","updated_at":"2015-09-29T08:34:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"653b92126d22bcf92c267f6c275c0342560d3809","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fsek/web/pulls/247/commits","review_comments_url":"https://api.github.com/repos/fsek/web/pulls/247/comments","review_comment_url":"https://api.github.com/repos/fsek/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fsek/web/issues/247/comments","statuses_url":"https://api.github.com/repos/fsek/web/statuses/7277e7542175b5ae5616d6069296e9f18d8c41d0","head":{"label":"fsek:david-bilbokning","ref":"david-bilbokning","sha":"7277e7542175b5ae5616d6069296e9f18d8c41d0","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-05-13T14:47:36Z","pushed_at":"2015-09-29T08:34:09Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":213874,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":50,"forks":2,"open_issues":50,"watchers":4,"default_branch":"master"}},"base":{"label":"fsek:master","ref":"master","sha":"5a867b543e22212e63b97b001c2ecd48304143a2","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-05-13T14:47:36Z","pushed_at":"2015-09-29T08:34:09Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":213874,"stargazers_count":4,"watchers_count":4,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":50,"forks":2,"open_issues":50,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/247"},"html":{"href":"https://github.com/fsek/web/pull/247"},"issue":{"href":"https://api.github.com/repos/fsek/web/issues/247"},"comments":{"href":"https://api.github.com/repos/fsek/web/issues/247/comments"},"review_comments":{"href":"https://api.github.com/repos/fsek/web/pulls/247/comments"},"review_comment":{"href":"https://api.github.com/repos/fsek/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fsek/web/pulls/247/commits"},"statuses":{"href":"https://api.github.com/repos/fsek/web/statuses/7277e7542175b5ae5616d6069296e9f18d8c41d0"}}}}