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

Add free-drawing page #7266

Merged
merged 19 commits into from
Jan 9, 2025
Merged
Prev Previous commit
Next Next commit
Add endpoint
  • Loading branch information
iHiD committed Jan 9, 2025
commit c77856250e79cb39dbf8edd42c2d9020d9e04bd6
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
Loading