Add API for gilding cards

This commit is contained in:
Stanko K.R.
2025-12-05 14:37:04 +01:00
parent 41115eaf87
commit 1caeea541d
2 changed files with 32 additions and 2 deletions
+10 -2
View File
@@ -3,11 +3,19 @@ class Cards::GoldnessesController < ApplicationController
def create
@card.gild
render_card_replacement
respond_to do |format|
format.turbo_stream { render_card_replacement }
format.json { head :no_content }
end
end
def destroy
@card.ungild
render_card_replacement
respond_to do |format|
format.turbo_stream { render_card_replacement }
format.json { head :no_content }
end
end
end
@@ -18,4 +18,26 @@ class Cards::GoldnessesControllerTest < ActionDispatch::IntegrationTest
assert_card_container_rerendered(cards(:logo))
end
end
test "create as JSON" do
card = cards(:text)
assert_not card.golden?
post card_goldness_path(card), as: :json
assert_response :no_content
assert card.reload.golden?
end
test "destroy as JSON" do
card = cards(:logo)
assert card.golden?
delete card_goldness_path(card), as: :json
assert_response :no_content
assert_not card.reload.golden?
end
end