bullet-train-co / bullet_train-core

The Open Source Ruby on Rails SaaS Framework
36 stars 44 forks source link

API: Implementing the `update` action in `User` #320

Open gazayas opened 1 year ago

gazayas commented 1 year ago

I looked into this TODO:

https://github.com/bullet-train-co/bullet_train-core/blob/350023aa4c3116f4df89c85f6dd2d7dbf8261bbf/bullet_train-api/app/controllers/concerns/api/v1/users/controller_base.rb#L66-L70

I set up a test like this:

test "update" do
  put "/api/v1/users/#{@user.id}", params: {
    access_token: access_token,
    user: {
      email: @user.email,
      first_name: "Updated",
      last_name: "Record",
      time_zone: @user.time_zone,
      locale: @user.current_team.locale
    }
  }

  # ...
end

However, the update action isn't getting fired at all, and this returns a 404. I tried putting the update action in the starter repository instead at app/controllers/api/v1/users_controller.rb, but I just got the following error instead:

Error:
Api::V1::UsersControllerTest#test_update:
AbstractController::ActionNotFound: The action 'update' could not be found for Api::V1::UsersController
    test/controllers/api/v1/users_controller_test.rb:58:in `block in <class:UsersControllerTest>'

I don't want to waste too much time on this one, just thought I'd post some thoughts here in case there's something I'm overlooking and if anyone has any insight.

newstler commented 1 year ago

I've added this so we could get user params in OpenAPI. Not sure why it couldn't be found, will take a look.

gazayas commented 1 year ago

I looked into the devise controllers too, it looks like update isn't being filtered through there either.