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

Retain edited email body when going back from preview #791

Merged
merged 2 commits into from
Jan 20, 2022
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
4 changes: 3 additions & 1 deletion app/controllers/support/cases/emails/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update
@case_email_content_form = CaseEmailContentForm.from_validation(validation)

if validation.success?
@back_url = edit_support_case_email_content_path(@current_case)
@back_url = edit_support_case_email_content_path(@current_case, case_email_content_form: { email_body: case_email_content_form_params[:email_body] })

render :show
else
Expand Down Expand Up @@ -69,6 +69,8 @@ def basic_email_subject
end

def basic_email_body
return case_email_content_form_params[:email_body] if params[:case_email_content_form].present?

I18n.t("support.case_email_content.edit.default_email_body.non_template")
end

Expand Down
5 changes: 5 additions & 0 deletions spec/features/support/emails/agent_sends_basic_email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
end
end

it "retains the updated email body when clicking back on the preview" do
click_link "Back"
expect(page).to have_field("Enter email body", with: "New email body")
end

context "when leaving the email body blank" do
let(:custom_email_body) { "" }

Expand Down