{"action":"created","issue":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/13052","repository_url":"https://api.github.com/repos/ManageIQ/manageiq","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/13052/labels{/name}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/13052/comments","events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/13052/events","html_url":"https://github.com/ManageIQ/manageiq/pull/13052","id":194327839,"number":13052,"title":"Button class refactoring: #calculate_properties","user":{"login":"vecerek","id":5737996,"avatar_url":"https://avatars.githubusercontent.com/u/5737996?v=3","gravatar_id":"","url":"https://api.github.com/users/vecerek","html_url":"https://github.com/vecerek","followers_url":"https://api.github.com/users/vecerek/followers","following_url":"https://api.github.com/users/vecerek/following{/other_user}","gists_url":"https://api.github.com/users/vecerek/gists{/gist_id}","starred_url":"https://api.github.com/users/vecerek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vecerek/subscriptions","organizations_url":"https://api.github.com/users/vecerek/orgs","repos_url":"https://api.github.com/users/vecerek/repos","events_url":"https://api.github.com/users/vecerek/events{/privacy}","received_events_url":"https://api.github.com/users/vecerek/received_events","type":"User","site_admin":false},"labels":[{"id":110594929,"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/refactoring","name":"refactoring","color":"fbca04","default":false},{"id":182909575,"url":"https://api.github.com/repos/ManageIQ/manageiq/labels/ui","name":"ui","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":{"login":"romanblanco","id":1187051,"avatar_url":"https://avatars.githubusercontent.com/u/1187051?v=3","gravatar_id":"","url":"https://api.github.com/users/romanblanco","html_url":"https://github.com/romanblanco","followers_url":"https://api.github.com/users/romanblanco/followers","following_url":"https://api.github.com/users/romanblanco/following{/other_user}","gists_url":"https://api.github.com/users/romanblanco/gists{/gist_id}","starred_url":"https://api.github.com/users/romanblanco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanblanco/subscriptions","organizations_url":"https://api.github.com/users/romanblanco/orgs","repos_url":"https://api.github.com/users/romanblanco/repos","events_url":"https://api.github.com/users/romanblanco/events{/privacy}","received_events_url":"https://api.github.com/users/romanblanco/received_events","type":"User","site_admin":false},"assignees":[{"login":"romanblanco","id":1187051,"avatar_url":"https://avatars.githubusercontent.com/u/1187051?v=3","gravatar_id":"","url":"https://api.github.com/users/romanblanco","html_url":"https://github.com/romanblanco","followers_url":"https://api.github.com/users/romanblanco/followers","following_url":"https://api.github.com/users/romanblanco/following{/other_user}","gists_url":"https://api.github.com/users/romanblanco/gists{/gist_id}","starred_url":"https://api.github.com/users/romanblanco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/romanblanco/subscriptions","organizations_url":"https://api.github.com/users/romanblanco/orgs","repos_url":"https://api.github.com/users/romanblanco/repos","events_url":"https://api.github.com/users/romanblanco/events{/privacy}","received_events_url":"https://api.github.com/users/romanblanco/received_events","type":"User","site_admin":false},{"login":"PanSpagetka","id":9535558,"avatar_url":"https://avatars.githubusercontent.com/u/9535558?v=3","gravatar_id":"","url":"https://api.github.com/users/PanSpagetka","html_url":"https://github.com/PanSpagetka","followers_url":"https://api.github.com/users/PanSpagetka/followers","following_url":"https://api.github.com/users/PanSpagetka/following{/other_user}","gists_url":"https://api.github.com/users/PanSpagetka/gists{/gist_id}","starred_url":"https://api.github.com/users/PanSpagetka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PanSpagetka/subscriptions","organizations_url":"https://api.github.com/users/PanSpagetka/orgs","repos_url":"https://api.github.com/users/PanSpagetka/repos","events_url":"https://api.github.com/users/PanSpagetka/events{/privacy}","received_events_url":"https://api.github.com/users/PanSpagetka/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2016-12-08T12:49:34Z","updated_at":"2016-12-09T13:22:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/13052","html_url":"https://github.com/ManageIQ/manageiq/pull/13052","diff_url":"https://github.com/ManageIQ/manageiq/pull/13052.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/13052.patch"},"body":"### Refactoring #calculate_properties\r\n\r\nMany of the buttons use the following method to update their `:title` property in case of being disabled:\r\n```\r\ndef calculate_properties\t\t\r\n  super\t\t\r\n  self[:title] = @error_message if @error_message.present?\t\t\r\nend\r\n```\r\n\r\nThus, this small part of code has gradually been duplicated across many button classes. It would be much better to incorporate this step into the base method of `#calculate_properties` and adjust the existing `disabled?` methods, so the `@error_message` would be set inside of them and they would return `@error_message.present?`.\r\n\r\n---\r\n\r\n### Simplification of ServerPromote\r\n\r\nThe logic of `#disabled?` has been simplified in `ServerPromote` button class as stated below.\r\nLet the following terms be defined as:\r\n```\r\np = @record.priority\r\nA = @record.priority != 1\r\nB = @record.priority != 2\r\nC = @record.priority == 2\r\nT = (A && B) || C\r\n```\r\n\r\n| p | A | B | C | T |\r\n|---|---|---|---|---|\r\n| 1 | 0 | 1 | 0 | 0 |\r\n| 2 | 1 | 0 | 1 | 1 |\r\n| -1, 3, 4, ... | 1 | 1 | 0 | 1 |\r\n\r\nThe truth table above shows that the term is false only in case that the priority is set to `1` -> the term can be simplified to `@record.priority != 1`.\r\n\r\n---\r\nSome of the specs also had to be adjusted to reflect the changes.\r\n\r\n# Links\r\nRelated issue: #6554"},"comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments/266012478","html_url":"https://github.com/ManageIQ/manageiq/pull/13052#issuecomment-266012478","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/13052","id":266012478,"user":{"login":"miq-bot","id":7806257,"avatar_url":"https://avatars.githubusercontent.com/u/7806257?v=3","gravatar_id":"","url":"https://api.github.com/users/miq-bot","html_url":"https://github.com/miq-bot","followers_url":"https://api.github.com/users/miq-bot/followers","following_url":"https://api.github.com/users/miq-bot/following{/other_user}","gists_url":"https://api.github.com/users/miq-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/miq-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miq-bot/subscriptions","organizations_url":"https://api.github.com/users/miq-bot/orgs","repos_url":"https://api.github.com/users/miq-bot/repos","events_url":"https://api.github.com/users/miq-bot/events{/privacy}","received_events_url":"https://api.github.com/users/miq-bot/received_events","type":"User","site_admin":false},"created_at":"2016-12-09T13:22:25Z","updated_at":"2016-12-09T13:22:25Z","body":"<rubocop />Checked commits https://github.com/vecerek/manageiq/compare/2074103288e3287f04dfbd65196b6c18d97d3844~...59c30a1290d787324c98c4b994aaa2551d359e3b with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1\n54 files checked, 0 offenses detected\nEverything looks good. :cake:\n"}}
{"actor":{"display_login":"miq-bot"}}