Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Fix updating organization settings in case there were errors' to v0.26 #9938

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def edit
def update
enforce_permission_to :update, :organization, organization: current_organization
@form = form(OrganizationForm).from_params(params)
@form.id = current_organization.id

UpdateOrganization.call(current_organization, @form) do
on(:ok) do
Expand Down
54 changes: 38 additions & 16 deletions decidim-admin/spec/system/admin_manages_organization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,27 +355,49 @@
expect(organization[:welcome_notification_subject]).to be_nil
expect(organization.send_welcome_notification).to be_truthy
end
end

context "when customizing it" do
it "shows the custom fields and stores them" do
visit decidim_admin.edit_organization_path
check "Send welcome notification"
check "Customize welcome notification"
context "when customizing it" do
it "shows the custom fields and stores them" do
visit decidim_admin.edit_organization_path
check "Send welcome notification"
check "Customize welcome notification"

fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs",
en: "Well hello!"
fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs",
en: "Well hello!"

fill_in_i18n_editor :organization_welcome_notification_body, "#organization-welcome_notification_body-tabs",
en: "<p>Body</p>"
fill_in_i18n_editor :organization_welcome_notification_body, "#organization-welcome_notification_body-tabs",
en: "<p>Body</p>"

click_button "Update"
expect(page).to have_content("updated successfully")
click_button "Update"
expect(page).to have_content("updated successfully")

organization.reload
expect(organization.send_welcome_notification).to be_truthy
expect(organization[:welcome_notification_subject]).to include("en" => "Well hello!")
expect(organization[:welcome_notification_body]).to include("en" => "<p>Body</p>")
end
organization.reload
expect(organization.send_welcome_notification).to be_truthy
expect(organization[:welcome_notification_subject]).to include("en" => "Well hello!")
expect(organization[:welcome_notification_body]).to include("en" => "<p>Body</p>")
end

it "allows re-sending the form in case there was an error on the form" do
visit decidim_admin.edit_organization_path
check "Send welcome notification"
check "Customize welcome notification"

fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs",
en: ""

click_button "Update"
expect(page).to have_content("There was a problem updating this organization.")

fill_in_i18n :organization_welcome_notification_subject, "#organization-welcome_notification_subject-tabs",
en: "Well hello!"

click_button "Update"
expect(page).to have_content("updated successfully")

organization.reload
expect(organization.send_welcome_notification).to be_truthy
expect(organization[:welcome_notification_subject]).to include("en" => "Well hello!")
end
end
end
Expand Down