Skip to content

Commit

Permalink
Add endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Jan 9, 2025
1 parent fc05dfd commit c778562
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/controllers/api/bootcamp/drawings_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class API::Bootcamp::DrawingsController < API::Bootcamp::BaseController
before_action :use_drawing

def update
@drawing.update(code: params[:code])

render json: {}, status: :ok
end

private
def use_drawing
@drawing = current_user.bootcamp_drawings.find_by!(uuid: params[:uuid])
end
end
17 changes: 17 additions & 0 deletions test/controllers/api/bootcamp/drawings_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require_relative '../base_test_case'

class API::Bootcamp::DrawingsControllerTest < API::BaseTestCase
test "update: updates and 200s" do
user = create :user
drawing = create(:bootcamp_drawing, user:)
code = "Something"

setup_user(user)
patch api_bootcamp_drawing_url(drawing, code:), headers: @headers

assert_response :ok
assert_json_response({})

assert code, drawing.reload.code
end
end

0 comments on commit c778562

Please sign in to comment.