Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changeset errors in markdown/body with issue changeset builder #966

Merged
merged 1 commit into from
Sep 25, 2017

Conversation

joshsmith
Copy link
Contributor

What's in this PR?

This fixes the issue with changeset errors from blank markdown (and therefore blank body) values that had an attempted fix in #963. It turns out that we're not using the changesets defined in the model itself, but instead specifically putting changes into a changeset and then validating.

@begedin I think it's worth addressing whether or not we want this logic to be split apart so separately, as it was pretty confusing; even in code review I didn't expect that this was using some other changeset. Any thoughts here?

Would like to hear @landongrindheim's thoughts on this, too.

@joshsmith joshsmith requested a review from begedin September 24, 2017 20:39
@joshsmith joshsmith added this to the GitHub integration milestone Sep 24, 2017
@begedin
Copy link
Contributor

begedin commented Sep 25, 2017

The idea/concept of a changeset, is that you have a function which casts and validates input for a specific action.

The Task.create_changesetspecific action is creation of a task from code corps.

The GitHub.Event.Issues.ChangesetBuilder.build specific action is "creating a task when handling an Issues event.

In hindsight, I believe we should consider changing the name of the module from ChangesetBuilder into, maybe, IssueToTaskChangeset or something along the lines, but I don't feel great about bunching up multiple changesets into one, since I feel it defeats the purpose of the changeset concept in the first place.

The issue here is that we named our changeset based on our initial (mis)understanding of what the purpose of changesets is.

EDIT:

Looking at the code for handling the issues event, I'm not seeing a part that would misguide the developer into thinking that Task.create_changeset is the one being used here.

The mistake comes from the assumption that all database inserts go through the same changeset function, which is, IMHO, incorrect. While the most basic validations are often common across all insertions, at the very least, there will be custom casts based on the origin.

ja_resource, for example, operated on a similar (but IMO much worse) assumption ModelName.changeset, is the "one changeset to rule them all", through which ALL database operations go and that's the main reason we're moving away from it.

begedin
begedin previously approved these changes Sep 25, 2017
Copy link
Contributor

@begedin begedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Something to consider, and I believe I've posted a comment in a related discussion somewhere,

#963 removed the requirement for a task to have a body when a user is creating/updating it from CodeCorps

I don't think that requirement is needed anyway, but I will say it again, just to put the option out there, since we are using multiple different changesets, we can add the requirement back in the case of input from CodeCorps, while keeping it off in the case of syncing from Github.

That's the main strength of changesets - different validations and restrictions on the same schema in different scenarios.

@joshsmith
Copy link
Contributor Author

@begedin understood and agreed about changesets. I think maybe we could just be more explicit about documenting it, and likely should have been much more explicit about the requirements in the issue.

@joshsmith joshsmith deleted the update-changeset-builder branch September 25, 2017 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants