Skip to content

Commit

Permalink
Restore destroy functionality
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nickcharlton committed Jun 26, 2020
1 parent 844c270 commit 538bf4c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/administrate/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//= require jquery
//= require jquery_ujs
//= require selectize
//= require moment
//= require datetime_picker
Expand Down
1 change: 1 addition & 0 deletions spec/example_app/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
2 changes: 1 addition & 1 deletion spec/features/log_entries_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/features/orders_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 538bf4c

Please sign in to comment.