From e14262dc01fe7c73019c8f38d695ec49c4e87cd6 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Sun, 28 Sep 2025 18:50:26 +0200 Subject: [PATCH] Fix tests, remove workflow controllers --- app/controllers/cards/stagings_controller.rb | 14 ------ .../collections/workflows_controller.rb | 19 -------- app/controllers/workflows_controller.rb | 43 ------------------- config/routes.rb | 5 --- .../cards/stagings_controller_test.rb | 12 ------ .../collections/workflows_controller_test.rb | 16 ------- test/controllers/workflows_controller_test.rb | 43 ------------------- test/models/card/entropic_test.rb | 4 +- test/models/card/postponable_test.rb | 4 +- 9 files changed, 4 insertions(+), 156 deletions(-) delete mode 100644 app/controllers/cards/stagings_controller.rb delete mode 100644 app/controllers/collections/workflows_controller.rb delete mode 100644 app/controllers/workflows_controller.rb delete mode 100644 test/controllers/cards/stagings_controller_test.rb delete mode 100644 test/controllers/collections/workflows_controller_test.rb delete mode 100644 test/controllers/workflows_controller_test.rb diff --git a/app/controllers/cards/stagings_controller.rb b/app/controllers/cards/stagings_controller.rb deleted file mode 100644 index bbf5b38a9..000000000 --- a/app/controllers/cards/stagings_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Cards::StagingsController < ApplicationController - include CardScoped - - def update - stage = @collection.workflow.stages.find(params[:stage_id]) - - if @card.considering? - @card.engage - end - - @card.change_stage_to(stage) - render_card_replacement - end -end diff --git a/app/controllers/collections/workflows_controller.rb b/app/controllers/collections/workflows_controller.rb deleted file mode 100644 index 7b79baad4..000000000 --- a/app/controllers/collections/workflows_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Collections::WorkflowsController < ApplicationController - include CollectionScoped - - before_action :set_workflow - - def update - @collection.update! workflow: @workflow - render turbo_stream: [ - turbo_stream.replace([ @collection, :workflows ], partial: "collections/edit/workflows", locals: { collection: @collection }), - turbo_stream_flash(notice: "Saved") - ] - end - - private - def set_workflow - workflow_id = params[:collection][:workflow_id] - @workflow = workflow_id.present? ? Workflow.find(workflow_id) : nil - end -end diff --git a/app/controllers/workflows_controller.rb b/app/controllers/workflows_controller.rb deleted file mode 100644 index 24aab333b..000000000 --- a/app/controllers/workflows_controller.rb +++ /dev/null @@ -1,43 +0,0 @@ -class WorkflowsController < ApplicationController - before_action :set_workflow, only: %i[ show edit update destroy ] - - include FilterScoped - - def index - @workflows = Workflow.all - end - - def new - @workflow = Workflow.new - end - - def create - @workflow = Workflow.create! workflow_params - redirect_to workflows_path - end - - def show - end - - def edit - end - - def update - @workflow.update! workflow_params - redirect_to @workflow - end - - def destroy - @workflow.destroy - redirect_to workflows_path - end - - private - def set_workflow - @workflow = Workflow.find params[:id] - end - - def workflow_params - params.expect workflow: :name - end -end diff --git a/config/routes.rb b/config/routes.rb index 6c69f6bc5..0f646bff1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -64,7 +64,6 @@ Rails.application.routes.draw do resource :publish resource :reading resource :recover - resource :staging resource :watch resource :collection, only: :update @@ -115,10 +114,6 @@ Rails.application.routes.draw do resources :days end - resources :workflows do - resources :stages, module: :workflows - end - resources :uploads, only: :create get "/u/*slug" => "uploads#show", as: :upload diff --git a/test/controllers/cards/stagings_controller_test.rb b/test/controllers/cards/stagings_controller_test.rb deleted file mode 100644 index 5e49876f5..000000000 --- a/test/controllers/cards/stagings_controller_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require "test_helper" - -class Cards::StagingsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in_as :kevin - end - - test "update" do - put card_staging_path(cards(:logo)), params: { stage_id: workflow_stages(:qa_in_progress).id }, as: :turbo_stream - assert_card_container_rerendered(cards(:logo)) - end -end diff --git a/test/controllers/collections/workflows_controller_test.rb b/test/controllers/collections/workflows_controller_test.rb deleted file mode 100644 index e4e739720..000000000 --- a/test/controllers/collections/workflows_controller_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require "test_helper" - -class Collections::WorkflowsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in_as :kevin - end - - test "update" do - collection = collections(:writebook) - - patch collection_workflow_path(collection), params: { collection: { workflow_id: workflows(:on_call).id } } - - assert_turbo_stream action: :replace, target: dom_id(collection, :workflows) - assert_equal workflows(:on_call), collection.reload.workflow - end -end diff --git a/test/controllers/workflows_controller_test.rb b/test/controllers/workflows_controller_test.rb deleted file mode 100644 index 8d3d64c69..000000000 --- a/test/controllers/workflows_controller_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require "test_helper" - -class WorkflowsControllerTest < ActionDispatch::IntegrationTest - setup do - sign_in_as :kevin - end - - test "index" do - get workflows_path - assert_in_body workflows(:on_call).name - end - - test "create" do - get new_workflow_path - assert_response :success - - assert_difference -> { Workflow.count }, +1 do - post workflows_path, params: { workflow: { name: "My new workflow!" } } - assert_redirected_to workflows_path - end - end - - test "show" do - get workflow_path(workflows(:on_call)) - assert_in_body workflows(:on_call).name - end - - test "update" do - get edit_workflow_path(workflows(:on_call)) - assert_response :success - - put workflow_path(workflows(:on_call)), params: { workflow: { name: "Monkeyflow!" } } - follow_redirect! - assert_in_body "Monkeyflow!" - end - - test "destroy" do - assert_difference -> { Workflow.count }, -1 do - delete workflow_path(workflows(:on_call)) - assert_redirected_to workflows_path - end - end -end diff --git a/test/models/card/entropic_test.rb b/test/models/card/entropic_test.rb index 0e826e092..fce3ef2d8 100644 --- a/test/models/card/entropic_test.rb +++ b/test/models/card/entropic_test.rb @@ -28,7 +28,7 @@ class Card::EntropicTest < ActiveSupport::TestCase cards(:logo).update!(last_active_at: 1.day.ago - entropy_configurations("37s_account").auto_postpone_period) cards(:shipping).update!(last_active_at: 1.day.from_now - entropy_configurations("37s_account").auto_postpone_period) - assert_difference -> { Card.not_now.count }, +1 do + assert_difference -> { Card.postponed.count }, +1 do Card.auto_postpone_all_due end @@ -40,7 +40,7 @@ class Card::EntropicTest < ActiveSupport::TestCase cards(:logo).update!(last_active_at: 1.day.ago - entropy_configurations(:writebook_collection).auto_postpone_period) cards(:shipping).update!(last_active_at: 1.day.from_now - entropy_configurations(:writebook_collection).auto_postpone_period) - assert_difference -> { Card.not_now.count }, +1 do + assert_difference -> { Card.postponed.count }, +1 do Card.auto_postpone_all_due end diff --git a/test/models/card/postponable_test.rb b/test/models/card/postponable_test.rb index 734eab90d..b4a183437 100644 --- a/test/models/card/postponable_test.rb +++ b/test/models/card/postponable_test.rb @@ -30,8 +30,8 @@ class Card::PostponableTest < ActiveSupport::TestCase logo.postpone - assert_includes Card.not_now, logo - assert_not_includes Card.not_now, text + assert_includes Card.postponed, logo + assert_not_includes Card.postponed, text assert_includes Card.active, text assert_not_includes Card.active, logo