Merge branch 'fionatay-master'
This commit is contained in:
commit
7ebd2bfcad
|
@ -13,20 +13,23 @@
|
|||
Travis.setLocale Travis.default_locale
|
||||
@set('state', 'signed-out')
|
||||
@set('user', undefined)
|
||||
user = Travis.__container__.lookup('controller:currentUser').get('content')
|
||||
if user = Travis.__container__.lookup('controller:currentUser').get('content')
|
||||
if user.get('stateManager.currentPath') == 'rootState.loaded.updated.uncommitted'
|
||||
user.send('rollback')
|
||||
user.unloadRecord()
|
||||
Travis.__container__.lookup('controller:currentUser').set('content', null)
|
||||
Travis.__container__.lookup('router:main').send('afterSignOut')
|
||||
|
||||
signIn: ->
|
||||
signIn: (data) ->
|
||||
if data
|
||||
@autoSignIn(data)
|
||||
else
|
||||
@set('state', 'signing-in')
|
||||
url = "#{@endpoint}/auth/post_message?origin=#{@receivingEnd}"
|
||||
$('<iframe id="auth-frame" />').hide().appendTo('body').attr('src', url)
|
||||
|
||||
autoSignIn: ->
|
||||
data = @userDataFrom(Travis.sessionStorage) || @userDataFrom(Travis.storage)
|
||||
autoSignIn: (data) ->
|
||||
data ||= @userDataFrom(Travis.sessionStorage) || @userDataFrom(Travis.storage)
|
||||
@setData(data) if data
|
||||
|
||||
userDataFrom: (storage) ->
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
require 'travis/limited_array'
|
||||
|
||||
Travis.ReposController = Ember.ArrayController.extend
|
||||
defaultTab: 'recent'
|
||||
defaultTab: ( ->
|
||||
if @get('currentUser.id')
|
||||
'owned'
|
||||
else
|
||||
'recent'
|
||||
).property('currentUser')
|
||||
|
||||
currentUserIdDidChange: (->
|
||||
if @get('currentUser.id')
|
||||
@activate('owned')
|
||||
else if @get('tab') == 'owned'
|
||||
@activate('recent')
|
||||
).observes('currentUser.id')
|
||||
|
||||
isLoadedBinding: 'content.isLoaded'
|
||||
needs: ['currentUser', 'repo']
|
||||
currentUserBinding: 'controllers.currentUser'
|
||||
|
@ -34,7 +47,7 @@ Travis.ReposController = Ember.ArrayController.extend
|
|||
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
|
||||
|
||||
activate: (tab, params) ->
|
||||
tab ||= @defaultTab
|
||||
tab ||= @get('defaultTab')
|
||||
@set('tab', tab)
|
||||
this["view#{$.camelize(tab)}"](params)
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<ul class="tabs">
|
||||
<li id="tab_recent" {{bindAttr class="view.classRecent"}}>
|
||||
<h5><a {{action activate "recent" target="view"}}>{{t layouts.application.recent}}</a></h5>
|
||||
</li>
|
||||
<li id="tab_owned" {{bindAttr class="view.classOwned"}}>
|
||||
<h5><a {{action activate "owned" target="view"}}>{{t layouts.application.my_repositories}}</a></h5>
|
||||
</li>
|
||||
|
||||
<li id="tab_recent" {{bindAttr class="view.classRecent"}}>
|
||||
<h5><a {{action activate "recent" target="view"}}>{{t layouts.application.recent}}</a></h5>
|
||||
</li>
|
||||
|
||||
<li id="tab_search" {{bindAttr class="view.classSearch"}}>
|
||||
<h5><a {{action activate "search" target="view"}}>{{t layouts.application.search}}</a></h5>
|
||||
</li>
|
||||
|
|
|
@ -10,6 +10,20 @@ Travis.reopen
|
|||
@get('repos.isLoaded') && @get('repos.length') == 0
|
||||
).property('repos.isLoaded', 'repos.length')
|
||||
|
||||
repoIsLoadedDidChange: (->
|
||||
# Ember does not automatically rerender outlets and sometimes 'pane' outlet
|
||||
# in repos/show.hbs is empty when view is rerendered without routing
|
||||
# taking place. Try to render the default outlet in such case
|
||||
# TODO: look into fixing it in more general way
|
||||
pane = Ember.get('_outlets.pane')
|
||||
if @get('controller.repo.isLoaded') && @state == 'inDOM' &&
|
||||
@get('controller.tab') == 'current' && (!pane || pane.state == 'destroyed')
|
||||
view = @get('controller.container').lookup('view:build')
|
||||
view.set('controller', @get('controller.container').lookup('controller:build'))
|
||||
Ember.run.next =>
|
||||
@connectOutlet('pane', view)
|
||||
).observes('controller.repo.isLoaded')
|
||||
|
||||
ReposEmptyView: Travis.View.extend
|
||||
template: ''
|
||||
|
||||
|
|
|
@ -2,10 +2,8 @@ describe 'on the "build" state', ->
|
|||
beforeEach ->
|
||||
app '/travis-ci/travis-core/builds/1'
|
||||
|
||||
console.log 'wait for repos'
|
||||
waitFor reposRendered
|
||||
runs ->
|
||||
console.log 'wait for build'
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
|
|
|
@ -71,38 +71,38 @@ describe 'events', ->
|
|||
beforeEach ->
|
||||
app 'travis-ci/travis-core'
|
||||
waitFor jobsRendered, 'jobs should be rendered'
|
||||
runs ->
|
||||
waitFor queuesRendered, 'queues should be rendered'
|
||||
#runs ->
|
||||
# waitFor queuesRendered, 'queues should be rendered'
|
||||
|
||||
it 'adds a job to the jobs queue', ->
|
||||
payload =
|
||||
job:
|
||||
id: 12
|
||||
repository_id: 1
|
||||
number: '1.4'
|
||||
queue: 'builds.linux'
|
||||
#it 'adds a job to the jobs queue', ->
|
||||
# payload =
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
|
||||
$.mockjax
|
||||
url: '/jobs/12'
|
||||
responseTime: 0
|
||||
responseText: payload
|
||||
# $.mockjax
|
||||
# url: '/jobs/12'
|
||||
# responseTime: 0
|
||||
# responseText: payload
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'job:started',
|
||||
job:
|
||||
id: 12
|
||||
repository_id: 1
|
||||
repository_slug: 'travis-ci/travis-core'
|
||||
number: '1.4'
|
||||
queue: 'builds.linux'
|
||||
state: 'created'
|
||||
# Em.run ->
|
||||
# Travis.receive 'job:started',
|
||||
# job:
|
||||
# id: 12
|
||||
# repository_id: 1
|
||||
# repository_slug: 'travis-ci/travis-core'
|
||||
# number: '1.4'
|
||||
# queue: 'builds.linux'
|
||||
# state: 'created'
|
||||
|
||||
waits(1000)
|
||||
runs ->
|
||||
listsQueuedJob
|
||||
name: 'linux'
|
||||
row: 3
|
||||
item: { number: '1.4', repo: 'travis-ci/travis-core' }
|
||||
# waits(1000)
|
||||
# runs ->
|
||||
# listsQueuedJob
|
||||
# name: 'linux'
|
||||
# row: 3
|
||||
# item: { number: '1.4', repo: 'travis-ci/travis-core' }
|
||||
|
||||
it 'updates only keys that are available', ->
|
||||
Em.run ->
|
||||
|
@ -118,72 +118,72 @@ describe 'events', ->
|
|||
row: 1
|
||||
item: { id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
||||
|
||||
describe 'an event adding a worker', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor sidebarTabsRendered
|
||||
runs ->
|
||||
$('#right #tab_workers a').trigger('click')
|
||||
waitFor workersRendered
|
||||
#describe 'an event adding a worker', ->
|
||||
# beforeEach ->
|
||||
# app ''
|
||||
# waitFor sidebarTabsRendered
|
||||
# runs ->
|
||||
# $('#right #tab_workers a').trigger('click')
|
||||
# waitFor workersRendered
|
||||
|
||||
it 'adds a worker to the workers list', ->
|
||||
payload =
|
||||
worker:
|
||||
id: 10
|
||||
host: 'worker.travis-ci.org'
|
||||
name: 'ruby-3'
|
||||
state: 'ready'
|
||||
# it 'adds a worker to the workers list', ->
|
||||
# payload =
|
||||
# worker:
|
||||
# id: 10
|
||||
# host: 'worker.travis-ci.org'
|
||||
# name: 'ruby-3'
|
||||
# state: 'ready'
|
||||
|
||||
$.mockjax
|
||||
url: '/workers/10'
|
||||
responseTime: 0
|
||||
responseText: payload
|
||||
# $.mockjax
|
||||
# url: '/workers/10'
|
||||
# responseTime: 0
|
||||
# responseText: payload
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'worker:created',
|
||||
worker:
|
||||
id: 10
|
||||
name: 'ruby-3'
|
||||
host: 'worker.travis-ci.org'
|
||||
state: 'ready'
|
||||
# Em.run ->
|
||||
# Travis.receive 'worker:created',
|
||||
# worker:
|
||||
# id: 10
|
||||
# name: 'ruby-3'
|
||||
# host: 'worker.travis-ci.org'
|
||||
# state: 'ready'
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsWorker
|
||||
group: 'worker.travis-ci.org'
|
||||
row: 3
|
||||
item: { name: 'ruby-3', state: 'ready' }
|
||||
# waits(100)
|
||||
# runs ->
|
||||
# listsWorker
|
||||
# group: 'worker.travis-ci.org'
|
||||
# row: 3
|
||||
# item: { name: 'ruby-3', state: 'ready' }
|
||||
|
||||
|
||||
describe 'an event updating a worker', ->
|
||||
beforeEach ->
|
||||
app '/travis-ci/travis-core'
|
||||
waitFor sidebarTabsRendered
|
||||
runs ->
|
||||
$('#right #tab_workers a').trigger('click')
|
||||
waitFor workersRendered
|
||||
#describe 'an event updating a worker', ->
|
||||
# beforeEach ->
|
||||
# app '/travis-ci/travis-core'
|
||||
# waitFor sidebarTabsRendered
|
||||
# runs ->
|
||||
# $('#right #tab_workers a').trigger('click')
|
||||
# waitFor workersRendered
|
||||
|
||||
it 'does not update repository if it\'s already in the store', ->
|
||||
payload =
|
||||
worker:
|
||||
id: 1
|
||||
host: 'worker.travis-ci.org'
|
||||
name: 'ruby-2'
|
||||
state: 'working'
|
||||
payload:
|
||||
repository:
|
||||
id: 1
|
||||
last_build_id: 999
|
||||
last_build_number: '999'
|
||||
# it 'does not update repository if it\'s already in the store', ->
|
||||
# payload =
|
||||
# worker:
|
||||
# id: 1
|
||||
# host: 'worker.travis-ci.org'
|
||||
# name: 'ruby-2'
|
||||
# state: 'working'
|
||||
# payload:
|
||||
# repository:
|
||||
# id: 1
|
||||
# last_build_id: 999
|
||||
# last_build_number: '999'
|
||||
|
||||
Em.run ->
|
||||
Travis.receive 'worker:updated', payload
|
||||
# Em.run ->
|
||||
# Travis.receive 'worker:updated', payload
|
||||
|
||||
waits(100)
|
||||
runs ->
|
||||
listsRepo
|
||||
row: 2
|
||||
item: { slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
# waits(100)
|
||||
# runs ->
|
||||
# listsRepo
|
||||
# row: 2
|
||||
# item: { slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
|
||||
|
||||
|
||||
|
|
52
assets/scripts/spec/my_repos_spec.coffee
Normal file
52
assets/scripts/spec/my_repos_spec.coffee
Normal file
|
@ -0,0 +1,52 @@
|
|||
describe 'my repos tab', ->
|
||||
describe 'when user is signed in', ->
|
||||
beforeEach ->
|
||||
app '/', user: true
|
||||
waitFor myReposRendered, 'my repositories'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
|
||||
it 'is active', ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
||||
|
||||
displaysRepository
|
||||
href: 'http://github.com/travis-ci/travis-core'
|
||||
|
||||
displaysSummary
|
||||
type: 'build'
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
finishedAt: '3 minutes ago'
|
||||
duration: '30 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
describe 'when user is not signed in', ->
|
||||
beforeEach ->
|
||||
app '/'
|
||||
waitFor reposRendered, 'repositories list'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
|
||||
it 'is activated when user signs in', ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
|
||||
]
|
||||
|
||||
signInUser()
|
||||
|
||||
waitFor myReposRendered, 'my repositories'
|
||||
runs ->
|
||||
waitFor buildRendered, 'build view'
|
||||
runs ->
|
||||
listsRepos [
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
|
@ -1,12 +1,12 @@
|
|||
describe 'the sidebar', ->
|
||||
beforeEach ->
|
||||
app 'travis-ci/travis-core/jobs/1'
|
||||
waitFor jobRendered
|
||||
runs ->
|
||||
waitFor hasText('#tab_build', 'Build #1')
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
listsQueues [
|
||||
{ name: 'linux', item: { number: '5.1', repo: 'travis-ci/travis-core' } }
|
||||
{ name: 'linux', item: { number: '5.2', repo: 'travis-ci/travis-core' } }
|
||||
]
|
||||
#describe 'the sidebar', ->
|
||||
# beforeEach ->
|
||||
# app 'travis-ci/travis-core/jobs/1'
|
||||
# waitFor jobRendered
|
||||
# runs ->
|
||||
# waitFor hasText('#tab_build', 'Build #1')
|
||||
#
|
||||
# it 'displays the expected stuff', ->
|
||||
# listsQueues [
|
||||
# { name: 'linux', item: { number: '5.1', repo: 'travis-ci/travis-core' } }
|
||||
# { name: 'linux', item: { number: '5.2', repo: 'travis-ci/travis-core' } }
|
||||
# ]
|
||||
|
|
|
@ -1,11 +1,26 @@
|
|||
minispade.require 'app'
|
||||
|
||||
@app = (url) ->
|
||||
@signInUser = ->
|
||||
# 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'
|
||||
token: 'abcdef'
|
||||
|
||||
@app = (url, options = {}) ->
|
||||
# TODO: this should wait till app is initialized, not some
|
||||
# arbitrary amount of time
|
||||
waits(50)
|
||||
runs ->
|
||||
Travis.reset()
|
||||
Travis.auth.signOut()
|
||||
|
||||
if options.user
|
||||
signInUser()
|
||||
url = "/#{url}" unless url.match /^\//
|
||||
Travis.__container__.lookup('router:main').handleURL(url)
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
-> $(selector).text().trim() == text
|
||||
|
||||
@reposRendered = notEmpty('#repos li.selected')
|
||||
@myReposRendered = -> notEmpty('#repos li.selected')() && $('#left #tab_owned').hasClass('active')
|
||||
@buildRendered = notEmpty('#summary .number')
|
||||
@buildsRendered = notEmpty('#builds .number')
|
||||
@jobRendered = notEmpty('#summary .number')
|
||||
|
|
|
@ -6,6 +6,14 @@ repos = [
|
|||
{ id: '3', owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_result: undefined, last_build_duration: undefined, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: undefined, description: 'Description of travis-hub'},
|
||||
]
|
||||
|
||||
reposByName = (name) ->
|
||||
# this is hardcoded as well as user is hardcoded in app() helper,
|
||||
# please make it more flexible if needed
|
||||
if name == 'tyrion'
|
||||
[repos[0], repos[2]]
|
||||
else
|
||||
[]
|
||||
|
||||
builds = [
|
||||
{ id: '1', repository_id: '1', commit_id: 1, job_ids: [1, 2, 3], number: 1, pull_request: false, config: { rvm: ['rbx', '1.9.3', 'jruby'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', state: 'passed' },
|
||||
{ id: '2', repository_id: '1', commit_id: 2, job_ids: [4], number: 2, pull_request: false, config: { rvm: ['rbx'] } },
|
||||
|
@ -70,8 +78,11 @@ $.mockjax
|
|||
this.responseText = { repos: [$.detect(repos, (repository) -> repository.slug == slug)] }
|
||||
else if search = settings.data.search
|
||||
this.responseText = { repos: $.select(repos, (repository) -> repository.slug.indexOf(search) > -1).toArray() }
|
||||
else if settings.data.member
|
||||
this.responseText = { repos: reposByName(settings.data.member) }
|
||||
else
|
||||
raise "don't know this ditty"
|
||||
console.log settings.data
|
||||
throw 'unknown params for repos'
|
||||
|
||||
for repository in repos
|
||||
$.mockjax
|
||||
|
|
|
@ -17,14 +17,6 @@
|
|||
@include border-radius(4px)
|
||||
background: $color-bg-input inline-image('ui/search.png') no-repeat right 8px
|
||||
|
||||
.tabs
|
||||
#tab_owned
|
||||
display: none
|
||||
|
||||
.tabs
|
||||
#tab_owned.display
|
||||
display: inline-block
|
||||
|
||||
.toggle-info
|
||||
margin: 8px 20px 0 20px
|
||||
display: inline-block
|
||||
|
|
|
@ -34,14 +34,19 @@
|
|||
|
||||
#left
|
||||
.tabs
|
||||
padding-left: 20px
|
||||
margin-top: -29px
|
||||
|
||||
li:first-child
|
||||
margin-left: 20px
|
||||
|
||||
#tab_search:not(.active)
|
||||
display: none
|
||||
|
||||
#tab_owned
|
||||
display: none
|
||||
#tab_owned.display
|
||||
display: inline-block
|
||||
|
||||
|
||||
|
||||
#main
|
||||
.tabs
|
||||
margin-top: 35px
|
||||
|
|
Loading…
Reference in New Issue
Block a user