Reputation: 2411
I have a checkbox on a page that sends an AJAX call to a method in a controller. A User checks this box to indicate that they have selected this Item, and the relationship is stored in a join table called UserItems.
How would I go about testing this? I currently have:
check "add-this-item-"+item.id.to_s
@user.user_item.item.should include(item)
The checkbox has a name that is "add-this-item-" plus its ID. Using pry-nav, I have verified that it is finding the checkbox and selecting it - however the test database does not update.
The checkbox does update the database when using the site locally.
I can't seem to figure this out. Any help is appreciated!
Upvotes: 0
Views: 311
Reputation: 62698
You're going to need to use a Capybara driver that can run Javascript, like PhantomJS. The standard Capybara driver doesn't run Javascript, and thus wouldn't invoke click handlers or AJAX.
Upvotes: 1