{"action":"created","comment":{"url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/comments/175408199","pull_request_review_id":104929671,"id":175408199,"diff_hunk":"@@ -119,6 +120,44 @@ def number_associated_models\n     [cluster, component, service].select(&:present?).length\n   end\n \n+  def validate_requested_period\n+    return unless requested_start && requested_end","path":"app/models/maintenance_window.rb","position":13,"original_position":13,"commit_id":"7671953beefbeb78c0194de1edec3ac6a2591398","original_commit_id":"7671953beefbeb78c0194de1edec3ac6a2591398","user":{"login":"bobwhitelock","id":7476523,"avatar_url":"https://avatars0.githubusercontent.com/u/7476523?v=4","gravatar_id":"","url":"https://api.github.com/users/bobwhitelock","html_url":"https://github.com/bobwhitelock","followers_url":"https://api.github.com/users/bobwhitelock/followers","following_url":"https://api.github.com/users/bobwhitelock/following{/other_user}","gists_url":"https://api.github.com/users/bobwhitelock/gists{/gist_id}","starred_url":"https://api.github.com/users/bobwhitelock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobwhitelock/subscriptions","organizations_url":"https://api.github.com/users/bobwhitelock/orgs","repos_url":"https://api.github.com/users/bobwhitelock/repos","events_url":"https://api.github.com/users/bobwhitelock/events{/privacy}","received_events_url":"https://api.github.com/users/bobwhitelock/received_events","type":"User","site_admin":false},"body":"If either (or both) of these are unset then the model will already be invalid as we validate their presence:\r\nhttps://github.com/alces-software/alces-flight-center/blob/361051bee2bd8e321e2d9ef6f26bc28099c34ca6/app/models/maintenance_window.rb#L10-L11\r\nSo I think there is no need to handle this situation in other validations apart from by making sure they do not error, which this line does, as we will need to fix these fields not being present anyway at which point this validation will run.","created_at":"2018-03-19T11:49:42Z","updated_at":"2018-03-19T11:49:42Z","html_url":"https://github.com/alces-software/alces-flight-center/pull/101#discussion_r175408199","pull_request_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/comments/175408199"},"html":{"href":"https://github.com/alces-software/alces-flight-center/pull/101#discussion_r175408199"},"pull_request":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101"}},"in_reply_to_id":174440820},"pull_request":{"url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101","id":174354202,"html_url":"https://github.com/alces-software/alces-flight-center/pull/101","diff_url":"https://github.com/alces-software/alces-flight-center/pull/101.diff","patch_url":"https://github.com/alces-software/alces-flight-center/pull/101.patch","issue_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/101","number":101,"state":"closed","locked":false,"title":"MaintenanceWindow `requested_start` and `requested_end` validations","user":{"login":"bobwhitelock","id":7476523,"avatar_url":"https://avatars0.githubusercontent.com/u/7476523?v=4","gravatar_id":"","url":"https://api.github.com/users/bobwhitelock","html_url":"https://github.com/bobwhitelock","followers_url":"https://api.github.com/users/bobwhitelock/followers","following_url":"https://api.github.com/users/bobwhitelock/following{/other_user}","gists_url":"https://api.github.com/users/bobwhitelock/gists{/gist_id}","starred_url":"https://api.github.com/users/bobwhitelock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobwhitelock/subscriptions","organizations_url":"https://api.github.com/users/bobwhitelock/orgs","repos_url":"https://api.github.com/users/bobwhitelock/repos","events_url":"https://api.github.com/users/bobwhitelock/events{/privacy}","received_events_url":"https://api.github.com/users/bobwhitelock/received_events","type":"User","site_admin":false},"body":"This PR adds various validations for the MaintenanceWindow `requested_start` and `requested_end` validations, to ensure certain invariants about these properties hold:\r\n\r\n- `requested_start` should always be before `requested_end`;\r\n\r\n- `requested_start` and `requested_end` cannot be in the past, apart from in certain 'finished' states for a MaintenanceWindow to avoid every saved MaintenanceWindow eventually becoming invalid which would likely cause us future problems.\r\n\r\nAdding these validations now became particularly important as non-admin users will soon be able to change these fields, so we want to be more robust when given bad data to make the UX better and avoid saving data which we would consider invalid.\r\n\r\nThe diff here is a bit large, but there shouldn't be anything too complex here, and some of the changes are just due to existing validation tests changing position without any actual behaviour changes.\r\n\r\nAnother step towards https://trello.com/c/k81APmbi/191-expired-maintenance-should-still-show-in-table-users-can-always-change-requested-start-and-end-date-when-confirming; based on #100.","created_at":"2018-03-12T12:34:05Z","updated_at":"2018-03-19T11:49:42Z","closed_at":"2018-03-14T12:29:41Z","merged_at":"2018-03-14T12:29:41Z","merge_commit_sha":"db3f6e117e04b341abf39f59118c341c6aadcaf9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101/commits","review_comments_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101/comments","review_comment_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/101/comments","statuses_url":"https://api.github.com/repos/alces-software/alces-flight-center/statuses/7671953beefbeb78c0194de1edec3ac6a2591398","head":{"label":"alces-software:feature/mw-start-and-end-validations","ref":"feature/mw-start-and-end-validations","sha":"7671953beefbeb78c0194de1edec3ac6a2591398","user":{"login":"alces-software","id":945288,"avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"repo":{"id":103410349,"name":"alces-flight-center","full_name":"alces-software/alces-flight-center","owner":{"login":"alces-software","id":945288,"avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alces-software/alces-flight-center","description":"Alces Flight Center cluster support and management site","fork":false,"url":"https://api.github.com/repos/alces-software/alces-flight-center","forks_url":"https://api.github.com/repos/alces-software/alces-flight-center/forks","keys_url":"https://api.github.com/repos/alces-software/alces-flight-center/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alces-software/alces-flight-center/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alces-software/alces-flight-center/teams","hooks_url":"https://api.github.com/repos/alces-software/alces-flight-center/hooks","issue_events_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/events{/number}","events_url":"https://api.github.com/repos/alces-software/alces-flight-center/events","assignees_url":"https://api.github.com/repos/alces-software/alces-flight-center/assignees{/user}","branches_url":"https://api.github.com/repos/alces-software/alces-flight-center/branches{/branch}","tags_url":"https://api.github.com/repos/alces-software/alces-flight-center/tags","blobs_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/refs{/sha}","trees_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alces-software/alces-flight-center/statuses/{sha}","languages_url":"https://api.github.com/repos/alces-software/alces-flight-center/languages","stargazers_url":"https://api.github.com/repos/alces-software/alces-flight-center/stargazers","contributors_url":"https://api.github.com/repos/alces-software/alces-flight-center/contributors","subscribers_url":"https://api.github.com/repos/alces-software/alces-flight-center/subscribers","subscription_url":"https://api.github.com/repos/alces-software/alces-flight-center/subscription","commits_url":"https://api.github.com/repos/alces-software/alces-flight-center/commits{/sha}","git_commits_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/commits{/sha}","comments_url":"https://api.github.com/repos/alces-software/alces-flight-center/comments{/number}","issue_comment_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/comments{/number}","contents_url":"https://api.github.com/repos/alces-software/alces-flight-center/contents/{+path}","compare_url":"https://api.github.com/repos/alces-software/alces-flight-center/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alces-software/alces-flight-center/merges","archive_url":"https://api.github.com/repos/alces-software/alces-flight-center/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alces-software/alces-flight-center/downloads","issues_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues{/number}","pulls_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls{/number}","milestones_url":"https://api.github.com/repos/alces-software/alces-flight-center/milestones{/number}","notifications_url":"https://api.github.com/repos/alces-software/alces-flight-center/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alces-software/alces-flight-center/labels{/name}","releases_url":"https://api.github.com/repos/alces-software/alces-flight-center/releases{/id}","deployments_url":"https://api.github.com/repos/alces-software/alces-flight-center/deployments","created_at":"2017-09-13T14:30:59Z","updated_at":"2018-03-15T11:47:00Z","pushed_at":"2018-03-19T11:46:11Z","git_url":"git://github.com/alces-software/alces-flight-center.git","ssh_url":"git@github.com:alces-software/alces-flight-center.git","clone_url":"https://github.com/alces-software/alces-flight-center.git","svn_url":"https://github.com/alces-software/alces-flight-center","homepage":"https://center.alces-flight.com/","size":9006,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":18,"watchers":1,"default_branch":"develop"}},"base":{"label":"alces-software:develop","ref":"develop","sha":"7d5bbc9a90be065055ca199a8692425a433264e4","user":{"login":"alces-software","id":945288,"avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"repo":{"id":103410349,"name":"alces-flight-center","full_name":"alces-software/alces-flight-center","owner":{"login":"alces-software","id":945288,"avatar_url":"https://avatars0.githubusercontent.com/u/945288?v=4","gravatar_id":"","url":"https://api.github.com/users/alces-software","html_url":"https://github.com/alces-software","followers_url":"https://api.github.com/users/alces-software/followers","following_url":"https://api.github.com/users/alces-software/following{/other_user}","gists_url":"https://api.github.com/users/alces-software/gists{/gist_id}","starred_url":"https://api.github.com/users/alces-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alces-software/subscriptions","organizations_url":"https://api.github.com/users/alces-software/orgs","repos_url":"https://api.github.com/users/alces-software/repos","events_url":"https://api.github.com/users/alces-software/events{/privacy}","received_events_url":"https://api.github.com/users/alces-software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alces-software/alces-flight-center","description":"Alces Flight Center cluster support and management site","fork":false,"url":"https://api.github.com/repos/alces-software/alces-flight-center","forks_url":"https://api.github.com/repos/alces-software/alces-flight-center/forks","keys_url":"https://api.github.com/repos/alces-software/alces-flight-center/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alces-software/alces-flight-center/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alces-software/alces-flight-center/teams","hooks_url":"https://api.github.com/repos/alces-software/alces-flight-center/hooks","issue_events_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/events{/number}","events_url":"https://api.github.com/repos/alces-software/alces-flight-center/events","assignees_url":"https://api.github.com/repos/alces-software/alces-flight-center/assignees{/user}","branches_url":"https://api.github.com/repos/alces-software/alces-flight-center/branches{/branch}","tags_url":"https://api.github.com/repos/alces-software/alces-flight-center/tags","blobs_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/refs{/sha}","trees_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alces-software/alces-flight-center/statuses/{sha}","languages_url":"https://api.github.com/repos/alces-software/alces-flight-center/languages","stargazers_url":"https://api.github.com/repos/alces-software/alces-flight-center/stargazers","contributors_url":"https://api.github.com/repos/alces-software/alces-flight-center/contributors","subscribers_url":"https://api.github.com/repos/alces-software/alces-flight-center/subscribers","subscription_url":"https://api.github.com/repos/alces-software/alces-flight-center/subscription","commits_url":"https://api.github.com/repos/alces-software/alces-flight-center/commits{/sha}","git_commits_url":"https://api.github.com/repos/alces-software/alces-flight-center/git/commits{/sha}","comments_url":"https://api.github.com/repos/alces-software/alces-flight-center/comments{/number}","issue_comment_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues/comments{/number}","contents_url":"https://api.github.com/repos/alces-software/alces-flight-center/contents/{+path}","compare_url":"https://api.github.com/repos/alces-software/alces-flight-center/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alces-software/alces-flight-center/merges","archive_url":"https://api.github.com/repos/alces-software/alces-flight-center/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alces-software/alces-flight-center/downloads","issues_url":"https://api.github.com/repos/alces-software/alces-flight-center/issues{/number}","pulls_url":"https://api.github.com/repos/alces-software/alces-flight-center/pulls{/number}","milestones_url":"https://api.github.com/repos/alces-software/alces-flight-center/milestones{/number}","notifications_url":"https://api.github.com/repos/alces-software/alces-flight-center/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alces-software/alces-flight-center/labels{/name}","releases_url":"https://api.github.com/repos/alces-software/alces-flight-center/releases{/id}","deployments_url":"https://api.github.com/repos/alces-software/alces-flight-center/deployments","created_at":"2017-09-13T14:30:59Z","updated_at":"2018-03-15T11:47:00Z","pushed_at":"2018-03-19T11:46:11Z","git_url":"git://github.com/alces-software/alces-flight-center.git","ssh_url":"git@github.com:alces-software/alces-flight-center.git","clone_url":"https://github.com/alces-software/alces-flight-center.git","svn_url":"https://github.com/alces-software/alces-flight-center","homepage":"https://center.alces-flight.com/","size":9006,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":18,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101"},"html":{"href":"https://github.com/alces-software/alces-flight-center/pull/101"},"issue":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/issues/101"},"comments":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/issues/101/comments"},"review_comments":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101/comments"},"review_comment":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/pulls/101/commits"},"statuses":{"href":"https://api.github.com/repos/alces-software/alces-flight-center/statuses/7671953beefbeb78c0194de1edec3ac6a2591398"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"bobwhitelock"}}