akephalos
akephalos copied to clipboard
Form with :remote => true in padrino returns raw javascript
From zenom:
Wondering if you can shed some light. I am using Steak/RSpec2 and trying to get Akephalos to work.
When I use Capybara.current_driver = :akephalos I get the following. (some of this is debug) https://gist.github.com/ab137f4fd11b4f7750f4
When I use Capybara.javascript_driver = :akephalos I get the following. https://gist.github.com/372016a28f9d1c324322
Basically what I have is a link that is clicked to show a "Notes" form. User enters in some data, clicks submit, note gets added to another notes div. My controller returns the javascript to refresh the Notes list div. When using the javascript_driver, I just get the javascript back from the controller, I don't get the customer page which the notes listed in it. (Does this make sense, not sure if I am explaining it right). Basically it works the same with without akephalos and just using capybara/racktest.
This isn't rails just FYI, this is using Padrino.
What I am trying to do is basically test a dynamic note addition. So a user goes to a customers page. They click an add note link which pulls a template in with an add note form. Add some note text, click submit.
At this point, it should add the note text to a div inside the customers page. (This is being done with a remote => true form. Which goes to a notes controller, which returns some javascript to refresh the div in the customers page). Now when I click the submit button for the add note, I get the javascript from the controller, its like its not doing the ajax call but actually just posting the form. Now this is the same thing that happens without akephalos (just plain old capybara with rack/test).
Anything else I can do to clarify or test please let me know.
Just wanted to update this... Controller code: https://gist.github.com/557eda685def48971fff
And the form code in the customer view. -form_for :note, url(:notes, :create, :customer_id => @customer.id, :format => :js), :remote => true, :class => :form, :id => 'note_form' do |f| =partial "notes/form", :locals => { :f => f}
Also here are my rspec2 helpers and such.
spec_helper.rb https://gist.github.com/65c49f000587645c4ae2
acceptance_helper.rb https://gist.github.com/11202fb4467bc00da3b9
Another test I just tried to do with the new google instant. Using akephalos. This is with setting Capybara.app_host = "http://www.google.com" not sure if this is possible to test this way, but it works in selenium, just not akephalos.
Another test. scenario "create a credit card with valid data", :js => true do visit "/" fill_in "q", :with => "MMA WrapUp" page.should have_content "mma wrap up" end
Another thing I just thought of, is I am using RVM, not sure if that makes a difference or not too. Ruby version is 1.9.2-p0.
I've narrowed down this issue to a bug in HtmlUnit: https://sourceforge.net/tracker/?func=detail&aid=3072866&group_id=47038&atid=448266
In rails.js, this comes before the $('form[data-remote]') handler:
$('a[data-confirm],input[data-confirm]').live('click', function () { // ....
For some reason, this prevents the other event handlers from running, which is why the form is posting directly instead of using ajax. Hopefully this issue will be resolved soon and this will work as expected.
Hmm htmlunit folks havn't even picked this ticket up on there end it appears. Gonna be a while you think?
Is it workaround for this bug?
I'm also interested in this - i hope to have time to look at it on thursday.