ruby on rails - ActiveRecord::RecordNotFound for record just created in 'js: true' Feature spec -


trying work javascript in simple feature spec i'm not able visit page.

describe "diskfiles"   ...   describe "update action", js: true     before(:each)       df = factorygirl.create(:disk_file)       visit edit_disk_file_path(df)     end      "should not show checkmark if no match"       expect(page).to_not have_content "✓"     end   end end 

i error:

  1) diskfiles update action should not show checkmark if no match      failure/error: unable find matching line backtrace      activerecord::recordnotfound:        couldn't find diskfile id=7598 [where "disk_items"."type" in ('diskfile')]      # ./app/controllers/disk_files_controller.rb:89:in `set_disk_file' 

which confuses me because created record in before(:each) and passes when remove js: true.

what missing?

it looks running tests transactional fixtures. when run test js: true run application , test in separate threads. create disk_file object in transaction (that automatically rolled @ end of test) in test thread. changes made in transaction not visible application unless committed (which not happen).

the solution problem use different database cleanup strategy javascript tests. database_cleaner gem popular way this.

see https://github.com/jnicklas/capybara#transactions-and-database-setup


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -