Add API for gilding cards
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user