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

Switch GithubAppInstallationController away from ja_resource and canary #1055

Merged
merged 2 commits into from
Oct 12, 2017

Conversation

treble37
Copy link
Contributor

@treble37 treble37 commented Oct 11, 2017

What's in this PR?

Helps support #864

Make sure any changes to code include changes to documentation.

References

Fixes #890

Progress on: #864

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.

Some changes that are actually unrelated to your work, but were pointed out thanks to it. Otherwise, good job!

plug JaResource
action_fallback CodeCorpsWeb.FallbackController
plug CodeCorpsWeb.Plug.DataToAttributes
plug CodeCorpsWeb.Plug.IdsToIntegers

@spec model :: module
def model, do: CodeCorps.GithubAppInstallation
Copy link
Contributor

Choose a reason for hiding this comment

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

You can completely remove the model function. It's used internally by ja_resource only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx

def create?(%User{} = user, %Ecto.Changeset{} = changeset),
do: changeset |> get_project |> owned_by?(user)
def create?(%User{} = user, params),
do: params |> get_project |> owned_by?(user)

def update?(%User{} = user, %GithubAppInstallation{} = github_app_installation),
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like you pointed out a bug we weren't aware of. There github app installation endpoint should only support :index, :show and :create in the controller. That means we do not really need an :update policy here, so feel free to remove it as well as the associated tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, all changes should be live now, thanks @begedin !

%GithubAppInstallation{}
|> GithubAppInstallation.create_changeset(attributes)
@spec delete(Plug.Conn.t, map) :: Conn.t
def delete(%Conn{} = conn, %{"id" => id} = params) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, a "bug" here. We should not be supporting a :delete. The controller should only have :index, :show and :create.

@treble37 treble37 force-pushed the 890-githubappcontroller branch from 956c75a to 6ea520b Compare October 11, 2017 15:19
def create?(%User{} = user, %Ecto.Changeset{} = changeset),
do: changeset |> get_project |> owned_by?(user)
def create?(%User{} = user, params),
do: params |> get_project |> owned_by?(user)

Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, but would kill this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed newline and it's all one one line now, thx!

@joshsmith
Copy link
Contributor

Tiny tiny change and then this is good to go.

@joshsmith joshsmith dismissed begedin’s stale review October 11, 2017 15:45

Changes were made.

@treble37 treble37 force-pushed the 890-githubappcontroller branch from 6ea520b to bfbb0f4 Compare October 11, 2017 16:01
@begedin begedin dismissed joshsmith’s stale review October 12, 2017 07:37

Took over, requested changes were made.

@begedin begedin merged commit 13de440 into code-corps:develop Oct 12, 2017
@begedin
Copy link
Contributor

begedin commented Oct 12, 2017

Great work @treble37

@treble37 treble37 deleted the 890-githubappcontroller branch October 12, 2017 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants