{"action":"created","issue":{"url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/120","labels_url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/120/comments","events_url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/120/events","html_url":"https://github.com/ministryofjustice/defence-request-service/pull/120","id":70133914,"number":120,"title":"Extract transitions resource","user":{"login":"pedrosmmoreira","id":658761,"avatar_url":"https://avatars.githubusercontent.com/u/658761?v=3","gravatar_id":"","url":"https://api.github.com/users/pedrosmmoreira","html_url":"https://github.com/pedrosmmoreira","followers_url":"https://api.github.com/users/pedrosmmoreira/followers","following_url":"https://api.github.com/users/pedrosmmoreira/following{/other_user}","gists_url":"https://api.github.com/users/pedrosmmoreira/gists{/gist_id}","starred_url":"https://api.github.com/users/pedrosmmoreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedrosmmoreira/subscriptions","organizations_url":"https://api.github.com/users/pedrosmmoreira/orgs","repos_url":"https://api.github.com/users/pedrosmmoreira/repos","events_url":"https://api.github.com/users/pedrosmmoreira/events{/privacy}","received_events_url":"https://api.github.com/users/pedrosmmoreira/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-22T14:02:35Z","updated_at":"2015-04-25T16:48:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ministryofjustice/defence-request-service/pulls/120","html_url":"https://github.com/ministryofjustice/defence-request-service/pull/120","diff_url":"https://github.com/ministryofjustice/defence-request-service/pull/120.diff","patch_url":"https://github.com/ministryofjustice/defence-request-service/pull/120.patch"},"body":"This extracts a resource responsible for managing the state transitions of defence requests."},"comment":{"url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/comments/96235370","html_url":"https://github.com/ministryofjustice/defence-request-service/pull/120#issuecomment-96235370","issue_url":"https://api.github.com/repos/ministryofjustice/defence-request-service/issues/120","id":96235370,"user":{"login":"ansonK","id":722405,"avatar_url":"https://avatars.githubusercontent.com/u/722405?v=3","gravatar_id":"","url":"https://api.github.com/users/ansonK","html_url":"https://github.com/ansonK","followers_url":"https://api.github.com/users/ansonK/followers","following_url":"https://api.github.com/users/ansonK/following{/other_user}","gists_url":"https://api.github.com/users/ansonK/gists{/gist_id}","starred_url":"https://api.github.com/users/ansonK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansonK/subscriptions","organizations_url":"https://api.github.com/users/ansonK/orgs","repos_url":"https://api.github.com/users/ansonK/repos","events_url":"https://api.github.com/users/ansonK/events{/privacy}","received_events_url":"https://api.github.com/users/ansonK/received_events","type":"User","site_admin":false},"created_at":"2015-04-25T16:48:22Z","updated_at":"2015-04-25T16:48:22Z","body":"What is missing from the Transitions service objects is error bubbling. When a transition fails (either due to a guard clause or a failed validation) then an error message must be bubbled up to the controller for display to the user.\r\n\r\nEach of these service object could respond_to ```errors``` like below:\r\n\r\n```\r\n   if transition.complete\r\n      redirect_to dashboard_path,\r\n        notice: flash_message(requested_transition.to_sym, DefenceRequest)\r\n    else\r\n      redirect_to dashboard_path, error: transition.errors\r\n    end\r\n```\r\nThe ```errors``` response should be something that can be stored in the flash and rendered to the user\r\n\r\nThoughts?"}}