{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/49717899","id":49717899,"diff_hunk":"@@ -76,4 +76,37 @@\n       expect(query).to match(/resource_type = 'EmsCluster'.*resource_type = 'Host'/)\n     end\n   end\n+\n+  describe \".last_created_on\" do\n+    context \"returns the last created_on date\" do\n+      def expect_last_created_on_to_eq_resource_last_created_on(resource)\n+        bottleneck_event = BottleneckEvent.create!(:resource => resource)\n+        expect(described_class.last_created_on(resource)).to eq(bottleneck_event.reload.created_on)\n+      end","path":"spec/models/bottleneck_event_spec.rb","position":10,"original_position":10,"commit_id":"f21635669a6db8b3e84d53c29562766046c661a8","original_commit_id":"f21635669a6db8b3e84d53c29562766046c661a8","user":{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},"body":"@Fryguy what do you think of this way of DRYing up this spec? I'm not sure what the consensus is around here :)","created_at":"2016-01-14T12:00:52Z","updated_at":"2016-01-14T12:00:52Z","html_url":"https://github.com/ManageIQ/manageiq/pull/6129#discussion_r49717899","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/49717899"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/6129#discussion_r49717899"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129","id":55645222,"html_url":"https://github.com/ManageIQ/manageiq/pull/6129","diff_url":"https://github.com/ManageIQ/manageiq/pull/6129.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/6129.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/6129","number":6129,"state":"open","locked":false,"title":"checks for last created BottleneckEvent failed for Hosts","user":{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},"body":"`Host` uses STI and `BottleneckEvent` uses a polymorphic relation to\r\na resource, which can be a `Host`.\r\nWhen creating a `BottleneckEvent` its resource_type is the base_class\r\nof the STI class. Like this\r\n\r\n```ruby\r\nhost = ManageIQ::Providers::Redhat::InfraManager::Host.create!(name: 'test')\r\nevent = BottleneckEvent.create!(:resource => host)\r\nevent.resource_type # => 'Host'\r\n```\r\n\r\nThis caused the check for the last created `BottleneckEvent` to fail,\r\nbecause `BottleneckEvent.last_created_on(obj)` queried on `class_name`.\r\n\r\nIt happened only for Hosts and could lead to way too many events created.\r\nNormally we would only create one, if the last one was created less\r\nthan 24hrs ago.\r\n\r\nAlso, creating a BottleneckEvent may silently fail.\r\nThis could lead to a false log message about how many events have\r\nbeen created. \r\n\r\nhttps://bugzilla.redhat.com/show_bug.cgi?id=1296113\r\n\r\n- [ ] rebased","created_at":"2016-01-11T16:37:54Z","updated_at":"2016-01-14T12:00:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2470eb2e046c968b6b8ec843415aef51c591ef1c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/6129/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/f21635669a6db8b3e84d53c29562766046c661a8","head":{"label":"durandom:bottleneck_event_generation","ref":"bottleneck_event_generation","sha":"f21635669a6db8b3e84d53c29562766046c661a8","user":{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},"repo":{"id":48989151,"name":"manageiq","full_name":"durandom/manageiq","owner":{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/durandom/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/durandom/manageiq","forks_url":"https://api.github.com/repos/durandom/manageiq/forks","keys_url":"https://api.github.com/repos/durandom/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/durandom/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/durandom/manageiq/teams","hooks_url":"https://api.github.com/repos/durandom/manageiq/hooks","issue_events_url":"https://api.github.com/repos/durandom/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/durandom/manageiq/events","assignees_url":"https://api.github.com/repos/durandom/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/durandom/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/durandom/manageiq/tags","blobs_url":"https://api.github.com/repos/durandom/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/durandom/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/durandom/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/durandom/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/durandom/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/durandom/manageiq/languages","stargazers_url":"https://api.github.com/repos/durandom/manageiq/stargazers","contributors_url":"https://api.github.com/repos/durandom/manageiq/contributors","subscribers_url":"https://api.github.com/repos/durandom/manageiq/subscribers","subscription_url":"https://api.github.com/repos/durandom/manageiq/subscription","commits_url":"https://api.github.com/repos/durandom/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/durandom/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/durandom/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/durandom/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/durandom/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/durandom/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/durandom/manageiq/merges","archive_url":"https://api.github.com/repos/durandom/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/durandom/manageiq/downloads","issues_url":"https://api.github.com/repos/durandom/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/durandom/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/durandom/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/durandom/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/durandom/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/durandom/manageiq/releases{/id}","created_at":"2016-01-04T10:05:53Z","updated_at":"2016-01-13T19:58:57Z","pushed_at":"2016-01-14T10:38:49Z","git_url":"git://github.com/durandom/manageiq.git","ssh_url":"git@github.com:durandom/manageiq.git","clone_url":"https://github.com/durandom/manageiq.git","svn_url":"https://github.com/durandom/manageiq","homepage":"manageiq.org","size":101349,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"ManageIQ:master","ref":"master","sha":"719790ec755e79836828afcc14463aa917b61bbe","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Cloud Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","created_at":"2014-06-13T02:31:26Z","updated_at":"2016-01-14T10:16:27Z","pushed_at":"2016-01-14T11:53:22Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":136077,"stargazers_count":190,"watchers_count":190,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":203,"mirror_url":null,"open_issues_count":515,"forks":203,"open_issues":515,"watchers":190,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/6129"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/6129"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/6129/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/6129/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/f21635669a6db8b3e84d53c29562766046c661a8"}}}}