Fix specs
After update specs fail when there is an unexpected ajax query, because the response is not an ajax response. A long term solution is to remove mockjax from specs, because it makes them brittle and they usually fail after small changes. A better approach would be to use fixtures, which are available for ember model
This commit is contained in:
parent
5b5a9d7839
commit
c751b7a8a4
|
@ -29,6 +29,8 @@ test "event containing a repository, adds repository to repos list", ->
|
|||
last_build_number: 10
|
||||
last_build_started_at: '2012-07-02T00:01:00Z'
|
||||
last_build_finished_at: '2012-07-02T00:02:30Z'
|
||||
last_build_state: 'passed'
|
||||
last_build_duration: 90
|
||||
|
||||
wait().then ->
|
||||
listsRepo
|
||||
|
|
|
@ -12,6 +12,19 @@ test "first sync page is show when user just signed up and is syncing", ->
|
|||
login: 'new-user'
|
||||
)
|
||||
|
||||
$.mockjax
|
||||
url: '/hooks'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
hooks: []
|
||||
|
||||
$.mockjax
|
||||
url: '/users'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
user:
|
||||
is_syncing: true
|
||||
|
||||
Travis.config.syncingPageRedirectionTime = 100
|
||||
|
||||
wait().then ->
|
||||
|
|
|
@ -23,7 +23,37 @@ window.signInUser = (data) ->
|
|||
email: 'tyrion@example.org'
|
||||
login: 'tyrion'
|
||||
token: 'abcdef'
|
||||
created_at: "2011-05-10T15:43:59Z"
|
||||
gravatar_id: "582034b63279abeaa8e76acf12f5ee30"
|
||||
is_syncing: false
|
||||
locale: "en"
|
||||
name: "Tyrion"
|
||||
synced_at: "2013-12-09T09:41:47Z"
|
||||
}
|
||||
$.mockjax
|
||||
url: '/users/1'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
user: userData
|
||||
$.mockjax
|
||||
url: '/users/permissions'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
permissions: []
|
||||
admin: []
|
||||
push: []
|
||||
pull: []
|
||||
$.mockjax
|
||||
url: '/broadcasts'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
broadcasts: []
|
||||
$.mockjax
|
||||
url: '/accounts'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
accounts: []
|
||||
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
minispade.require 'ext/jquery'
|
||||
|
||||
responseTime = 0
|
||||
responseTime = 10
|
||||
|
||||
repos = [
|
||||
{ id: '1', owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_state: 'passed', last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core', github_language: 'ruby' },
|
||||
|
@ -18,9 +18,9 @@ reposByName = (name) ->
|
|||
|
||||
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'] }, duration: null },
|
||||
{ id: '2', repository_id: '1', commit_id: 2, job_ids: [4], number: 2, pull_request: false, config: { rvm: ['rbx'] }, duration: null, state: 'created', finished_at: null },
|
||||
{ id: '3', repository_id: '2', commit_id: 3, job_ids: [5], number: 3, pull_request: false, config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', state: 'failed' },
|
||||
{ id: '4', repository_id: '3', commit_id: 4, job_ids: [6], number: 4, pull_request: false, config: { rvm: ['rbx'] }, duration: null, started_at: '2012-07-02T00:02:00Z' },
|
||||
{ id: '4', repository_id: '3', commit_id: 4, job_ids: [6], number: 4, pull_request: false, config: { rvm: ['rbx'] }, duration: null, started_at: '2012-07-02T00:02:00Z', state: 'queued', finished_at: null },
|
||||
]
|
||||
|
||||
commits = [
|
||||
|
@ -174,4 +174,3 @@ $.mockjax
|
|||
url: '/profile/hooks'
|
||||
responseTime: responseTime
|
||||
responseText: { hooks: hooks }
|
||||
|
||||
|
|
|
@ -6,16 +6,27 @@ module "Travis.User",
|
|||
Travis.User.resetData()
|
||||
|
||||
test '', ->
|
||||
$.mockjax({
|
||||
url: '/users/permissions',
|
||||
responseTime: 10,
|
||||
responseText: {
|
||||
permissions: [1],
|
||||
admin: [1],
|
||||
pull: [2],
|
||||
push: [3]
|
||||
}
|
||||
});
|
||||
# TODO: we should not need to mock entire user response
|
||||
# just for user creation. It happens, because whenever
|
||||
# a user is created we try to get fresh data
|
||||
userData = {
|
||||
id: 1
|
||||
email: 'tyrion@example.org'
|
||||
login: 'tyrion'
|
||||
token: 'abcdef'
|
||||
created_at: "2011-05-10T15:43:59Z"
|
||||
gravatar_id: "582034b63279abeaa8e76acf12f5ee30"
|
||||
is_syncing: false
|
||||
locale: "en"
|
||||
name: "Tyrion"
|
||||
synced_at: "2013-12-09T09:41:47Z"
|
||||
}
|
||||
$.mockjax
|
||||
url: '/users/1'
|
||||
responseTime: 10
|
||||
responseText:
|
||||
user: userData
|
||||
|
||||
|
||||
Travis.User.load [{ id: '1', login: 'test@travis-ci.org' }]
|
||||
user = null
|
||||
|
@ -24,9 +35,13 @@ test '', ->
|
|||
|
||||
Ember.run ->
|
||||
user = Travis.User.find(1)
|
||||
user.set '_rawPermissions',
|
||||
then: (func) ->
|
||||
func(permissions: [1], admin: [1], pull: [2], push: [3])
|
||||
|
||||
pushPermissions = user.get('pushPermissions')
|
||||
adminPermissions = user.get('adminPermissions')
|
||||
|
||||
wait().then ->
|
||||
deepEqual(adminPermissions.toArray(), [1])
|
||||
deepEqual(pushPermissions.toArray(), [3])
|
||||
deepEqual(pushPermissions.toArray(), [3])
|
||||
|
|
Loading…
Reference in New Issue
Block a user