Introduce a separate controller for collection entropy config
which opens the door to rendering turbo frames in the responses to collection edits.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
class Collections::EntropyConfigurationsController < ApplicationController
|
||||
include CollectionScoped
|
||||
|
||||
def update
|
||||
@collection.entropy_configuration.update!(entropy_configuration_params)
|
||||
|
||||
redirect_to edit_collection_path(@collection), notice: "Collection updated"
|
||||
end
|
||||
|
||||
private
|
||||
def entropy_configuration_params
|
||||
params.expect(collection: [ :auto_close_period, :auto_reconsider_period ])
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
<div class="margin-block-end">
|
||||
<strong class="divider txt-large">Do or Die</strong>
|
||||
<%= render "entropy/auto_close", model: collection %>
|
||||
<%= render "entropy/auto_close", model: collection, url: collection_entropy_configuration_path(collection) %>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ Rails.application.routes.draw do
|
||||
resource :workflow, only: :update
|
||||
resource :involvement
|
||||
resource :publication
|
||||
resource :entropy_configuration
|
||||
end
|
||||
|
||||
resources :cards
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
require "test_helper"
|
||||
|
||||
class Collections::EntropyConfigurationsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :kevin
|
||||
@collection = collections(:writebook)
|
||||
end
|
||||
|
||||
test "update" do
|
||||
put collection_entropy_configuration_path(@collection), params: { collection: { auto_close_period: 1.day, auto_reconsider_period: 2.days } }
|
||||
|
||||
assert_equal 1.day, @collection.entropy_configuration.reload.auto_close_period
|
||||
assert_equal 2.days, @collection.entropy_configuration.reload.auto_reconsider_period
|
||||
|
||||
assert_redirected_to edit_collection_path(@collection)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user