bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 572 forks source link

bip_text Test Helper datapicker MiniTest failure #615

Open sean-whiley opened 5 years ago

sean-whiley commented 5 years ago

When using the bip_text Test Helper with a Capybara, MiniTest test, the test would fail because the date would fail its assertion of a specific entered date.

This was caused by the datepicker reseting itself when the test moved onto the next text entry point.

Adding a new method solved this problem:

def bip_date(model, attr, new_value)
  id = BestInPlace::Utils.build_best_in_place_id model, attr
  find("##{id}").click
  execute_script <<-JS
    $("##{id} input[name='#{attr}']").
      datepicker("setDate", '#{escape_javascript new_value.to_s}').
      datepicker("hide");
  JS
  wait_for_ajax
end

I tried to create a fork and make the changes but could not get the appraisal tests to run.

So if anyone is looking for a fix this might help!