mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 20:21:25 +08:00
FIX: correctly show validation errors in automation (#27622)
A previous refactor has prevented errors to show correctly. The guilt of the issue is that we were not calling the error variable correctly in the templates. This commit also adds a spec for this case, and removes the need for `I18n.backend.store_translations` in specs so we don't have to write too much boilerplate each time we write a spec.
This commit is contained in:
34
plugins/automation/spec/system/error_spec.rb
Normal file
34
plugins/automation/spec/system/error_spec.rb
Normal file
@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "DiscourseAutomation | error", type: :system do
|
||||
fab!(:admin)
|
||||
|
||||
before do
|
||||
SiteSetting.discourse_automation_enabled = true
|
||||
sign_in(admin)
|
||||
end
|
||||
|
||||
context "when saving the form with an error" do
|
||||
it "shows the error correctly" do
|
||||
visit("/admin/plugins/discourse-automation")
|
||||
|
||||
find(".new-automation").click
|
||||
fill_in("automation-name", with: "aaaaa")
|
||||
select_kit = PageObjects::Components::SelectKit.new(".scriptables")
|
||||
select_kit.expand
|
||||
select_kit.select_row_by_value("post")
|
||||
find(".create-automation").click
|
||||
select_kit = PageObjects::Components::SelectKit.new(".triggerables")
|
||||
select_kit.expand
|
||||
select_kit.select_row_by_value("recurring")
|
||||
find(".update-automation").click
|
||||
|
||||
expect(page).to have_content(
|
||||
I18n.t(
|
||||
"discourse_automation.models.fields.required_field",
|
||||
{ name: "topic", target: "script", target_name: "post" },
|
||||
),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user