Fix upload settings redirection
This commit is contained in:
committed by
Javi Martín
parent
1fb351425f
commit
cb91a7421d
@@ -1,5 +1,6 @@
|
||||
<%= form_tag admin_update_content_types_path, method: :put, id: "edit_#{dom_id(setting)}" do %>
|
||||
<%= hidden_field_tag "id", setting.id, id: dom_id(setting, :id) %>
|
||||
<%= hidden_field_tag :tab, tab if tab %>
|
||||
|
||||
<div class="small-12 medium-6 large-8 column">
|
||||
<% group = setting.content_type_group %>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
class Admin::Settings::ContentTypesFormComponent < ApplicationComponent
|
||||
attr_reader :setting
|
||||
attr_reader :setting, :tab
|
||||
delegate :dom_id, to: :helpers
|
||||
|
||||
def initialize(setting)
|
||||
def initialize(setting, tab: nil)
|
||||
@setting = setting
|
||||
@tab = tab
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</td>
|
||||
<td>
|
||||
<% if setting.content_type? %>
|
||||
<%= render Admin::Settings::ContentTypesFormComponent.new(setting) %>
|
||||
<%= render Admin::Settings::ContentTypesFormComponent.new(setting, tab: tab) %>
|
||||
<% elsif setting.feature? %>
|
||||
<%= render Admin::Settings::FeaturedSettingsFormComponent.new(setting, tab: tab) %>
|
||||
<% else %>
|
||||
|
||||
@@ -37,7 +37,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
Setting.mime_types[group][content_type]
|
||||
end
|
||||
setting.update! value: mime_type_values.join(" ")
|
||||
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
|
||||
redirect_to request_referer, notice: t("admin.settings.flash.updated")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<h2><%= t("admin.settings.index.images_and_documents") %></h2>
|
||||
|
||||
<%= render Admin::Settings::TableComponent.new(settings: @uploads_settings, setting_name: "setting") %>
|
||||
<%= render Admin::Settings::TableComponent.new(settings: @uploads_settings, setting_name: "setting", tab: "#tab-images-and-documents") %>
|
||||
|
||||
@@ -277,6 +277,18 @@ describe "Admin settings", :admin do
|
||||
expect(page).to have_current_path(admin_settings_path)
|
||||
expect(page).to have_css("h2", exact_text: "SDG configuration")
|
||||
end
|
||||
|
||||
scenario "On #tab-images-and-documents" do
|
||||
Setting["feature.sdg"] = true
|
||||
visit admin_settings_path(anchor: "tab-images-and-documents")
|
||||
within("tr", text: "Maximum number of documents") do
|
||||
fill_in "Maximum number of documents", with: 5
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(admin_settings_path)
|
||||
expect(page).to have_field("Maximum number of documents", with: 5)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Skip verification" do
|
||||
|
||||
Reference in New Issue
Block a user