From 538bf4c388a7e2dea0f675d3401ffb140a5ebfff Mon Sep 17 00:00:00 2001 From: Nick Charlton Date: Fri, 26 Jun 2020 18:26:49 +0100 Subject: [PATCH] Restore destroy functionality In #1618, we removed the explicit include of `jquery_ujs` as it should no longer be necessary. Alas, this broke the ability to destroy items. This wasn't caught by the tests because Capybara tries to be clever with these links, sending the `DELETE` directly instead of clicking on the link. We disable this here and switch the specs to use the JS driver so that we're actually testing the functionality (it can't pass without). Adding the include of `jquery_ujs` solves this for now, unblocking us from having a release for lots of other features and allows us to revisit this problem again (in a way that we'll catch it this time!). Fixes #1643. --- app/assets/javascripts/administrate/application.js | 1 + spec/example_app/app/assets/javascripts/application.js | 1 + spec/features/log_entries_index_spec.rb | 2 +- spec/features/orders_index_spec.rb | 4 ++-- spec/rails_helper.rb | 4 ++++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/administrate/application.js b/app/assets/javascripts/administrate/application.js index aa8a55d18b..1742ae435c 100644 --- a/app/assets/javascripts/administrate/application.js +++ b/app/assets/javascripts/administrate/application.js @@ -1,4 +1,5 @@ //= require jquery +//= require jquery_ujs //= require selectize //= require moment //= require datetime_picker diff --git a/spec/example_app/app/assets/javascripts/application.js b/spec/example_app/app/assets/javascripts/application.js index 003b12b4c0..3e5bd21447 100644 --- a/spec/example_app/app/assets/javascripts/application.js +++ b/spec/example_app/app/assets/javascripts/application.js @@ -11,4 +11,5 @@ // about supported directives. // //= require jquery +//= require jquery_ujs //= require_tree . diff --git a/spec/features/log_entries_index_spec.rb b/spec/features/log_entries_index_spec.rb index d38af18b5b..1c0fcb13e3 100644 --- a/spec/features/log_entries_index_spec.rb +++ b/spec/features/log_entries_index_spec.rb @@ -48,7 +48,7 @@ expect(current_path).to eq(new_admin_log_entry_path) end - scenario "user deletes record" do + scenario "user deletes record", js: true do create(:log_entry) visit admin_log_entries_path diff --git a/spec/features/orders_index_spec.rb b/spec/features/orders_index_spec.rb index 223dcb3029..969cafcecf 100644 --- a/spec/features/orders_index_spec.rb +++ b/spec/features/orders_index_spec.rb @@ -45,7 +45,7 @@ expect(current_path).to eq(new_admin_order_path) end - scenario "user deletes record" do + scenario "user deletes record", js: true do create(:order) visit admin_orders_path @@ -56,7 +56,7 @@ ) end - scenario "cannot delete because associated payment" do + scenario "cannot delete because associated payment", js: true do create(:payment, order: create(:order)) visit admin_orders_path diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ab55491ed1..e82e49a673 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -37,4 +37,8 @@ module Features Capybara::Poltergeist::Driver.new(app, options) end +Capybara.register_driver :rack_test do |app| + Capybara::RackTest::Driver.new(app, respect_data_method: false) +end + Capybara.server = :webrick