Fix tests, remove workflow controllers
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user