Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
Re-initializing a backbone collection doesn't unbind events

I'm contributing to the diaspora* social network and most of the front-end code is written with backbone. Jasmine is used to test that javascript code, and I discovered that, depending of the order of the tests, they may fail. The data isn't cleaned correctly between tests.

The project is open-source, so let me link the code directly. This line for example, at the beginning of the test, is sometimes failing saying Expected object not to have properties "reshared: 5", which is the result of a leftover of that test, run before.

However, notice that the collection was correctly reset before the second test run. But if you put a break point just after that line, and enter target.unreadCountByType in the Firefox console, it will print Object { reshared: 5 }. So, calling new app.collections.Notifications(); doesn't actually (completely) reset the collection.

The collection is defined in this file and as you can see, is correctly initialized (unreadCountByType: {}).

I think that the problem lies here. In those lines, there is a binding to userChangedUnreadStatus which is done each time the parse function is called. So I guess that this should be unbinded at some point, put here my investigation is stuck, as I have no idea how backbone works.

If you want to run the test locally, git clone git@github.com:diaspora/diaspora.git, then generate the assets with bin/rake tests:generate_fixtures, launch jasmine with RAILS_ENV=test bin/rake jasmine and then run the test by visting http://localhost:8888/?spec=app.collections.Notifications with your web browser.

Any help welcome!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda