Skip to content

When updating a task if it belongs to a GithubRepo update associated issue on github #803

@begedin

Description

@begedin

Problem

In the first iteration of github integration, a project can be assigned a repository on github, via a dropdown. Likewise, a task can then be assigned an issue on github.

If that is the case, when that task updates, the associated issue should update as well.

While we're handling this, we should extract task controller behavior into a separate module.

Subtasks

  • If it doesn't already exist, add /lib/code_corps/task/task.ex module, namespaced CodeCorps.Task
  • Add update/3 function to that module
    • Function accepts task, an attributes map and the current user
    • Function updates task, then updates associated github issue if necessary (using information from associated GithubRepo and the github_issue_number field.
    • Function returns {:ok, task} or {:error, changeset} or {:error, _}
    • If the current user is GitHub connected, the github API calls should be made on their behalf. If not, they should be made on the behalf of the default user provided by Provide default github user for the purposes of github integration #800
  • Modify TaskController.update to call the new module function
  • Add tests for new service module/new function which assert these four cases:
    • Task with no github id is updated, {:ok, updated_task} was returned, no github api call was made
    • Task with github id was updated, {:ok, updated_task} was returned, a github call was made
    • There was a validation error
    • There was some other error

The existing controller tests can remain as is.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions