Use card rerendering instead of redirects
This commit is contained in:
@@ -6,5 +6,6 @@ class Cards::AssignmentsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@card.toggle_assignment @collection.users.active.find(params[:assignee_id])
|
@card.toggle_assignment @collection.users.active.find(params[:assignee_id])
|
||||||
|
rerender_card_container
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ class Cards::ClosuresController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@card.close(user: Current.user, reason: params[:reason])
|
@card.close(user: Current.user, reason: params[:reason])
|
||||||
redirect_to @card
|
rerender_card_container
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@card.reopen
|
@card.reopen
|
||||||
redirect_to @card
|
rerender_card_container
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ class Cards::EngagementsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@card.engage
|
@card.engage
|
||||||
redirect_to @card
|
rerender_card_container
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@card.reconsider
|
@card.reconsider
|
||||||
redirect_to @card
|
rerender_card_container
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,9 +10,4 @@ class Cards::GoldnessesController < ApplicationController
|
|||||||
@card.ungild
|
@card.ungild
|
||||||
rerender_card_container
|
rerender_card_container
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
def rerender_card_container
|
|
||||||
render turbo_stream: turbo_stream.replace([ @card, :card_container ], partial: "cards/container", locals: { card: @card.reload })
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class Cards::StagingsController < ApplicationController
|
|||||||
else
|
else
|
||||||
@card.update!(stage: nil)
|
@card.update!(stage: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rerender_card_container
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class Cards::TaggingsController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@card.toggle_tag_with sanitized_tag_title_param
|
@card.toggle_tag_with sanitized_tag_title_param
|
||||||
|
rerender_card_container
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -13,4 +13,8 @@ module CardScoped
|
|||||||
def set_collection
|
def set_collection
|
||||||
@collection = @card.collection
|
@collection = @card.collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rerender_card_container
|
||||||
|
render turbo_stream: turbo_stream.replace([ @card, :card_container ], partial: "cards/container", locals: { card: @card.reload })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<%= turbo_stream.replace([ @card, :meta ], partial: "cards/display/perma/meta", locals: { card: @card }) %>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<%= turbo_stream.replace dom_id(@card, "stages") do %>
|
|
||||||
<%= render partial: "cards/stagings/stages", locals: { card: @card } %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= turbo_stream.set_css_variable dom_id(@card, :card_closure_toggle), name: "--card-color", value: @card.color %>
|
|
||||||
<%= turbo_stream.set_css_variable dom_id(@card, :card_container), name: "--card-color", value: @card.color %>
|
|
||||||
<%= turbo_stream.set_css_variable dom_id(@card, :card_engagement_toggle), name: "--card-color", value: @card.color %>
|
|
||||||
<%= turbo_stream.set_css_variable dom_id(@card, :ticket), name: "--card-color", value: @card.color %>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<%= turbo_stream.replace([ @card, :tags ], partial: "cards/display/perma/tags", locals: { card: @card }) %>
|
|
||||||
@@ -13,12 +13,12 @@ class Cards::AssignmentsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "create" do
|
test "create" do
|
||||||
assert_changes "cards(:logo).assigned_to?(users(:david))", from: false, to: true do
|
assert_changes "cards(:logo).assigned_to?(users(:david))", from: false, to: true do
|
||||||
post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
|
post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
|
||||||
|
assert_card_container_rerendered(cards(:logo))
|
||||||
end
|
end
|
||||||
assert_response :success
|
|
||||||
|
|
||||||
assert_changes "cards(:logo).assigned_to?(users(:david))", from: true, to: false do
|
assert_changes "cards(:logo).assigned_to?(users(:david))", from: true, to: false do
|
||||||
post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
|
post card_assignments_path(cards(:logo)), params: { assignee_id: users(:david).id }, as: :turbo_stream
|
||||||
|
assert_card_container_rerendered(cards(:logo))
|
||||||
end
|
end
|
||||||
assert_response :success
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ class Cards::ClosuresControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
assert_changes -> { card.reload.closed? }, from: false, to: true do
|
assert_changes -> { card.reload.closed? }, from: false, to: true do
|
||||||
post card_closure_path(card, reason: "Scope too big")
|
post card_closure_path(card, reason: "Scope too big")
|
||||||
|
assert_card_container_rerendered(card)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "Scope too big", card.closure.reason
|
assert_equal "Scope too big", card.closure.reason
|
||||||
|
|
||||||
assert_redirected_to collection_card_path(card.collection, card)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "destroy" do
|
test "destroy" do
|
||||||
@@ -22,8 +21,7 @@ class Cards::ClosuresControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
assert_changes -> { card.reload.closed? }, from: true, to: false do
|
assert_changes -> { card.reload.closed? }, from: true, to: false do
|
||||||
delete card_closure_path(card)
|
delete card_closure_path(card)
|
||||||
|
assert_card_container_rerendered(card)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to collection_card_path(card.collection, card)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ class Cards::EngagementsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
assert_changes -> { card.reload.doing? }, from: false, to: true do
|
assert_changes -> { card.reload.doing? }, from: false, to: true do
|
||||||
post card_engagement_path(card)
|
post card_engagement_path(card)
|
||||||
|
assert_card_container_rerendered(card)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to collection_card_path(card.collection, card)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "destroy" do
|
test "destroy" do
|
||||||
@@ -20,8 +19,12 @@ class Cards::EngagementsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
assert_changes -> { card.reload.doing? }, from: true, to: false do
|
assert_changes -> { card.reload.doing? }, from: true, to: false do
|
||||||
delete card_engagement_path(card)
|
delete card_engagement_path(card)
|
||||||
|
assert_card_container_rerendered(card)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_redirected_to collection_card_path(card.collection, card)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def assert_card_container_rerendered(card)
|
||||||
|
assert_turbo_stream action: :replace, target: dom_id(card, :card_container)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ class Cards::GoldnessesControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "create" do
|
test "create" do
|
||||||
assert_changes -> { cards(:text).reload.golden? }, from: false, to: true do
|
assert_changes -> { cards(:text).reload.golden? }, from: false, to: true do
|
||||||
post card_goldness_path(cards(:text)), as: :turbo_stream
|
post card_goldness_path(cards(:text)), as: :turbo_stream
|
||||||
assert_response :success
|
assert_card_container_rerendered(cards(:text))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "destroy" do
|
test "destroy" do
|
||||||
assert_changes -> { cards(:logo).reload.golden? }, from: true, to: false do
|
assert_changes -> { cards(:logo).reload.golden? }, from: true, to: false do
|
||||||
delete card_goldness_path(cards(:logo)), as: :turbo_stream
|
delete card_goldness_path(cards(:logo)), as: :turbo_stream
|
||||||
assert_response :success
|
assert_card_container_rerendered(cards(:logo))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ class Cards::TaggingsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "toggle tag on" do
|
test "toggle tag on" do
|
||||||
assert_changes "cards(:logo).tagged_with?(tags(:mobile))", from: false, to: true do
|
assert_changes "cards(:logo).tagged_with?(tags(:mobile))", from: false, to: true do
|
||||||
post card_taggings_path(cards(:logo)), params: { tag_title: tags(:mobile).title }, as: :turbo_stream
|
post card_taggings_path(cards(:logo)), params: { tag_title: tags(:mobile).title }, as: :turbo_stream
|
||||||
|
assert_card_container_rerendered(cards(:logo))
|
||||||
end
|
end
|
||||||
assert_response :success
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "toggle tag off" do
|
test "toggle tag off" do
|
||||||
assert_changes "cards(:logo).tagged_with?(tags(:web))", from: true, to: false do
|
assert_changes "cards(:logo).tagged_with?(tags(:web))", from: true, to: false do
|
||||||
post card_taggings_path(cards(:logo)), params: { tag_title: tags(:web).title }, as: :turbo_stream
|
post card_taggings_path(cards(:logo)), params: { tag_title: tags(:web).title }, as: :turbo_stream
|
||||||
|
assert_card_container_rerendered(cards(:logo))
|
||||||
end
|
end
|
||||||
assert_response :success
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -10,6 +10,6 @@ module ActiveSupport
|
|||||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||||
fixtures :all
|
fixtures :all
|
||||||
|
|
||||||
include ChangeTestHelper, SessionTestHelper
|
include CardTestHelper, ChangeTestHelper, SessionTestHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
module CardTestHelper
|
||||||
|
def assert_card_container_rerendered(card)
|
||||||
|
assert_turbo_stream action: :replace, target: dom_id(card, :card_container)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user