Fix problem with getting started template rendering on first sync
When first sync template is displayed, user usually doesn't have any repos, which also triggers rendering of getting started template. The fix for this is to handle the action to render getting started page on first sync and do nothing in such case. I also added a test to ensure that it works correctly.
This commit is contained in:
parent
a8fe524c00
commit
018eafe84b
|
@ -6,7 +6,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
'owned'
|
||||
else
|
||||
'recent'
|
||||
).property('currentUser')
|
||||
).property('currentUser.id')
|
||||
|
||||
currentUserIdDidChange: (->
|
||||
if @get('currentUser.id')
|
||||
|
@ -16,10 +16,10 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
).observes('currentUser.id')
|
||||
|
||||
tabOrIsLoadedDidChange: (->
|
||||
if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0
|
||||
|
||||
@container.lookup('router:main').send('renderNoOwnedRepos')
|
||||
).observes('isLoaded', 'tab')
|
||||
Ember.run.scheduleOnce 'routerTransitions', this, ->
|
||||
if @get('tab') == 'owned' && @get('isLoaded') && @get('length') == 0
|
||||
@container.lookup('router:main').send('renderNoOwnedRepos')
|
||||
).observes('isLoaded', 'tab', 'length')
|
||||
|
||||
isLoadedBinding: 'content.isLoaded'
|
||||
needs: ['currentUser', 'repo']
|
||||
|
|
|
@ -140,6 +140,11 @@ Travis.GettingStartedRoute = Ember.Route.extend
|
|||
@_super.apply(this, arguments)
|
||||
|
||||
Travis.FirstSyncRoute = Ember.Route.extend
|
||||
events:
|
||||
renderNoOwnedRepos: (->)
|
||||
# do nothing, we are showing first sync, so it's normal that there is
|
||||
# no owned repos
|
||||
|
||||
setupController: ->
|
||||
$('body').attr('id', 'home')
|
||||
@container.lookup('controller:repos').activate()
|
||||
|
|
|
@ -43,7 +43,7 @@ Travis.FirstSyncView = Travis.View.extend
|
|||
).then(null, (e) ->
|
||||
console.log('There was a problem while redirecting from first sync', e)
|
||||
)
|
||||
, 5000
|
||||
, Travis.config.syncingPageRedirectionTime
|
||||
|
||||
require 'views/accounts'
|
||||
require 'views/application'
|
||||
|
|
|
@ -5,7 +5,6 @@ module "My repos",
|
|||
Ember.run -> Travis.reset()
|
||||
|
||||
test "my repos is active by default when user is signed in", ->
|
||||
|
||||
Ember.run -> signInUser()
|
||||
visit('/').then ->
|
||||
wait().then ->
|
||||
|
|
26
assets/scripts/spec/integration/sync.coffee
Normal file
26
assets/scripts/spec/integration/sync.coffee
Normal file
|
@ -0,0 +1,26 @@
|
|||
module "Sync",
|
||||
setup: ->
|
||||
Ember.run -> Travis.advanceReadiness()
|
||||
teardown: ->
|
||||
Ember.run -> Travis.reset()
|
||||
|
||||
test "first sync page is show when user just signed up and is syncing", ->
|
||||
Ember.run ->
|
||||
signInUser(
|
||||
is_syncing: true
|
||||
synced_at: null
|
||||
login: 'new-user'
|
||||
)
|
||||
|
||||
Travis.config.syncingPageRedirectionTime = 100
|
||||
|
||||
wait().then ->
|
||||
ok $('#first_sync').text().match(/Just a few more seconds as we talk to GitHub to find out which repositories belong to you./)
|
||||
|
||||
stop()
|
||||
Travis.__container__.lookup('controller:currentUser').get('content').set('isSyncing', false)
|
||||
setTimeout ->
|
||||
start()
|
||||
visit('/').then ->
|
||||
ok $('#getting-started').text().match(/Welcome to Travis CI!/)
|
||||
, 120
|
|
@ -16,15 +16,19 @@ Ember.Container.prototype.stub = (fullName, instance) ->
|
|||
instance.destroy = instance.destroy || (->)
|
||||
this.cache.dict[fullName] = instance
|
||||
|
||||
window.signInUser = ->
|
||||
window.signInUser = (data) ->
|
||||
data ||= {}
|
||||
userData = {
|
||||
id: 1
|
||||
email: 'tyrion@example.org'
|
||||
login: 'tyrion'
|
||||
token: 'abcdef'
|
||||
}
|
||||
userData = Ember.merge(userData, data)
|
||||
# for now let's just use harcoded data to log in the user,
|
||||
# we may extend it in the future to pass specific user data
|
||||
Travis.auth.signIn
|
||||
user:
|
||||
id: 1
|
||||
email: 'tyrion@example.org'
|
||||
login: 'tyrion'
|
||||
token: 'abcdef'
|
||||
user: userData
|
||||
token: 'abcdef'
|
||||
|
||||
#@app = (url, options = {}) ->
|
||||
|
|
|
@ -71,6 +71,7 @@ $.extend Travis,
|
|||
Travis.advanceReadiness() # bc, remove once merged to master
|
||||
|
||||
config:
|
||||
syncingPageRedirectionTime: 5000
|
||||
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
|
||||
pusher_key: $('meta[name="travis.pusher_key"]').attr('value')
|
||||
ga_code: $('meta[name="travis.ga_code"]').attr('value')
|
||||
|
|
Loading…
Reference in New Issue
Block a user