Merge branch 'master' of github.com:travis-ci/travis-web

Conflicts:
	Gemfile.lock
This commit is contained in:
Sven Fuchs 2012-12-14 14:12:14 +01:00
commit 07670570ca
38 changed files with 330 additions and 127 deletions

View File

@ -1,3 +1,3 @@
--- ---
:polled_at: 1354548824 :polled_at: 1355238733
:updated_at: 1354548824 :updated_at: 1355238733

View File

@ -3,7 +3,16 @@ rvm:
- 1.9.3 - 1.9.3
before_script: before_script:
- bundle exec rakep - bundle exec rakep
script: "bundle exec rspec spec" env:
- "TEST_SUITE=spec"
- "TEST_SUITE=ember"
script: "script/ci"
matrix:
allow_failures:
- env: "TEST_SUITE=ember"
rvm: "1.9.3"
notifications: notifications:
irc: "irc.freenode.org#travis" irc: "irc.freenode.org#travis"
campfire: campfire:

View File

@ -4,6 +4,7 @@ source :rubygems
gem 'puma' gem 'puma'
gem 'rack-ssl', '~> 1.3' gem 'rack-ssl', '~> 1.3'
gem 'rack-protection', '~> 1.3'
gem 'rack-cache' gem 'rack-cache'
gem 'rack-mobile-detect' gem 'rack-mobile-detect'
gem 'sinatra' gem 'sinatra'

View File

@ -71,9 +71,7 @@ GEM
rack (1.4.1) rack (1.4.1)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-mobile-detect (0.4.0) rack-protection (1.2.0)
rack
rack-protection (1.3.2)
rack rack
rack-ssl (1.3.2) rack-ssl (1.3.2)
rack rack
@ -130,7 +128,6 @@ DEPENDENCIES
localeapp-handlebars_i18n localeapp-handlebars_i18n
puma puma
rack-cache rack-cache
rack-mobile-detect
rack-ssl (~> 1.3) rack-ssl (~> 1.3)
rake (~> 0.9.2) rake (~> 0.9.2)
rake-pipeline! rake-pipeline!

View File

@ -9,23 +9,23 @@
window.addEventListener('message', (e) => @receiveMessage(e)) window.addEventListener('message', (e) => @receiveMessage(e))
accessToken: (-> accessToken: (->
sessionStorage.getItem('travis.token') Travis.sessionStorage.getItem('travis.token')
).property() ).property()
# if the user is in the session storage, we're using it. if we have a flag # if the user is in the session storage, we're using it. if we have a flag
# for auto signin then we're trying to sign in. # for auto signin then we're trying to sign in.
autoSignIn: (path) -> autoSignIn: (path) ->
console.log 'autoSignIn' console.log 'autoSignIn'
global = localStorage.getItem('travis.user') global = Travis.storage.getItem('travis.user')
session = sessionStorage.getItem('travis.user') session = Travis.sessionStorage.getItem('travis.user')
user = session || global user = session || global
if user if user
localStorage.setItem('travis.user', user) unless global Travis.storage.setItem('travis.user', user) unless global
data = JSON.parse(user) data = JSON.parse(user)
data = { user: data } unless data.user? data = { user: data } unless data.user?
@setData(data) @setData(data)
else if localStorage.getItem('travis.auto_signin') else if Travis.storage.getItem('travis.auto_signin')
console.log 'travis.auto_signin', localStorage.getItem('travis.auto_signin') console.log 'travis.auto_signin', Travis.storage.getItem('travis.auto_signin')
@signIn() @signIn()
# try signing in, but check later in case we have a timeout # try signing in, but check later in case we have a timeout
@ -36,11 +36,12 @@
Ember.run.later(this, @checkSignIn.bind(this), @timeout) Ember.run.later(this, @checkSignIn.bind(this), @timeout)
signOut: -> signOut: ->
localStorage.removeItem('travis.auto_signin') Travis.storage.removeItem('travis.auto_signin')
localStorage.removeItem('travis.locale') Travis.storage.removeItem('travis.locale')
localStorage.removeItem('travis.user') Travis.storage.removeItem('travis.user')
localStorage.removeItem('travis.token') Travis.storage.removeItem('travis.token')
sessionStorage.clear() Travis.sessionStorage.clear()
Travis.setLocale Travis.default_locale
@setData() @setData()
trySignIn: -> trySignIn: ->
@ -52,7 +53,7 @@
forceSignIn: -> forceSignIn: ->
console.log 'forceSignIn' console.log 'forceSignIn'
localStorage.setItem('travis.auto_signin', 'true') Travis.storage.setItem('travis.auto_signin', 'true')
window.location = "#{@endpoint}/auth/handshake?redirect_uri=#{location}" window.location = "#{@endpoint}/auth/handshake?redirect_uri=#{location}"
# TODO should have clearData() to clean this up # TODO should have clearData() to clean this up
@ -65,30 +66,31 @@
@afterSignIn(data.user) if data?.user @afterSignIn(data.user) if data?.user
afterSignIn: (user) -> afterSignIn: (user) ->
Travis.setLocale user.locale || Travis.default_locale
Travis.trigger('user:signed_in', user) Travis.trigger('user:signed_in', user)
@get('app.router').send('afterSignIn', @readAfterSignInPath()) @get('app.router').send('afterSignIn', @readAfterSignInPath())
storeToken: (token) -> storeToken: (token) ->
token = token || localStorage.getItem('travis.token') token = token || Travis.storage.getItem('travis.token')
if token if token
localStorage.setItem('travis.token', token) Travis.storage.setItem('travis.token', token)
sessionStorage.setItem('travis.token', token) Travis.sessionStorage.setItem('travis.token', token)
@notifyPropertyChange('accessToken') @notifyPropertyChange('accessToken')
storeUser: (user) -> storeUser: (user) ->
localStorage.setItem('travis.auto_signin', 'true') Travis.storage.setItem('travis.auto_signin', 'true')
sessionStorage.setItem('travis.user', JSON.stringify(user)) Travis.sessionStorage.setItem('travis.user', JSON.stringify(user))
@app.store.load(Travis.User, user) @app.store.load(Travis.User, user)
user = @app.store.find(Travis.User, user.id) user = @app.store.find(Travis.User, user.id)
user.get('permissions') user.get('permissions')
user user
storeAfterSignInPath: (path) -> storeAfterSignInPath: (path) ->
sessionStorage.setItem('travis.after_signin_path', path) Travis.sessionStorage.setItem('travis.after_signin_path', path)
readAfterSignInPath: -> readAfterSignInPath: ->
path = sessionStorage.getItem('travis.after_signin_path') path = Travis.sessionStorage.getItem('travis.after_signin_path')
sessionStorage.removeItem('travis.after_signin_path') Travis.sessionStorage.removeItem('travis.after_signin_path')
path path
receiveMessage: (event) -> receiveMessage: (event) ->

View File

@ -2,7 +2,6 @@ require 'travis/limited_array'
Travis.ReposController = Ember.ArrayController.extend Travis.ReposController = Ember.ArrayController.extend
defaultTab: 'recent' defaultTab: 'recent'
sortProperties: ['sortOrder']
isLoadedBinding: 'content.isLoaded' isLoadedBinding: 'content.isLoaded'
init: -> init: ->
@ -21,7 +20,10 @@ Travis.ReposController = Ember.ArrayController.extend
viewRecent: -> viewRecent: ->
content = Travis.LimitedArray.create content = Travis.LimitedArray.create
content: Travis.Repo.find() content: Em.ArrayProxy.extend(Em.SortableMixin).create(
sortProperties: ['sortOrder']
content: Travis.Repo.find()
)
limit: 30 limit: 30
@set('content', content) @set('content', content)
# @set('content', Travis.Repo.find()) # @set('content', Travis.Repo.find())

View File

@ -1,3 +1,4 @@
require 'helpers/handlebars' require 'helpers/handlebars'
require 'helpers/helpers' require 'helpers/helpers'
require 'helpers/urls' require 'helpers/urls'
require 'helpers/i18n_handlebars'

View File

@ -6,11 +6,11 @@ safe = (string) ->
Handlebars.registerHelper 'tipsy', (text, tip) -> Handlebars.registerHelper 'tipsy', (text, tip) ->
safe '<span class="tool-tip" original-title="' + tip + '">' + text + '</span>' safe '<span class="tool-tip" original-title="' + tip + '">' + text + '</span>'
Handlebars.registerHelper 't', (key) ->
safe I18n.t(key)
Ember.registerBoundHelper 'capitalize', (value, options) -> Ember.registerBoundHelper 'capitalize', (value, options) ->
safe $.capitalize(value) if value?
safe $.capitalize(value)
else
''
Ember.registerBoundHelper 'formatTime', (value, options) -> Ember.registerBoundHelper 'formatTime', (value, options) ->
safe Travis.Helpers.timeAgoInWords(value) || '-' safe Travis.Helpers.timeAgoInWords(value) || '-'

View File

@ -0,0 +1,34 @@
I18nBoundView = Ember.View.extend Ember._Metamorph, {
key: null,
valueDidChange: ->
return if this.morph.isRemoved()
this.morph.html(this.valueForRender())
valueForRender: ->
new Handlebars.SafeString I18n.t(this.key)
init: ->
this._super()
Travis.addObserver('locale', this, 'valueDidChange')
didInsertElement: ->
this.valueDidChange()
destroy: ->
Travis.removeObserver('locale', this, 'valueDidChange')
this._super()
render: (buffer) ->
buffer.push(this.valueForRender())
}
Ember.Handlebars.registerHelper 't', (key, options) ->
view = options.data.view
bindView = view.createChildView(I18nBoundView, { key: key })
view.appendChild(bindView)
# dont write any content from this helper, let the child view
# take care of itself.
false

View File

@ -30,10 +30,10 @@
"http://github.com/#{slug}/network" "http://github.com/#{slug}/network"
githubAdmin: (slug) -> githubAdmin: (slug) ->
"http://github.com/#{slug}/admin/hooks#travis_minibucket" "http://github.com/#{slug}/settings/hooks#travis_minibucket"
statusImage: (slug, branch) -> statusImage: (slug, branch) ->
"https://secure.travis-ci.org/#{slug}.png" + if branch then "?branch=#{branch}" else '' "#{location.protocol}//#{location.host}/#{slug}.png" + if branch then "?branch=#{branch}" else ''
email: (email) -> email: (email) ->
"mailto:#{email}" "mailto:#{email}"

View File

@ -12,11 +12,15 @@ require 'travis/model'
setSeen: -> setSeen: ->
Travis.Broadcast.seen.pushObject(@get('id')) Travis.Broadcast.seen.pushObject(@get('id'))
localStorage.setItem('travis.seen_broadcasts', JSON.stringify(Travis.Broadcast.seen)) Travis.storage.setItem('travis.seen_broadcasts', JSON.stringify(Travis.Broadcast.seen))
@notifyPropertyChange('isSeen') @notifyPropertyChange('isSeen')
@Travis.Broadcast.reopenClass @Travis.Broadcast.reopenClass
seen: Ember.A(JSON.parse(localStorage.getItem('travis.seen_broadcasts')) || []) seen: (->
seenBroadcasts = Travis.storage.getItem('travis.seen_broadcasts')
seenBroadcasts = JSON.parse(seenBroadcasts) if seenBroadcasts?
Ember.A(seenBroadcasts || [])
)()
# TODO fix or monkey-patch the adapter's url and key lookup/generation crap # TODO fix or monkey-patch the adapter's url and key lookup/generation crap
# url: 'users/broadcasts' # url: 'users/broadcasts'

View File

@ -19,7 +19,7 @@ require 'travis/model'
).property() ).property()
urlGithubAdmin: (-> urlGithubAdmin: (->
"http://github.com/#{@get('slug')}/admin/hooks#travis_minibucket" "http://github.com/#{@get('slug')}/settings/hooks#travis_minibucket"
).property() ).property()
toggle: -> toggle: ->

View File

@ -12,6 +12,14 @@ require 'travis/model'
lastBuild: DS.belongsTo('Travis.Build') lastBuild: DS.belongsTo('Travis.Build')
lastBuildHash: (->
{
id: @get('lastBuildId')
number: @get('lastBuildNumber')
repo: this
}
).property('lastBuildId', 'lastBuildNumber')
allBuilds: (-> allBuilds: (->
allBuilds = DS.RecordArray.create allBuilds = DS.RecordArray.create
type: Travis.Build type: Travis.Build

View File

@ -19,7 +19,7 @@ require 'travis/model'
Ember.run.next this, -> Ember.run.next this, ->
transaction = @get('store').transaction() transaction = @get('store').transaction()
transaction.add this transaction.add this
urlGithub: (-> urlGithub: (->
"https://github.com/#{@get('login')}" "https://github.com/#{@get('login')}"
).property() ).property()
@ -32,8 +32,7 @@ require 'travis/model'
).property() ).property()
updateLocale: (locale) -> updateLocale: (locale) ->
@setWithSession('locale', locale)
transaction = @get('transaction') transaction = @get('transaction')
transaction.commit() transaction.commit()
@ -45,6 +44,7 @@ require 'travis/model'
transaction.add self transaction.add self
@addObserver 'isSaving', observer @addObserver 'isSaving', observer
Travis.setLocale(locale)
type: (-> type: (->
'user' 'user'
@ -71,6 +71,6 @@ require 'travis/model'
setWithSession: (name, value) -> setWithSession: (name, value) ->
@set(name, value) @set(name, value)
user = JSON.parse(sessionStorage?.getItem('travis.user')) user = JSON.parse(Travis.sessionStorage.getItem('travis.user'))
user[$.underscore(name)] = @get(name) user[$.underscore(name)] = @get(name)
sessionStorage?.setItem('travis.user', JSON.stringify(user)) Travis.sessionStorage.setItem('travis.user', JSON.stringify(user))

View File

@ -115,6 +115,7 @@ Travis.Router = Ember.Router.extend
router.get('accountsController').set('content', Travis.Account.find()) router.get('accountsController').set('content', Travis.Account.find())
router.get('applicationController').connectOutlet 'top', 'top' router.get('applicationController').connectOutlet 'top', 'top'
router.get('applicationController').connectOutlet 'left', 'accounts' router.get('applicationController').connectOutlet 'left', 'accounts'
router.get('applicationController').connectOutlet 'flash', 'flash'
index: Ember.Route.extend index: Ember.Route.extend
route: '/' route: '/'

View File

@ -1,10 +1,10 @@
@Travis.Slider = -> @Travis.Slider = ->
@minimize() if localStorage?.getItem('travis.maximized') == 'true' @minimize() if Travis.storage.getItem('travis.maximized') == 'true'
this this
$.extend Travis.Slider.prototype, $.extend Travis.Slider.prototype,
persist: -> persist: ->
localStorage?.setItem('travis.maximized', @isMinimized()) Travis.storage.setItem('travis.maximized', @isMinimized())
isMinimized: -> isMinimized: ->
return $('body').hasClass('maximized'); return $('body').hasClass('maximized');

View File

@ -25,18 +25,16 @@
{{user.token}} {{user.token}}
</dd> </dd>
</div> </div>
<div>
<dt>
{{t profiles.show.locale}}:
</dt>
<dd>
{{view Ember.Select id="locale"
contentBinding="view.locales"
valueBinding="Travis.app.currentUser.locale"
optionLabelPath="content.name"
optionValuePath="content.key"}}
</dd>
</div>
</dl> </dl>
<form>
{{view Ember.Select id="locale"
contentBinding="view.locales"
valueBinding="Travis.app.currentUser.locale"
optionLabelPath="content.name"
optionValuePath="content.key"}}
<button name="commit" {{action saveLocale target="view"}}>
{{t profiles.show.update_locale}}
</button>
</form>

View File

@ -13,9 +13,11 @@
<a {{action showRepo this href=true}} class="slug">{{slug}}</a> <a {{action showRepo this href=true}} class="slug">{{slug}}</a>
{{/if}} {{/if}}
</div> </div>
{{#if lastBuildId}} {{#with lastBuildHash}}
<a {{action showBuild this lastBuildId href=true}} class="last_build">{{lastBuildNumber}}</a> {{#if id}}
{{/if}} <a {{action showBuild repo id href=true}} class="last_build">{{number}}</a>
{{/if}}
{{/with}}
<p class="summary"> <p class="summary">
<span class="duration_label">{{t repositories.duration}}:</span> <span class="duration_label">{{t repositories.duration}}:</span>

View File

@ -37,20 +37,24 @@
</li> </li>
<li id="tab_build" {{bindAttr class="view.classBuild"}}> <li id="tab_build" {{bindAttr class="view.classBuild"}}>
<h5> <h5>
{{#if view.build.id}} {{#with view.build}}
<a {{action showBuild view.repo view.build href=true}}> {{#if id}}
{{t repositories.tabs.build}} #{{view.build.number}} <a {{action showBuild repo this href=true}}>
</a> {{t repositories.tabs.build}} #{{number}}
{{/if}} </a>
{{/if}}
{{/with}}
</h5> </h5>
</li> </li>
<li id="tab_job" {{bindAttr class="view.classJob"}}> <li id="tab_job" {{bindAttr class="view.classJob"}}>
<h5> <h5>
{{#if view.job.id}} {{#with view.job}}
<a {{action showJob view.repo view.job href=true}}> {{#if id}}
{{t repositories.tabs.job}} #{{view.job.number}} <a {{action showJob repo this href=true}}>
</a> {{t repositories.tabs.job}} #{{number}}
{{/if}} </a>
{{/if}}
{{/with}}
</h5> </h5>
</li> </li>
</ul> </ul>

View File

@ -12,13 +12,6 @@
# popup: (event) -> # popup: (event) ->
# console.log event # console.log event
localeDidChange: (->
if locale = Travis.app.get('auth.user.locale')
if Travis.needsLocaleChange(locale)
Travis.setLocale(locale)
Travis.app.get('router').reload()
).observes('Travis.app.auth.user.locale')
click: (event) -> click: (event) ->
# TODO: this solves the case of closing menus and popups, # TODO: this solves the case of closing menus and popups,
# but I would like to rewrite it later, not sure how # but I would like to rewrite it later, not sure how

View File

@ -44,26 +44,25 @@
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm" "#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
).property('user.gravatarId') ).property('user.gravatarId')
# locale: (-> locale: (->
# @get('user.locale') @get('user.locale')
# ).property('user.locale') ).property('user.locale')
locales: (-> locales: (->
[ [
{ key: null, name: '' } { key: null, name: '' }
{ key: 'en', name: 'English' } { key: 'en', name: 'English' }
{ key: 'ca', name: 'Catalan' }
{ key: 'cs', name: 'Čeština' }
{ key: 'es', name: 'Español' } { key: 'es', name: 'Español' }
{ key: 'fr', name: 'Français' } { key: 'fr', name: 'Français' }
{ key: 'ja', name: '日本語' } { key: 'ja', name: '日本語' }
{ key: 'nl', name: 'Nederlands' } { key: 'nl', name: 'Nederlands' }
{ key: 'nb', name: 'Norsk Bokmål' } { key: 'nb', name: 'Norsk Bokmål' }
{ key: 'pl', name: 'Polski' } { key: 'pl', name: 'Polski' }
{ key: 'pt-BR': name: 'Português brasileiro' } { key: 'pt-BR', name: 'Português brasileiro' }
{ key: 'ru', name: 'Русский' } { key: 'ru', name: 'Русский' }
] ]
).property() ).property()
saveLocale: (event) -> change: (event) ->
return unless $('#locale').val()
@get('user').updateLocale($('#locale').val()) @get('user').updateLocale($('#locale').val())

View File

@ -45,7 +45,6 @@
didInsertElement: -> didInsertElement: ->
queues = for queue in Travis.QUEUES queues = for queue in Travis.QUEUES
Travis.LimitedArray.create Travis.LimitedArray.create
debug: true
content: Travis.Job.queued(queue.name), limit: 20 content: Travis.Job.queued(queue.name), limit: 20
id: "queue_#{queue.name}" id: "queue_#{queue.name}"
name: queue.display name: queue.display

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,7 @@ jQuery.support.cors = true
endpoint = Travis.config.api_endpoint || '' endpoint = Travis.config.api_endpoint || ''
options = options || {} options = options || {}
if token = sessionStorage.getItem('travis.token') if token = Travis.sessionStorage.getItem('travis.token')
options.headers ||= {} options.headers ||= {}
options.headers['Authorization'] ||= "token #{token}" options.headers['Authorization'] ||= "token #{token}"

View File

@ -7,11 +7,11 @@ Travis.LimitedArray = Em.ArrayProxy.extend
arrangedContent: (-> arrangedContent: (->
content = @get('content') content = @get('content')
if @get('disable') if @get('disabled')
content content
else if content else if content
content.slice(0, @get('limit')) content.slice(0, @get('limit'))
).property('content', 'limit', 'disable') ).property('content', 'limit', 'disabled')
totalLength: (-> totalLength: (->
@get('content.length') @get('content.length')
@ -20,40 +20,49 @@ Travis.LimitedArray = Em.ArrayProxy.extend
leftLength: (-> leftLength: (->
totalLength = @get('totalLength') totalLength = @get('totalLength')
limit = @get('limit') limit = @get('limit')
if totalLength > limit
totalLength - limit if @get('disabled') || totalLength <= limit
else
0 0
).property('totalLength', 'limit') else
totalLength - limit
).property('totalLength', 'limit', 'disabled')
isMore: (-> isMore: (->
@get('leftLength') > 0 !@get('disabled') && @get('leftLength') > 0
).property('leftLength') ).property('leftLength')
showAll: -> showAll: ->
@set 'limit', 1000000000 @set 'disabled', true
@set 'disable', true
contentArrayWillChange: (array, index, removedCount, addedCount) ->
@_super.apply this, arguments
return if @get('disabled')
if removedCount
arrangedContent = @get 'arrangedContent'
removedObjects = array.slice(index, index + removedCount);
arrangedContent.removeObjects(removedObjects)
contentArrayDidChange: (array, index, removedCount, addedCount) -> contentArrayDidChange: (array, index, removedCount, addedCount) ->
@_super.apply this, arguments @_super.apply this, arguments
return if @get('disable') return if @get('disabled')
limit = @get('limit')
if addedCount
if index < limit
addedObjects = array.slice(index, index + addedCount)
@replaceContent(index, 0, addedObjects)
@balanceArray()
balanceArray: ->
limit = @get 'limit' limit = @get 'limit'
arrangedContent = @get('arrangedContent') arrangedContent = @get 'arrangedContent'
length = arrangedContent.get 'length' length = arrangedContent.get 'length'
content = @get 'content'
if addedCount > 0
addedObjects = array.slice(index, index + addedCount)
for object in addedObjects
arrangedContent.unshiftObject(object)
if removedCount
removedObjects = array.slice(index, index + removedCount);
arrangedContent.removeObjects(removedObjects)
length = arrangedContent.get 'length'
content = @get('content')
if length > limit if length > limit
arrangedContent.replace(limit, length - limit) arrangedContent.replace(limit, length - limit)
@ -61,5 +70,5 @@ Travis.LimitedArray = Em.ArrayProxy.extend
count = limit - length count = limit - length
while count > 0 while count > 0
if next = content.find( (object) -> !arrangedContent.contains(object) ) if next = content.find( (object) -> !arrangedContent.contains(object) )
arrangedContent.unshiftObject(next) arrangedContent.pushObject(next)
count -= 1 count -= 1

View File

@ -0,0 +1,46 @@
describe 'Travis.LimitedArray', ->
it 'limits given content', ->
content = [1, 2, 3]
array = Travis.LimitedArray.create content: content, limit: 2
expect( array.get('length') ).toEqual 2
expect( array.toArray() ).toEqual [1, 2]
it 'inserts content at the right place when unshifting', ->
content = [1, 2, 3]
array = Travis.LimitedArray.create content: content, limit: 2
content.unshiftObject 0
expect( array.get('length') ).toEqual 2
expect( array.toArray() ).toEqual [0, 1]
it 'does not insert content when it\'s inserted not in the limited range', ->
content = [1, 2, 3]
array = Travis.LimitedArray.create content: content, limit: 2
content.pushObject 0
expect( array.get('length') ).toEqual 2
expect( array.toArray() ).toEqual [1, 2]
it 'properly removes items', ->
content = [1, 2, 3]
array = Travis.LimitedArray.create content: content, limit: 2
content.shiftObject()
expect( array.get('length') ).toEqual 2
expect( array.toArray() ).toEqual [2, 3]
content.shiftObject()
expect( array.get('length') ).toEqual 1
expect( array.toArray() ).toEqual [3]
content.shiftObject()
expect( array.get('length') ).toEqual 0
it 'allows to expand array to show all items', ->
content = [1, 2, 3]
array = Travis.LimitedArray.create content: content, limit: 2
array.showAll()
expect( array.get('length') ).toEqual 3
expect( array.toArray() ).toEqual [1, 2, 3]

View File

@ -13,6 +13,22 @@ if window.history.state == undefined
window.history.state = state window.history.state = state
oldReplaceState.apply this, arguments oldReplaceState.apply this, arguments
# TODO: how can I put it in Travis namespace and use immediately?
Storage = Em.Object.extend
init: ->
@set('storage', {})
key: (key) ->
"__#{key.replace('.', '__')}"
getItem: (k) ->
return @get("storage.#{@key(k)}")
setItem: (k,v) ->
@set("storage.#{@key(k)}", v)
removeItem: (k) ->
@setItem(k, null)
clear: ->
@set('storage', {})
@Travis = Em.Namespace.create Ember.Evented, @Travis = Em.Namespace.create Ember.Evented,
config: config:
api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href') api_endpoint: $('meta[rel="travis.api_endpoint"]').attr('href')
@ -48,16 +64,36 @@ if window.history.state == undefined
setLocale: (locale) -> setLocale: (locale) ->
return unless locale return unless locale
I18n.locale = locale I18n.locale = locale
localStorage.setItem('travis.locale', locale) Travis.set('locale', locale)
needsLocaleChange: (locale) -> storage: (->
I18n.locale != locale storage = null
try
storage = window.localStorage || throw('no storage')
catch err
storage = Storage.create()
storage
)()
default_locale: 'en'
sessionStorage: (->
storage = null
try
# firefox will not throw error on access for sessionStorage var,
# you need to actually get something from session
sessionStorage.getItem('foo')
storage = sessionStorage
catch err
storage = Storage.create()
storage
)()
run: (attrs) -> run: (attrs) ->
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!' location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
I18n.fallbacks = true I18n.fallbacks = true
@setLocale localStorage.getItem('travis.locale') || 'en' Travis.setLocale 'locale', @defualt_locale
Ember.run.next this, -> Ember.run.next this, ->
app = Travis.App.create(attrs || {}) app = Travis.App.create(attrs || {})

View File

@ -1,6 +1,7 @@
require 'rack' require 'rack'
require 'rack/ssl' require 'rack/ssl'
require 'rack/cache' require 'rack/cache'
require 'rack/protection'
require 'delegate' require 'delegate'
require 'time' require 'time'
@ -130,6 +131,9 @@ class Travis::Web::App
end end
builder.use Rack::Deflater builder.use Rack::Deflater
builder.use Rack::Head builder.use Rack::Head
builder.use Rack::Protection::XSSHeader
builder.use Rack::Protection::FrameOptions
builder.use Rack::Protection::PathTraversal
builder.use Rack::ConditionalGet builder.use Rack::ConditionalGet
builder.use MobileRedirect builder.use MobileRedirect
builder.run router builder.run router

View File

@ -19,6 +19,7 @@ en:
sponsored_by: This test series was run on a worker box sponsored by sponsored_by: This test series was run on a worker box sponsored by
name: Build name: Build
started_at: Started started_at: Started
state: state
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ en:
sponsored_by: This test series was run on a worker box sponsored by sponsored_by: This test series was run on a worker box sponsored by
sponsored_by: sponsored_by:
started_at: Started started_at: Started
state: state
layouts: layouts:
about: about:
alpha: This stuff is alpha. alpha: This stuff is alpha.
@ -82,6 +84,7 @@ en:
job: Job job: Job
log: Log log: Log
top: top:
accounts: accounts
admin: Admin admin: Admin
blog: Blog blog: Blog
docs: Docs docs: Docs
@ -89,6 +92,7 @@ en:
home: Home home: Home
profile: Profile profile: Profile
sign_out: Sign Out sign_out: Sign Out
signing_in: signing_in
stats: Stats stats: Stats
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ en:
show: show:
email: Email email: Email
github: Github github: Github
locale: locale
message: message:
config: how to configure custom build options config: how to configure custom build options
your_repos: ! " Flick the switches below to turn on the Travis service hook for your projects, then push to GitHub.<br />\n To test against multiple rubies, see" your_repos: ! " Flick the switches below to turn on the Travis service hook for your projects, then push to GitHub.<br />\n To test against multiple rubies, see"
@ -118,6 +123,7 @@ en:
your_repos: Your Repositories your_repos: Your Repositories
queue: Queue queue: Queue
repositories: repositories:
asciidoc: AsciiDoc
branch: Branch branch: Branch
commit: Commit commit: Commit
duration: Duration duration: Duration
@ -136,7 +142,6 @@ en:
pull_requests: Pull Requests pull_requests: Pull Requests
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Duration duration: Duration
statistics: statistics:

View File

@ -19,6 +19,7 @@ es:
sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por
name: Build name: Build
started_at: Iniciado started_at: Iniciado
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ es:
sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por sponsored_by: Esta serie de tests han sido ejecutados en una caja de Proceso patrocinada por
sponsored_by: Patrocinado por sponsored_by: Patrocinado por
started_at: Iniciado started_at: Iniciado
state:
layouts: layouts:
about: about:
alpha: Esto es alpha. alpha: Esto es alpha.
@ -82,6 +84,7 @@ es:
job: Trabajo job: Trabajo
log: Registro log: Registro
top: top:
accounts:
admin: Admin admin: Admin
blog: Blog blog: Blog
docs: Documentación docs: Documentación
@ -89,6 +92,7 @@ es:
home: Inicio home: Inicio
profile: Perfil profile: Perfil
sign_out: Desconectar sign_out: Desconectar
signing_in:
stats: Estadísticas stats: Estadísticas
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ es:
show: show:
email: email email: email
github: Github github: Github
locale:
message: message:
config: como configurar tus propias opciones para el Build config: como configurar tus propias opciones para el Build
your_repos: ! " Activa los interruptores para inicial el Travis service hook para tus proyectos, y haz un Push en GitHub.<br />\n Para probar varias versiones de ruby, mira" your_repos: ! " Activa los interruptores para inicial el Travis service hook para tus proyectos, y haz un Push en GitHub.<br />\n Para probar varias versiones de ruby, mira"
@ -118,6 +123,7 @@ es:
your_repos: Tus repositorios your_repos: Tus repositorios
queue: Cola queue: Cola
repositories: repositories:
asciidoc:
branch: Rama branch: Rama
commit: Commit commit: Commit
duration: Duración duration: Duración
@ -136,7 +142,6 @@ es:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Duración duration: Duración
statistics: statistics:

View File

@ -19,6 +19,7 @@ fr:
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
name: Version name: Version
started_at: Commencé started_at: Commencé
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ fr:
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par sponsored_by: Cette série de tests a été exécutée sur une machine sponsorisée par
started_at: Commencé started_at: Commencé
state:
layouts: layouts:
about: about:
alpha: Ceci est en alpha. alpha: Ceci est en alpha.
@ -82,6 +84,7 @@ fr:
job: Tâche job: Tâche
log: Journal log: Journal
top: top:
accounts:
admin: Admin admin: Admin
blog: Blog blog: Blog
docs: Documentation docs: Documentation
@ -89,6 +92,7 @@ fr:
home: Accueil home: Accueil
profile: Profil profile: Profil
sign_out: Déconnexion sign_out: Déconnexion
signing_in:
stats: Statistiques stats: Statistiques
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ fr:
show: show:
email: Courriel email: Courriel
github: Github github: Github
locale:
message: message:
config: comment configurer des options de version personnalisées config: comment configurer des options de version personnalisées
your_repos: ! 'Utilisez les boutons ci-dessous pour activer Travis sur vos projets puis déployez sur GitHub.<br /> your_repos: ! 'Utilisez les boutons ci-dessous pour activer Travis sur vos projets puis déployez sur GitHub.<br />
@ -120,6 +125,7 @@ fr:
your_repos: Vos dépôts your_repos: Vos dépôts
queue: File queue: File
repositories: repositories:
asciidoc:
branch: Branche branch: Branche
commit: Commit commit: Commit
duration: Durée duration: Durée
@ -138,7 +144,6 @@ fr:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Durée duration: Durée
statistics: statistics:

View File

@ -19,6 +19,7 @@ ja:
sponsored_by: このテストは以下のスポンサーの協力で行いました。 sponsored_by: このテストは以下のスポンサーの協力で行いました。
name: ビルド name: ビルド
started_at: 開始時刻 started_at: 開始時刻
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -47,6 +48,7 @@ ja:
sponsored_by: このテストは以下のスポンサーの協力で行いました。 sponsored_by: このテストは以下のスポンサーの協力で行いました。
sponsored_by: sponsored_by:
started_at: 開始時刻 started_at: 開始時刻
state:
layouts: layouts:
about: about:
alpha: まだアルファですよ! alpha: まだアルファですよ!
@ -76,6 +78,7 @@ ja:
job: ジョブ job: ジョブ
log: ログ log: ログ
top: top:
accounts:
admin: 管理 admin: 管理
blog: ブログ blog: ブログ
docs: Travisとは docs: Travisとは
@ -83,6 +86,7 @@ ja:
home: ホーム home: ホーム
profile: プロフィール profile: プロフィール
sign_out: ログアウト sign_out: ログアウト
signing_in:
stats: 統計 stats: 統計
locales: locales:
ca: ca:
@ -100,6 +104,7 @@ ja:
show: show:
email: メール email: メール
github: Github github: Github
locale: 言語
message: message:
config: 詳細設定 config: 詳細設定
your_repos: 以下のスイッチを設定し、Travis-ciを有効にします。Githubへプッシュしたらビルドは自動的に開始します。複数バーションや細かい設定はこちらへ your_repos: 以下のスイッチを設定し、Travis-ciを有効にします。Githubへプッシュしたらビルドは自動的に開始します。複数バーションや細かい設定はこちらへ
@ -112,6 +117,7 @@ ja:
your_repos: リポジトリ your_repos: リポジトリ
queue: キュー queue: キュー
repositories: repositories:
asciidoc:
branch: ブランチ branch: ブランチ
commit: コミット commit: コミット
duration: 処理時間 duration: 処理時間
@ -130,7 +136,6 @@ ja:
pull_requests: プルリクエスト pull_requests: プルリクエスト
test: test:
textile: .textile textile: .textile
asciidoc: .asciidoc
repository: repository:
duration: 時間 duration: 時間
statistics: statistics:

View File

@ -19,6 +19,7 @@ nb:
sponsored_by: Denne testen ble kjørt på en maskin sponset av sponsored_by: Denne testen ble kjørt på en maskin sponset av
name: Jobb name: Jobb
started_at: Startet started_at: Startet
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ nb:
sponsored_by: Denne testserien ble kjørt på en maskin sponset av sponsored_by: Denne testserien ble kjørt på en maskin sponset av
sponsored_by: sponsored_by:
started_at: Startet started_at: Startet
state:
layouts: layouts:
about: about:
alpha: Dette er alfa-greier. alpha: Dette er alfa-greier.
@ -82,6 +84,7 @@ nb:
job: Jobb job: Jobb
log: Logg log: Logg
top: top:
accounts:
admin: Administrator admin: Administrator
blog: Blogg blog: Blogg
docs: Dokumentasjon docs: Dokumentasjon
@ -89,6 +92,7 @@ nb:
home: Hjem home: Hjem
profile: Profil profile: Profil
sign_out: Logg ut sign_out: Logg ut
signing_in:
stats: Statistikk stats: Statistikk
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ nb:
show: show:
email: E-post email: E-post
github: Github github: Github
locale:
message: message:
config: hvordan sette opp egne jobbinnstillinger config: hvordan sette opp egne jobbinnstillinger
your_repos: ! "Slå\x10 på Travis for prosjektene dine ved å dra i bryterne under, og send koden til Github.<br />\nFor å teste mot flere versjoner av ruby, se " your_repos: ! "Slå\x10 på Travis for prosjektene dine ved å dra i bryterne under, og send koden til Github.<br />\nFor å teste mot flere versjoner av ruby, se "
@ -118,6 +123,7 @@ nb:
your_repos: Dine kodelagre your_repos: Dine kodelagre
queue: queue:
repositories: repositories:
asciidoc:
branch: Gren branch: Gren
commit: Innsender commit: Innsender
duration: Varighet duration: Varighet
@ -136,7 +142,6 @@ nb:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Varighet duration: Varighet
statistics: statistics:

View File

@ -19,6 +19,7 @@ nl:
sponsored_by: Deze tests zijn gedraaid op een machine gesponsord door sponsored_by: Deze tests zijn gedraaid op een machine gesponsord door
name: Bouw name: Bouw
started_at: Gestart started_at: Gestart
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ nl:
sponsored_by: Deze testen zijn uitgevoerd op een machine gesponsord door sponsored_by: Deze testen zijn uitgevoerd op een machine gesponsord door
sponsored_by: sponsored_by:
started_at: Gestart started_at: Gestart
state:
layouts: layouts:
about: about:
alpha: Dit is in alfa-stadium. alpha: Dit is in alfa-stadium.
@ -82,6 +84,7 @@ nl:
job: Taak job: Taak
log: Logboek log: Logboek
top: top:
accounts:
admin: Administratie admin: Administratie
blog: Blog blog: Blog
docs: Documentatie docs: Documentatie
@ -89,6 +92,7 @@ nl:
home: Home home: Home
profile: Profiel profile: Profiel
sign_out: Uitloggen sign_out: Uitloggen
signing_in:
stats: Statistieken stats: Statistieken
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ nl:
show: show:
email: Email adres email: Email adres
github: Github github: Github
locale:
message: message:
config: hoe eigen bouw-opties in te stellen config: hoe eigen bouw-opties in te stellen
your_repos: ! 'Zet de schakelaars hieronder aan om de Travis hook voor uw projecten te activeren en push daarna naar Github<br /> your_repos: ! 'Zet de schakelaars hieronder aan om de Travis hook voor uw projecten te activeren en push daarna naar Github<br />
@ -120,6 +125,7 @@ nl:
your_repos: Uw repositories your_repos: Uw repositories
queue: Wachtrij queue: Wachtrij
repositories: repositories:
asciidoc:
branch: Tak branch: Tak
commit: Commit commit: Commit
duration: Duur duration: Duur
@ -138,7 +144,6 @@ nl:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Duur duration: Duur
statistics: statistics:

View File

@ -19,6 +19,7 @@ pl:
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
name: Build name: Build
started_at: Rozpoczęto started_at: Rozpoczęto
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ pl:
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez sponsored_by: Te testy zostały uruchomione na maszynie sponsorowanej przez
started_at: Rozpoczęto started_at: Rozpoczęto
state:
layouts: layouts:
about: about:
alpha: To wciąż jest wersja alpha. alpha: To wciąż jest wersja alpha.
@ -82,6 +84,7 @@ pl:
job: Zadanie job: Zadanie
log: Log log: Log
top: top:
accounts:
admin: admin:
blog: Blog blog: Blog
docs: Dokumentacja docs: Dokumentacja
@ -89,6 +92,7 @@ pl:
home: Start home: Start
profile: Profil profile: Profil
sign_out: Wyloguj się sign_out: Wyloguj się
signing_in:
stats: Statystki stats: Statystki
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ pl:
show: show:
email: Email email: Email
github: Github github: Github
locale:
message: message:
config: jak skonfigurować niestandardowe opcje builda config: jak skonfigurować niestandardowe opcje builda
your_repos: ! " Przesuń suwak poniżej, aby włączyć Travisa, dla twoich projektów, a następnie umieść swój kod na GitHubie.<br />\n Aby testować swój kod przy użyciu wielu wersji Rubiego, zobacz" your_repos: ! " Przesuń suwak poniżej, aby włączyć Travisa, dla twoich projektów, a następnie umieść swój kod na GitHubie.<br />\n Aby testować swój kod przy użyciu wielu wersji Rubiego, zobacz"
@ -118,6 +123,7 @@ pl:
your_repos: Twoje repozytoria your_repos: Twoje repozytoria
queue: Kolejka queue: Kolejka
repositories: repositories:
asciidoc:
branch: Gałąź branch: Gałąź
commit: Commit commit: Commit
duration: Czas trwania duration: Czas trwania
@ -136,7 +142,6 @@ pl:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: duration:
statistics: statistics:

View File

@ -19,6 +19,7 @@ pt-BR:
sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por
name: Build name: Build
started_at: Iniciou em started_at: Iniciou em
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -53,6 +54,7 @@ pt-BR:
sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por sponsored_by: Esta série de testes foi executada em uma caixa de processos patrocinada por
sponsored_by: sponsored_by:
started_at: Iniciou em started_at: Iniciou em
state:
layouts: layouts:
about: about:
alpha: Isto é um alpha. alpha: Isto é um alpha.
@ -82,6 +84,7 @@ pt-BR:
job: Trabalho job: Trabalho
log: Log log: Log
top: top:
accounts:
admin: Admin admin: Admin
blog: Blog blog: Blog
docs: Documentação docs: Documentação
@ -89,6 +92,7 @@ pt-BR:
home: Home home: Home
profile: Perfil profile: Perfil
sign_out: Sair sign_out: Sair
signing_in:
stats: Estatísticas stats: Estatísticas
locales: locales:
ca: ca:
@ -106,6 +110,7 @@ pt-BR:
show: show:
email: Email email: Email
github: Github github: Github
locale:
message: message:
config: como configurar opções de build config: como configurar opções de build
your_repos: Use os botões abaixo para ligar ou desligar o hook de serviço do Travis para seus projetos, e então, faça um push para o Github.<br />Para testar com múltiplas versões do Ruby, leia your_repos: Use os botões abaixo para ligar ou desligar o hook de serviço do Travis para seus projetos, e então, faça um push para o Github.<br />Para testar com múltiplas versões do Ruby, leia
@ -118,6 +123,7 @@ pt-BR:
your_repos: Seus Repositórios your_repos: Seus Repositórios
queue: Fila queue: Fila
repositories: repositories:
asciidoc:
branch: Branch branch: Branch
commit: Commit commit: Commit
duration: Duração duration: Duração
@ -136,7 +142,6 @@ pt-BR:
pull_requests: pull_requests:
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Duração duration: Duração
statistics: statistics:

View File

@ -19,6 +19,7 @@ ru:
sponsored_by: Эта серия тестов была запущена на машине, спонсируемой sponsored_by: Эта серия тестов была запущена на машине, спонсируемой
name: Билд name: Билд
started_at: Начало started_at: Начало
state:
datetime: datetime:
distance_in_words: distance_in_words:
hours_exact: hours_exact:
@ -59,6 +60,7 @@ ru:
sponsored_by: Эта серия тестов была запущена на машине спонсируемой sponsored_by: Эта серия тестов была запущена на машине спонсируемой
sponsored_by: sponsored_by:
started_at: Начало started_at: Начало
state:
layouts: layouts:
about: about:
alpha: Это альфа-версия alpha: Это альфа-версия
@ -88,6 +90,7 @@ ru:
job: Задача job: Задача
log: Журнал log: Журнал
top: top:
accounts:
admin: Управление admin: Управление
blog: Блог blog: Блог
docs: Документация docs: Документация
@ -95,6 +98,7 @@ ru:
home: Главная home: Главная
profile: Профиль profile: Профиль
sign_out: Выход sign_out: Выход
signing_in:
stats: Статистика stats: Статистика
locales: locales:
ca: ca:
@ -112,6 +116,7 @@ ru:
show: show:
email: Электронная почта email: Электронная почта
github: Github github: Github
locale:
message: message:
config: как настроить специальные опции билда config: как настроить специальные опции билда
your_repos: ! 'Используйте переключатели, чтобы включить Travis service hook для вашего проекта, а потом отправьте код на GitHub.<br /> your_repos: ! 'Используйте переключатели, чтобы включить Travis service hook для вашего проекта, а потом отправьте код на GitHub.<br />
@ -126,6 +131,7 @@ ru:
your_repos: Ваши репозитории your_repos: Ваши репозитории
queue: Очередь queue: Очередь
repositories: repositories:
asciidoc:
branch: Ветка branch: Ветка
commit: Коммит commit: Коммит
duration: Длительность duration: Длительность
@ -144,7 +150,6 @@ ru:
pull_requests: Запросы на Pull pull_requests: Запросы на Pull
test: test:
textile: Textile textile: Textile
asciidoc: AsciiDoc
repository: repository:
duration: Длительность duration: Длительность
statistics: statistics:

9
script/ci Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ "$TEST_SUITE" == "spec" ]; then
bundle exec rspec spec
elif [ "$TEST_SUITE" == "ember" ]; then
bundle exec rackup -s puma -p 5000 -D
sleep 3
./run_jasmine.coffee http://localhost:5000/spec.html
fi