Skip to content

When creating a task, if it belongs to a GithubRepo, create associated issue on github #804

@begedin

Description

@begedin

Problem

A project can be tied to one or more github repositories, through the ProjectGithubRepo relation

When creating a task for a project, the attributes should contain a github_repo_id, meaning a task should now belong to a GithubRepo (but the relationship can be nil).

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 (namespace CodeCorps.Task
  • Add create/2 function to that module
    • Function accepts an attributes map and the current user
    • Function initializes task (associated with GithubRepo), creates an associated github issue for the assigned github repo, the stores that github issue number as the task :github_number field and finally saves the task
    • 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 identity provided in Provide default github user for the purposes of github integration #800
  • Modify TaskController.create to call the new module function
  • Add tests for new function which assert these four cases:
    • Task with no github id is created, {:ok, task} was returned, no github api call was made
    • Task with github id was created, {:ok, task} was returned, a github call was made
    • There was a validation error
    • There was some other error

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions