-
Notifications
You must be signed in to change notification settings - Fork 86
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
.
956c75a
to
6ea520b
Compare
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) | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
Tiny tiny change and then this is good to go. |
6ea520b
to
bfbb0f4
Compare
Took over, requested changes were made.
Great work @treble37 |
What's in this PR?
Helps support #864
Make sure any changes to code include changes to documentation.
References
Fixes #890
Progress on: #864