Enable polling for tests
This commit is contained in:
parent
234572f8a6
commit
93373e89ee
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import config from 'travis/config/environment'`
|
|
||||||
|
|
||||||
mixin = Ember.Mixin.create
|
mixin = Ember.Mixin.create
|
||||||
polling: Ember.inject.service()
|
polling: Ember.inject.service()
|
||||||
|
@ -7,13 +6,11 @@ mixin = Ember.Mixin.create
|
||||||
didInsertElement: ->
|
didInsertElement: ->
|
||||||
@_super.apply(this, arguments)
|
@_super.apply(this, arguments)
|
||||||
|
|
||||||
return unless config.ajaxPolling
|
|
||||||
@startPolling()
|
@startPolling()
|
||||||
|
|
||||||
willDestroyElement: ->
|
willDestroyElement: ->
|
||||||
@_super.apply(this, arguments)
|
@_super.apply(this, arguments)
|
||||||
|
|
||||||
return unless config.ajaxPolling
|
|
||||||
@stopPolling()
|
@stopPolling()
|
||||||
|
|
||||||
pollModelDidChange: (sender, key, value) ->
|
pollModelDidChange: (sender, key, value) ->
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
service = Ember.Service.extend
|
service = Ember.Service.extend
|
||||||
pollingInterval: 30000
|
pollingInterval: 30000
|
||||||
|
ajaxPolling: true
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
@_super.apply(this, arguments)
|
@_super.apply(this, arguments)
|
||||||
|
@ -10,9 +11,8 @@ service = Ember.Service.extend
|
||||||
@set('watchedModels', [])
|
@set('watchedModels', [])
|
||||||
@set('sources', [])
|
@set('sources', [])
|
||||||
|
|
||||||
return unless config.ajaxPolling
|
|
||||||
|
|
||||||
interval = setInterval =>
|
interval = setInterval =>
|
||||||
|
return unless config.ajaxPolling
|
||||||
@poll()
|
@poll()
|
||||||
, @get('pollingInterval')
|
, @get('pollingInterval')
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ define('travis/components/polling-test', [], ->
|
||||||
|
|
||||||
# I want to test this mixin in context of component, so I'm using
|
# I want to test this mixin in context of component, so I'm using
|
||||||
# modelForComponent
|
# modelForComponent
|
||||||
moduleForComponent 'polling-test', 'PollingTestComponent', {
|
moduleForComponent 'polling-test', 'PollingMixin', {
|
||||||
# specify the other units that are required for this test
|
# specify the other units that are required for this test
|
||||||
needs: []
|
needs: []
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import Polling from 'travis/services/polling'`
|
`import Polling from 'travis/services/polling'`
|
||||||
|
`import config from 'travis/config/environment'`
|
||||||
|
|
||||||
service = null
|
service = null
|
||||||
|
|
||||||
module 'PollingService',
|
module 'PollingService',
|
||||||
|
setup: ->
|
||||||
|
config.ajaxPolling = true
|
||||||
|
|
||||||
teardown: ->
|
teardown: ->
|
||||||
|
config.ajaxPolling = false
|
||||||
unless service.get('isDestroyed')
|
unless service.get('isDestroyed')
|
||||||
Ember.run ->
|
Ember.run ->
|
||||||
service.destroy()
|
service.destroy()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user