From e319b93dc63e0f2afce8105ef44e18cef4c725ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 13 Aug 2020 17:55:48 +0200 Subject: [PATCH] Don't disable button to download emails Rails automatically disables buttons when submitting a form. This works fine most of the time: for AJAX requests, it enables them again after the request is complete, and for non-AJAX requests, the button is replaced by a new element when the new page loads. However, there's an exception. When a request returns data so users can download a fire, the request is not an AJAX one and the button is not replaced. So users are left with a disabled button they can no longer click. So in this case, we aren't disabling the button after a user clicks it. --- app/views/admin/emails_download/index.html.erb | 4 +++- spec/system/admin/emails/emails_download_spec.rb | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/admin/emails_download/index.html.erb b/app/views/admin/emails_download/index.html.erb index a8283bbc2..395ff9039 100644 --- a/app/views/admin/emails_download/index.html.erb +++ b/app/views/admin/emails_download/index.html.erb @@ -12,6 +12,8 @@ <%= select_tag :users_segment, options_for_select(user_segments_options) %> - <%= submit_tag t("admin.emails_download.index.download_emails_button"), class: "button" %> + <%= submit_tag t("admin.emails_download.index.download_emails_button"), + class: "button", + data: { disable_with: false } %> <% end %> diff --git a/spec/system/admin/emails/emails_download_spec.rb b/spec/system/admin/emails/emails_download_spec.rb index 9c29a0742..b842e4276 100644 --- a/spec/system/admin/emails/emails_download_spec.rb +++ b/spec/system/admin/emails/emails_download_spec.rb @@ -38,4 +38,11 @@ describe "Admin download user emails" do expect(file_contents).to match_array ["admin_news1@consul.dev", "admin_news2@consul.dev"] end end + + scenario "Download button is not disabled after being clicked", :js do + visit admin_emails_download_index_path + click_button "Download emails list" + + expect(page).to have_button "Download emails list", disabled: false + end end