upjs-rails 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +142 -0
  3. data/README.md +4 -1
  4. data/design/ghost-debugging.txt +118 -0
  5. data/design/homepage.txt +236 -0
  6. data/dist/up-bootstrap.js +7 -3
  7. data/dist/up-bootstrap.min.js +1 -1
  8. data/dist/up.js +1611 -1222
  9. data/dist/up.min.js +2 -2
  10. data/lib/assets/javascripts/up/bus.js.coffee +1 -1
  11. data/lib/assets/javascripts/up/flow.js.coffee +21 -20
  12. data/lib/assets/javascripts/up/form.js.coffee +11 -12
  13. data/lib/assets/javascripts/up/history.js.coffee +137 -20
  14. data/lib/assets/javascripts/up/layout.js.coffee +134 -21
  15. data/lib/assets/javascripts/up/link.js.coffee +40 -17
  16. data/lib/assets/javascripts/up/modal.js.coffee +2 -2
  17. data/lib/assets/javascripts/up/motion.js.coffee +3 -1
  18. data/lib/assets/javascripts/up/navigation.js.coffee +5 -5
  19. data/lib/assets/javascripts/up/popup.js.coffee +2 -2
  20. data/lib/assets/javascripts/up/proxy.js.coffee +43 -82
  21. data/lib/assets/javascripts/up/tooltip.js.coffee +1 -1
  22. data/lib/assets/javascripts/up/util.js.coffee +145 -14
  23. data/lib/assets/javascripts/up-bootstrap/layout-ext.js.coffee +2 -2
  24. data/lib/assets/javascripts/up-bootstrap/navigation-ext.js.coffee +3 -1
  25. data/lib/assets/javascripts/up.js.coffee +2 -2
  26. data/lib/upjs/rails/version.rb +1 -1
  27. data/spec_app/Gemfile.lock +1 -1
  28. data/spec_app/config/routes.rb +1 -2
  29. data/spec_app/spec/javascripts/helpers/knife.js.coffee +1 -1
  30. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +4 -0
  31. data/spec_app/spec/javascripts/helpers/set_timer.js.coffee +3 -3
  32. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +5 -0
  33. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +8 -6
  34. data/spec_app/spec/javascripts/up/form_spec.js.coffee +1 -1
  35. data/spec_app/spec/javascripts/up/history_spec.js.coffee +80 -1
  36. data/spec_app/spec/javascripts/up/link_spec.js.coffee +64 -4
  37. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +2 -2
  38. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +7 -7
  39. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +6 -6
  40. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +2 -2
  41. data/spec_app/spec/javascripts/up/util_spec.js.coffee +22 -4
  42. metadata +7 -2
@@ -265,7 +265,10 @@ up.util = (->
265
265
 
266
266
  isString = (object) ->
267
267
  typeof(object) == 'string'
268
-
268
+
269
+ isNumber = (object) ->
270
+ typeof(object) == 'number'
271
+
269
272
  isHash = (object) ->
270
273
  typeof(object) == 'object' && !!object
271
274
 
@@ -559,11 +562,19 @@ up.util = (->
559
562
  contains = (stringOrArray, element) ->
560
563
  stringOrArray.indexOf(element) >= 0
561
564
 
562
- castsToTrue = (object) ->
563
- String(object) == "true"
564
-
565
- castsToFalse = (object) ->
566
- String(object) == "false"
565
+ castedAttr = ($element, attrName) ->
566
+ value = $element.attr(attrName)
567
+ switch value
568
+ when 'false' then false
569
+ when 'true' then true
570
+ when '' then true
571
+ else value # other strings, undefined, null, ...
572
+
573
+ # castsToTrue = (object) ->
574
+ # String(object) == "true"
575
+ #
576
+ # castsToFalse = (object) ->
577
+ # String(object) == "false"
567
578
 
568
579
  locationFromXhr = (xhr) ->
569
580
  xhr.getResponseHeader('X-Up-Location')
@@ -618,20 +629,138 @@ up.util = (->
618
629
  array.splice(index, 1)
619
630
  element
620
631
 
632
+ ###*
633
+ @method up.util.cache
634
+ @param {Number|Function} [config.size]
635
+ Maximum number of cache entries.
636
+ Set to `undefined` to not limit the cache size.
637
+ @param {Number|Function} [config.expiry]
638
+ The number of milliseconds after which a cache entry
639
+ will be discarded.
640
+ @param {String} [config.log]
641
+ A prefix for log entries printed by this cache object.
642
+ ###
643
+ cache = (config) ->
644
+
645
+ store = undefined
646
+
647
+ clear = ->
648
+ store = {}
649
+
650
+ clear()
651
+
652
+ log = (args...) ->
653
+ if config.log
654
+ args[0] = "[#{config.log}] #{args[0]}"
655
+ debug(args...)
656
+
657
+ maxSize = ->
658
+ if isMissing(config.size)
659
+ undefined
660
+ else if isFunction(config.size)
661
+ config.size()
662
+ else if isNumber(config.size)
663
+ config.size
664
+ else
665
+ error("Invalid size config: %o", config.size)
666
+
667
+ expiryMilis = ->
668
+ if isMissing(config.expiry)
669
+ undefined
670
+ else if isFunction(config.expiry)
671
+ config.expiry()
672
+ else if isNumber(config.expiry)
673
+ config.expiry
674
+ else
675
+ error("Invalid expiry config: %o", config.expiry)
676
+
677
+ normalizeStoreKey = (key) ->
678
+ if config.key
679
+ config.key(key)
680
+ else
681
+ key.toString()
682
+
683
+ trim = ->
684
+ storeKeys = copy(keys(store))
685
+ size = maxSize()
686
+ if size && storeKeys.length > size
687
+ oldestKey = null
688
+ oldestTimestamp = null
689
+ each storeKeys, (key) ->
690
+ promise = store[key] # we don't need to call cacheKey here
691
+ timestamp = promise.timestamp
692
+ if !oldestTimestamp || oldestTimestamp > timestamp
693
+ oldestKey = key
694
+ oldestTimestamp = timestamp
695
+ delete store[oldestKey] if oldestKey
696
+
697
+ alias = (oldKey, newKey) ->
698
+ value = get(oldKey)
699
+ if isDefined(value)
700
+ set(newKey, value)
701
+
702
+ timestamp = ->
703
+ (new Date()).valueOf()
704
+
705
+ set = (key, value) ->
706
+ storeKey = normalizeStoreKey(key)
707
+ store[storeKey] =
708
+ timestamp: timestamp()
709
+ value: value
710
+
711
+ remove = (key) ->
712
+ storeKey = normalizeStoreKey(key)
713
+ delete store[storeKey]
714
+
715
+ isFresh = (entry) ->
716
+ expiry = expiryMilis()
717
+ if expiry
718
+ timeSinceTouch = timestamp() - entry.timestamp
719
+ timeSinceTouch < expiryMilis()
720
+ else
721
+ true
722
+
723
+ get = (key, fallback = undefined) ->
724
+ storeKey = normalizeStoreKey(key)
725
+ if entry = store[storeKey]
726
+ if !isFresh(entry)
727
+ log("Discarding stale cache entry for %o", key)
728
+ remove(key)
729
+ fallback
730
+ else
731
+ log("Cache hit for %o", key)
732
+ entry.value
733
+ else
734
+ log("Cache miss for %o", key)
735
+ fallback
736
+
737
+ alias: alias
738
+ get: get
739
+ set: set
740
+ remove: remove
741
+ clear: clear
742
+
743
+
621
744
  config = (factoryOptions = {}) ->
622
745
  hash =
746
+ ensureKeyExists: (key) ->
747
+ factoryOptions.hasOwnProperty(key) or error("Unknown setting %o", key)
623
748
  reset: ->
624
749
  ownKeys = copy(Object.getOwnPropertyNames(hash))
625
750
  for key in ownKeys
626
751
  delete hash[key] unless contains(apiKeys, key)
627
752
  hash.update copy(factoryOptions)
628
- update: (options = {}) ->
629
- for key, value of options
630
- if factoryOptions.hasOwnProperty(key)
631
- hash[key] = value
753
+ update: (options) ->
754
+ if options
755
+ if isString(options)
756
+ hash.ensureKeyExists(options)
757
+ hash[options]
632
758
  else
633
- error("Unknown setting %o", key)
634
- hash
759
+ for key, value of options
760
+ hash.ensureKeyExists(key)
761
+ hash[key] = value
762
+ else
763
+ hash
635
764
  apiKeys = Object.getOwnPropertyNames(hash)
636
765
  hash.reset()
637
766
  hash
@@ -705,8 +834,9 @@ up.util = (->
705
834
  endsWith: endsWith
706
835
  isArray: isArray
707
836
  toArray: toArray
708
- castsToTrue: castsToTrue
709
- castsToFalse: castsToFalse
837
+ # castsToTrue: castsToTrue
838
+ # castsToFalse: castsToFalse
839
+ castedAttr: castedAttr
710
840
  locationFromXhr: locationFromXhr
711
841
  methodFromXhr: methodFromXhr
712
842
  clientSize: clientSize
@@ -721,6 +851,7 @@ up.util = (->
721
851
  memoize: memoize
722
852
  scrollbarWidth: scrollbarWidth
723
853
  config: config
854
+ cache: cache
724
855
  unwrapElement: unwrapElement
725
856
 
726
857
  )()
@@ -1,5 +1,5 @@
1
1
  defaults = up.layout.defaults()
2
2
 
3
3
  up.layout.defaults
4
- fixedTop: "#{defaults.fixedTop}, .navbar-fixed-top"
5
- fixedBottom: "#{defaults.fixedBottom}, .navbar-fixed-bottom"
4
+ fixedTop: defaults.fixedTop.concat(['.navbar-fixed-top'])
5
+ fixedBottom: defaults.fixedBottom.concat(['.navbar-fixed-bottom'])
@@ -1,4 +1,6 @@
1
+ defaults = up.navigation.defaults()
2
+
1
3
  # BS use the class `active` to highlight the current section
2
4
  # of a navigation bar.
3
5
  up.navigation.defaults
4
- currentClass: 'active'
6
+ currentClasses: defaults.currentClasses.concat(['active'])
@@ -2,10 +2,10 @@
2
2
  #= require up/util
3
3
  #= require up/browser
4
4
  #= require up/bus
5
- #= require up/layout
6
- #= require up/flow
7
5
  #= require up/magic
8
6
  #= require up/history
7
+ #= require up/layout
8
+ #= require up/flow
9
9
  #= require up/motion
10
10
  #= require up/proxy
11
11
  #= require up/link
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.9.1'
3
+ VERSION = '0.10.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- upjs-rails (0.8.0)
4
+ upjs-rails (0.9.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -1,7 +1,6 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
3
  mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)
4
- resources :cards
5
- root to: 'pages#home'
4
+ root to: redirect('/specs')
6
5
 
7
6
  end
@@ -59,7 +59,7 @@
59
59
  me.reset = reset
60
60
  me.cleaners = []
61
61
 
62
- if jasmine
62
+ if jasmine?
63
63
  me.point = "(#{contextBleeder.toString()})()"
64
64
  # Jasmine defines afterEach on window
65
65
  afterEach reset
@@ -0,0 +1,4 @@
1
+ beforeEach ->
2
+ @lastRequest = ->
3
+ jasmine.Ajax.requests.mostRecent() or up.util.error('There is no last request')
4
+
@@ -1,3 +1,3 @@
1
- @setTimer = (millis, fun) ->
2
- setTimeout(fun, millis)
3
-
1
+ beforeEach ->
2
+ @setTimer = (millis, fun) ->
3
+ setTimeout(fun, millis)
@@ -0,0 +1,5 @@
1
+ beforeEach ->
2
+ jasmine.addMatchers
3
+ toEndWith: (util, customEqualityTesters) ->
4
+ compare: (actual, expected) ->
5
+ pass: up.util.endsWith(actual, expected)
@@ -22,7 +22,7 @@ describe 'up.flow', ->
22
22
  """
23
23
 
24
24
  @respond = ->
25
- jasmine.Ajax.requests.mostRecent().respondWith
25
+ @lastRequest().respondWith
26
26
  status: 200
27
27
  contentType: 'text/html'
28
28
  responseText: @responseText
@@ -114,7 +114,9 @@ describe 'up.flow', ->
114
114
  expect(window.scriptTagExecuted).toHaveBeenCalledWith('middle')
115
115
  done()
116
116
 
117
- describe 'automatic scrolling', ->
117
+ it 'restores the scroll positions of all viewports within the target with options.restoreScroll'
118
+
119
+ describe 'revealing of elements', ->
118
120
 
119
121
  beforeEach ->
120
122
  @revealedHTML = ''
@@ -126,14 +128,14 @@ describe 'up.flow', ->
126
128
  @request = up.replace('.middle', '/path')
127
129
  @respond()
128
130
  @request.then =>
129
- expect(up.reveal).toHaveBeenCalledWith(@oldMiddle, jasmine.any(Object))
131
+ expect(up.reveal).toHaveBeenCalledWith(@oldMiddle)
130
132
  done()
131
133
 
132
134
  it 'reveals a new element that is being appended', (done) ->
133
135
  @request = up.replace('.middle:after', '/path')
134
136
  @respond()
135
137
  @request.then =>
136
- expect(up.reveal).not.toHaveBeenCalledWith(@oldMiddle, jasmine.any(Object))
138
+ expect(up.reveal).not.toHaveBeenCalledWith(@oldMiddle)
137
139
  # Text nodes are wrapped in a .up-insertion container so we can
138
140
  # animate them and measure their position/size for scrolling.
139
141
  # This is not possible for container-less text nodes.
@@ -146,7 +148,7 @@ describe 'up.flow', ->
146
148
  @request = up.replace('.middle:before', '/path')
147
149
  @respond()
148
150
  @request.then =>
149
- expect(up.reveal).not.toHaveBeenCalledWith(@oldMiddle, jasmine.any(Object))
151
+ expect(up.reveal).not.toHaveBeenCalledWith(@oldMiddle)
150
152
  # Text nodes are wrapped in a .up-insertion container so we can
151
153
  # animate them and measure their position/size for scrolling.
152
154
  # This is not possible for container-less text nodes.
@@ -253,7 +255,7 @@ describe 'up.flow', ->
253
255
  expect($('.element')).toHaveText('new text')
254
256
  done()
255
257
 
256
- request = jasmine.Ajax.requests.mostRecent()
258
+ request = @lastRequest()
257
259
  expect(request.url).toMatch(/\/source$/)
258
260
 
259
261
  request.respondWith
@@ -19,7 +19,7 @@ describe 'up.form', ->
19
19
 
20
20
  @promise = up.submit($form)
21
21
 
22
- @request = jasmine.Ajax.requests.mostRecent()
22
+ @request = @lastRequest()
23
23
  expect(@request.url).toMatch /\/path\/to$/
24
24
  expect(@request.method).toBe 'PUT'
25
25
  expect(@request.data()).toEqual
@@ -9,4 +9,83 @@ describe 'up.history', ->
9
9
  describe 'up.history.push', ->
10
10
 
11
11
  it 'should have tests'
12
-
12
+
13
+ describe 'unobtrusive behavior', ->
14
+
15
+ describe '[up-back]', ->
16
+
17
+ it 'sets an [up-href] attribute to the previous URL and sets the up-restore-scroll attribute to "true"', ->
18
+ up.history.push('/one')
19
+ console.log("url is now %o, previous was %o", up.history.url(), up.history.previousUrl())
20
+ up.history.push('/two')
21
+ console.log("url is now %o, previous was %o", up.history.url(), up.history.previousUrl())
22
+ $element = up.ready(affix('a[href="/three"][up-back]').text('text'))
23
+ console.log("url is now %o, previous was %o", up.history.url(), up.history.previousUrl())
24
+ expect($element.attr('href')).toEndWith('/three')
25
+ expect($element.attr('up-href')).toEndWith('/one')
26
+ expect($element.attr('up-restore-scroll')).toBe('')
27
+ expect($element.attr('up-follow')).toBe('')
28
+
29
+ it 'does not overwrite an existing up-href or up-restore-scroll attribute'
30
+
31
+ it 'does not set an up-href attribute if there is no previous URL'
32
+
33
+ describe 'scroll restauration', ->
34
+
35
+ afterEach ->
36
+ $('.viewport').remove()
37
+
38
+ it 'restores the scroll position of viewports when the user hits the back button', (done) ->
39
+
40
+ longContentHtml = """
41
+ <div class="viewport" style="width: 100px; height: 100px; overflow-y: scroll">
42
+ <div class="content" style="height: 1000px"></div>
43
+ </div>
44
+ """
45
+
46
+ respond = (html) =>
47
+ @lastRequest().respondWith
48
+ status: 200
49
+ contentType: 'text/html'
50
+ responseText: longContentHtml
51
+
52
+ $viewport = $(longContentHtml).appendTo(document.body)
53
+
54
+ up.layout.defaults(viewports: ['.viewport'])
55
+ up.history.defaults(popTargets: ['.viewport'])
56
+
57
+ $viewport.append(longContentHtml)
58
+
59
+ up.replace('.content', '/one')
60
+ respond()
61
+ $viewport.scrollTop(50)
62
+
63
+ up.replace('.content', '/two')
64
+ respond()
65
+ $('.viewport').scrollTop(150)
66
+
67
+ up.replace('.content', '/three')
68
+ respond()
69
+ $('.viewport').scrollTop(250)
70
+
71
+ history.back()
72
+ @setTimer 50, =>
73
+ respond() # we need to respond since we've never requested /two with the popTarget
74
+ expect($('.viewport').scrollTop()).toBe(150)
75
+
76
+ history.back()
77
+ @setTimer 50, =>
78
+ respond() # we need to respond since we've never requested /one with the popTarget
79
+ expect($('.viewport').scrollTop()).toBe(50)
80
+
81
+ history.forward()
82
+ @setTimer 50, =>
83
+ # No need to respond since we requested /two with the popTarget
84
+ # when we went backwards
85
+ expect($('.viewport').scrollTop()).toBe(150)
86
+
87
+ history.forward()
88
+ @setTimer 50, =>
89
+ respond() # we need to respond since we've never requested /three with the popTarget
90
+ expect($('.viewport').scrollTop()).toBe(250)
91
+ done()
@@ -1,5 +1,7 @@
1
1
  describe 'up.link', ->
2
-
2
+
3
+ u = up.util
4
+
3
5
  describe 'Javascript functions', ->
4
6
 
5
7
  describe 'up.follow', ->
@@ -14,7 +16,7 @@ describe 'up.link', ->
14
16
 
15
17
  promise = up.follow($link)
16
18
 
17
- jasmine.Ajax.requests.mostRecent().respondWith
19
+ @lastRequest().respondWith
18
20
  status: 200
19
21
  contentType: 'text/html'
20
22
  responseText:
@@ -33,9 +35,67 @@ describe 'up.link', ->
33
35
  it 'uses the method from a data-method attribute', ->
34
36
  $link = affix('a[href="/path"][data-method="PUT"]')
35
37
  up.follow($link)
36
- request = jasmine.Ajax.requests.mostRecent()
38
+ request = @lastRequest()
37
39
  expect(request.method).toBe('PUT')
38
40
 
41
+ it 'adds history entries and allows the user to use the back- and forward-buttons', (done) ->
42
+
43
+ # By default, up.history will replace the <body> tag when
44
+ # the user presses the back-button. We reconfigure this
45
+ # so we don't lose the Jasmine runner interface.
46
+ up.history.defaults
47
+ popTargets: ['.container']
48
+
49
+
50
+ respondWith = (html) =>
51
+ @lastRequest().respondWith
52
+ status: 200
53
+ contentType: 'text/html'
54
+ responseText: "<div class='container'><div class='target'>#{html}</div></div>"
55
+
56
+ followAndRespond = ($link, html) ->
57
+ promise = up.follow($link)
58
+ respondWith(html)
59
+ promise
60
+
61
+ $link1 = affix('a[href="/one"][up-target=".target"]')
62
+ $link2 = affix('a[href="/two"][up-target=".target"]')
63
+ $link3 = affix('a[href="/three"][up-target=".target"]')
64
+ $container = affix('.container')
65
+ $target = affix('.target').appendTo($container).text('original text')
66
+
67
+ followAndRespond($link1, 'text from one').then =>
68
+ expect($('.target')).toHaveText('text from one')
69
+ expect(location.pathname).toEqual('/one')
70
+
71
+ followAndRespond($link2, 'text from two').then =>
72
+ expect($('.target')).toHaveText('text from two')
73
+ expect(location.pathname).toEqual('/two')
74
+
75
+ followAndRespond($link3, 'text from three').then =>
76
+ expect($('.target')).toHaveText('text from three')
77
+ expect(location.pathname).toEqual('/three')
78
+
79
+ history.back()
80
+ @setTimer 50, =>
81
+ respondWith('restored text from two')
82
+ expect($('.target')).toHaveText('restored text from two')
83
+ expect(location.pathname).toEqual('/two')
84
+
85
+ history.back()
86
+ @setTimer 50, =>
87
+ respondWith('restored text from one')
88
+ expect($('.target')).toHaveText('restored text from one')
89
+ expect(location.pathname).toEqual('/one')
90
+
91
+ history.forward()
92
+ @setTimer 50, =>
93
+ # Since the response is cached, we don't have to respond
94
+ expect($('.target')).toHaveText('restored text from two')
95
+ expect(location.pathname).toEqual('/two')
96
+
97
+ done()
98
+
39
99
  else
40
100
 
41
101
  it 'follows the given link', ->
@@ -54,7 +114,7 @@ describe 'up.link', ->
54
114
  describe 'up.visit', ->
55
115
 
56
116
  it 'should have tests'
57
-
117
+
58
118
  describe 'unobtrusive behavior', ->
59
119
 
60
120
  describe 'a[up-target]', ->
@@ -11,7 +11,7 @@ describe 'up.modal', ->
11
11
  it "loads the given link's destination in a dialog window", (done) ->
12
12
  $link = affix('a[href="/path/to"][up-modal=".middle"]').text('link')
13
13
  promise = up.modal.open($link)
14
- request = jasmine.Ajax.requests.mostRecent()
14
+ request = @lastRequest()
15
15
  expect(request.url).toMatch /\/path\/to$/
16
16
  request.respondWith
17
17
  status: 200
@@ -34,7 +34,7 @@ describe 'up.modal', ->
34
34
  it "brings its own scrollbar, padding the body on the right in order to prevent jumping", (done) ->
35
35
  promise = up.modal.open(url: '/foo', target: '.container')
36
36
 
37
- jasmine.Ajax.requests.mostRecent().respondWith
37
+ @lastRequest().respondWith
38
38
  status: 200
39
39
  contentType: 'text/html'
40
40
  responseText:
@@ -11,11 +11,11 @@ describe 'up.motion', ->
11
11
  opacity = -> Number($element.css('opacity'))
12
12
  up.animate($element, 'fade-in', duration: 100, easing: 'linear')
13
13
 
14
- setTimer 0, ->
14
+ @setTimer 0, ->
15
15
  expect(opacity()).toBeAround(0.0, 0.25)
16
- setTimer 50, ->
16
+ @setTimer 50, ->
17
17
  expect(opacity()).toBeAround(0.5, 0.25)
18
- setTimer 100, ->
18
+ @setTimer 100, ->
19
19
  expect(opacity()).toBeAround(1.0, 0.25)
20
20
  done()
21
21
 
@@ -104,19 +104,19 @@ describe 'up.motion', ->
104
104
 
105
105
  opacity = ($element) -> Number($element.css('opacity'))
106
106
 
107
- setTimer 0, ->
107
+ @setTimer 0, ->
108
108
  expect(opacity($newGhost)).toBeAround(0.0, 0.25)
109
109
  expect(opacity($oldGhost)).toBeAround(1.0, 0.25)
110
110
 
111
- setTimer 40, ->
111
+ @setTimer 40, ->
112
112
  expect(opacity($newGhost)).toBeAround(0.4, 0.25)
113
113
  expect(opacity($oldGhost)).toBeAround(0.6, 0.25)
114
114
 
115
- setTimer 70, ->
115
+ @setTimer 70, ->
116
116
  expect(opacity($newGhost)).toBeAround(0.7, 0.25)
117
117
  expect(opacity($oldGhost)).toBeAround(0.3, 0.25)
118
118
 
119
- setTimer 125, ->
119
+ @setTimer 125, ->
120
120
  # Once our two ghosts have rendered their visual effect,
121
121
  # we remove them from the DOM.
122
122
  expect($newGhost).not.toBeInDOM()
@@ -39,7 +39,7 @@ describe 'up.navigation', ->
39
39
  expect($otherLink).not.toHaveClass('up-current')
40
40
 
41
41
  it 'allows to configure a custom "current" class, but always also sets .up-current', ->
42
- up.navigation.defaults(currentClass: 'highlight')
42
+ up.navigation.defaults(currentClasses: ['highlight'])
43
43
  spyOn(up.browser, 'url').and.returnValue('/foo')
44
44
  $currentLink = up.ready(affix('a[href="/foo"]'))
45
45
  expect($currentLink).toHaveClass('highlight up-current')
@@ -50,7 +50,7 @@ describe 'up.navigation', ->
50
50
  $link = affix('a[href="/foo"][up-target=".main"]')
51
51
  affix('.main')
52
52
  $link.click()
53
- jasmine.Ajax.requests.mostRecent().respondWith
53
+ @lastRequest().respondWith
54
54
  status: 200
55
55
  contentType: 'text/html'
56
56
  responseHeaders: { 'X-Up-Location': '/foo/' }
@@ -61,7 +61,7 @@ describe 'up.navigation', ->
61
61
  $link = affix('a[href="/foo/"][up-target=".main"]')
62
62
  affix('.main')
63
63
  $link.click()
64
- jasmine.Ajax.requests.mostRecent().respondWith
64
+ @lastRequest().respondWith
65
65
  status: 200
66
66
  contentType: 'text/html'
67
67
  responseHeaders: { 'X-Up-Location': '/foo' }
@@ -80,7 +80,7 @@ describe 'up.navigation', ->
80
80
  $link.click()
81
81
  # console.log($link)
82
82
  expect($link).toHaveClass('up-active')
83
- jasmine.Ajax.requests.mostRecent().respondWith
83
+ @lastRequest().respondWith
84
84
  status: 200
85
85
  contentType: 'text/html'
86
86
  responseText: '<div class="main">new-text</div>'
@@ -92,7 +92,7 @@ describe 'up.navigation', ->
92
92
  affix('.main')
93
93
  Trigger.mousedown($link)
94
94
  expect($link).toHaveClass('up-active')
95
- jasmine.Ajax.requests.mostRecent().respondWith
95
+ @lastRequest().respondWith
96
96
  status: 200
97
97
  contentType: 'text/html'
98
98
  responseText: '<div class="main">new-text</div>'
@@ -106,7 +106,7 @@ describe 'up.navigation', ->
106
106
  affix('.main')
107
107
  $link.click()
108
108
  expect($area).toHaveClass('up-active')
109
- jasmine.Ajax.requests.mostRecent().respondWith
109
+ @lastRequest().respondWith
110
110
  status: 200
111
111
  contentType: 'text/html'
112
112
  responseText: '<div class="main">new-text</div>'
@@ -22,7 +22,7 @@ describe 'up.proxy', ->
22
22
  expect(jasmine.Ajax.requests.count()).toEqual(1)
23
23
  expect(responses).toEqual([])
24
24
 
25
- jasmine.Ajax.requests.mostRecent().respondWith
25
+ @lastRequest().respondWith
26
26
  status: 200
27
27
  contentType: 'text/html'
28
28
  responseText: 'foo'
@@ -39,7 +39,7 @@ describe 'up.proxy', ->
39
39
  # See that we have triggered a second request
40
40
  expect(jasmine.Ajax.requests.count()).toEqual(2)
41
41
 
42
- jasmine.Ajax.requests.mostRecent().respondWith
42
+ @lastRequest().respondWith
43
43
  status: 200
44
44
  contentType: 'text/html'
45
45
  responseText: 'bar'