upjs-rails 0.12.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rdoc_options +23 -0
  3. data/CHANGELOG.md +20 -0
  4. data/design/up-validate.js.coffee +284 -0
  5. data/dist/up-bootstrap.js +4 -0
  6. data/dist/up-bootstrap.min.js +1 -1
  7. data/dist/up.js +547 -102
  8. data/dist/up.min.js +2 -2
  9. data/lib/assets/javascripts/up/browser.js.coffee +3 -2
  10. data/lib/assets/javascripts/up/flow.js.coffee +95 -17
  11. data/lib/assets/javascripts/up/form.js.coffee +327 -34
  12. data/lib/assets/javascripts/up/history.js.coffee +1 -1
  13. data/lib/assets/javascripts/up/layout.js.coffee +4 -4
  14. data/lib/assets/javascripts/up/link.js.coffee +5 -2
  15. data/lib/assets/javascripts/up/modal.js.coffee +1 -0
  16. data/lib/assets/javascripts/up/proxy.js.coffee +27 -12
  17. data/lib/assets/javascripts/up/syntax.js.coffee +39 -20
  18. data/lib/assets/javascripts/up/util.js.coffee +29 -12
  19. data/lib/assets/javascripts/up-bootstrap/form-ext.js.coffee +1 -0
  20. data/lib/upjs/rails/engine.rb +1 -1
  21. data/lib/upjs/rails/inspector.rb +63 -0
  22. data/lib/upjs/rails/inspector_accessor.rb +28 -0
  23. data/lib/upjs/rails/request_echo_headers.rb +7 -0
  24. data/lib/upjs/rails/request_method_cookie.rb +12 -4
  25. data/lib/upjs/rails/version.rb +5 -1
  26. data/lib/upjs-rails.rb +7 -5
  27. data/spec_app/.rspec +2 -0
  28. data/spec_app/Gemfile +0 -3
  29. data/spec_app/Gemfile.lock +43 -44
  30. data/spec_app/app/assets/stylesheets/application.css +1 -1
  31. data/spec_app/app/controllers/test_controller.rb +23 -0
  32. data/spec_app/config/routes.rb +2 -0
  33. data/spec_app/spec/controllers/test_controller_spec.rb +67 -0
  34. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +8 -0
  35. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +18 -0
  36. data/spec_app/spec/javascripts/helpers/reset_path.js.coffee +1 -0
  37. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +93 -43
  38. data/spec_app/spec/javascripts/up/form_spec.js.coffee +80 -18
  39. data/spec_app/spec/javascripts/up/history_spec.js.coffee +1 -5
  40. data/spec_app/spec/javascripts/up/link_spec.js.coffee +18 -17
  41. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +32 -37
  42. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +7 -26
  43. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +1 -7
  44. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +26 -25
  45. data/spec_app/spec/javascripts/up/util_spec.js.coffee +23 -0
  46. data/spec_app/spec/spec_helper.rb +62 -0
  47. metadata +12 -3
  48. data/lib/upjs/rails/request_ext.rb +0 -13
@@ -22,10 +22,7 @@ describe 'up.proxy', ->
22
22
  expect(jasmine.Ajax.requests.count()).toEqual(1)
23
23
  expect(responses).toEqual([])
24
24
 
25
- @lastRequest().respondWith
26
- status: 200
27
- contentType: 'text/html'
28
- responseText: 'foo'
25
+ @respondWith('foo')
29
26
 
30
27
  # See that both requests have been fulfilled by the same response
31
28
  expect(responses).toEqual(['foo', 'foo'])
@@ -39,33 +36,37 @@ describe 'up.proxy', ->
39
36
  # See that we have triggered a second request
40
37
  expect(jasmine.Ajax.requests.count()).toEqual(2)
41
38
 
42
- @lastRequest().respondWith
43
- status: 200
44
- contentType: 'text/html'
45
- responseText: 'bar'
39
+ @respondWith('bar')
46
40
 
47
41
  expect(responses).toEqual(['foo', 'foo', 'bar'])
48
42
 
49
- it "doesn't reuse responses for different paths", ->
50
- responses = []
51
-
52
- up.proxy.ajax(url: '/foo').then (data) -> responses.push(data)
53
- up.proxy.ajax(url: '/bar').then (data) -> responses.push(data)
54
-
55
- # See that only a single network request was triggered
43
+ it "doesn't reuse responses when asked for the same path, but different selectors", ->
44
+ up.proxy.ajax(url: '/path', selector: '.a')
45
+ up.proxy.ajax(url: '/path', selector: '.b')
56
46
  expect(jasmine.Ajax.requests.count()).toEqual(2)
57
47
 
58
- jasmine.Ajax.requests.at(0).respondWith
59
- status: 200
60
- contentType: 'text/html'
61
- responseText: 'foo'
48
+ it "reuses a response for an 'html' selector when asked for the same path and any other selector", ->
49
+ up.proxy.ajax(url: '/path', selector: 'html')
50
+ up.proxy.ajax(url: '/path', selector: 'body')
51
+ up.proxy.ajax(url: '/path', selector: 'p')
52
+ up.proxy.ajax(url: '/path', selector: '.klass')
53
+ expect(jasmine.Ajax.requests.count()).toEqual(1)
62
54
 
63
- jasmine.Ajax.requests.at(1).respondWith
64
- status: 200
65
- contentType: 'text/html'
66
- responseText: 'bar'
55
+ it "reuses a response for a 'body' selector when asked for the same path and any other selector other than 'html'", ->
56
+ up.proxy.ajax(url: '/path', selector: 'body')
57
+ up.proxy.ajax(url: '/path', selector: 'p')
58
+ up.proxy.ajax(url: '/path', selector: '.klass')
59
+ expect(jasmine.Ajax.requests.count()).toEqual(1)
67
60
 
68
- expect(responses).toEqual(['foo', 'bar'])
61
+ it "doesn't reuse a response for a 'body' selector when asked for the same path but an 'html' selector", ->
62
+ up.proxy.ajax(url: '/path', selector: 'body')
63
+ up.proxy.ajax(url: '/path', selector: 'html')
64
+ expect(jasmine.Ajax.requests.count()).toEqual(2)
65
+
66
+ it "doesn't reuse responses for different paths", ->
67
+ up.proxy.ajax(url: '/foo')
68
+ up.proxy.ajax(url: '/bar')
69
+ expect(jasmine.Ajax.requests.count()).toEqual(2)
69
70
 
70
71
  u.each ['GET', 'HEAD', 'OPTIONS'], (method) ->
71
72
 
@@ -91,7 +92,7 @@ describe 'up.proxy', ->
91
92
  # Send the same request for the same path, 3 minutes apart
92
93
  up.proxy.ajax(url: '/foo')
93
94
 
94
- @lastRequest().respondWith
95
+ @respondWith
95
96
  status: 500
96
97
  contentType: 'text/html'
97
98
  responseText: 'foo'
@@ -8,6 +8,29 @@ describe 'up.util', ->
8
8
  # fun = ($element, data) ->
9
9
  # expect(up.util.argNames(fun)).toEqual(['$element', 'data'])
10
10
 
11
+ describe 'up.util.createSelectorFromElement', ->
12
+
13
+ it "prefers using the element's 'up-id' attribute to using the element's ID", ->
14
+ $element = affix('div[up-id=up-id-value]#id-value')
15
+ expect(up.util.createSelectorFromElement($element)).toBe("[up-id='up-id-value']")
16
+
17
+ it "prefers using the element's ID to using the element's name", ->
18
+ $element = affix('div#id-value[name=name-value]')
19
+ expect(up.util.createSelectorFromElement($element)).toBe("#id-value")
20
+
21
+ it "prefers using the element's name to using the element's classes", ->
22
+ $element = affix('div[name=name-value].class1.class2')
23
+ expect(up.util.createSelectorFromElement($element)).toBe("[name='name-value']")
24
+
25
+ it "prefers using the element's classes to using the element's tag name", ->
26
+ $element = affix('div.class1.class2')
27
+ expect(up.util.createSelectorFromElement($element)).toBe(".class1.class2")
28
+
29
+ it "uses the element's tag name if no better description is available", ->
30
+ $element = affix('div')
31
+ expect(up.util.createSelectorFromElement($element)).toBe("div")
32
+
33
+
11
34
  describe 'up.util.castedAttr', ->
12
35
 
13
36
  it 'returns true if the attribute value is the string "true"', ->
@@ -0,0 +1,62 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc, in
11
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
+ # run as spec files by default. This means that files in spec/support that end
13
+ # in _spec.rb will both be required and run as specs, causing the specs to be
14
+ # run twice. It is recommended that you do not name files matching this glob to
15
+ # end with _spec.rb. You can configure this pattern with the --pattern
16
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
+ #
18
+ # The following line is provided for convenience purposes. It has the downside
19
+ # of increasing the boot-up time by auto-requiring all files in the support
20
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
+ # require only the support files necessary.
22
+ #
23
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
24
+
25
+ # Checks for pending migration and applies them before tests are run.
26
+ # If you are not using ActiveRecord, you can remove this line.
27
+ ActiveRecord::Migration.maintain_test_schema!
28
+
29
+ RSpec.configure do |config|
30
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
31
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
32
+
33
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
34
+ # examples within a transaction, remove the following line or assign false
35
+ # instead of true.
36
+ config.use_transactional_fixtures = true
37
+
38
+ # RSpec Rails can automatically mix in different behaviours to your tests
39
+ # based on their file location, for example enabling you to call `get` and
40
+ # `post` in specs under `spec/controllers`.
41
+ #
42
+ # You can disable this behaviour by removing the line below, and instead
43
+ # explicitly tag your specs with their type, e.g.:
44
+ #
45
+ # RSpec.describe UsersController, :type => :controller do
46
+ # # ...
47
+ # end
48
+ #
49
+ # The different available types are documented in the features, such as in
50
+ # https://relishapp.com/rspec/rspec-rails/docs
51
+ config.infer_spec_type_from_file_location!
52
+
53
+ # Filter lines from Rails gems in backtraces.
54
+ config.filter_rails_from_backtrace!
55
+ # arbitrary gems may also be filtered via:
56
+ # config.filter_gems_from_backtrace("gem name")
57
+
58
+ config.expect_with :rspec do |c|
59
+ c.syntax = [:should, :expect]
60
+ end
61
+
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.5
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-17 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -62,6 +62,7 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - ".gitignore"
65
+ - ".rdoc_options"
65
66
  - ".ruby-version"
66
67
  - CHANGELOG.md
67
68
  - Gemfile
@@ -79,6 +80,7 @@ files:
79
80
  - design/ghost-debugging.txt
80
81
  - design/homepage.txt
81
82
  - design/rename.txt
83
+ - design/up-validate.js.coffee
82
84
  - dist/up-bootstrap.css
83
85
  - dist/up-bootstrap.js
84
86
  - dist/up-bootstrap.min.css
@@ -88,6 +90,7 @@ files:
88
90
  - dist/up.min.css
89
91
  - dist/up.min.js
90
92
  - lib/assets/javascripts/up-bootstrap.js.coffee
93
+ - lib/assets/javascripts/up-bootstrap/form-ext.js.coffee
91
94
  - lib/assets/javascripts/up-bootstrap/layout-ext.js.coffee
92
95
  - lib/assets/javascripts/up-bootstrap/modal-ext.js.coffee
93
96
  - lib/assets/javascripts/up-bootstrap/navigation-ext.js.coffee
@@ -119,12 +122,14 @@ files:
119
122
  - lib/assets/stylesheets/up/tooltip.css.sass
120
123
  - lib/upjs-rails.rb
121
124
  - lib/upjs/rails/engine.rb
125
+ - lib/upjs/rails/inspector.rb
126
+ - lib/upjs/rails/inspector_accessor.rb
122
127
  - lib/upjs/rails/request_echo_headers.rb
123
- - lib/upjs/rails/request_ext.rb
124
128
  - lib/upjs/rails/request_method_cookie.rb
125
129
  - lib/upjs/rails/version.rb
126
130
  - spec_app/.firefox-version
127
131
  - spec_app/.gitignore
132
+ - spec_app/.rspec
128
133
  - spec_app/Bowerfile
129
134
  - spec_app/Gemfile
130
135
  - spec_app/Gemfile.lock
@@ -142,6 +147,7 @@ files:
142
147
  - spec_app/app/controllers/cards_controller.rb
143
148
  - spec_app/app/controllers/concerns/.keep
144
149
  - spec_app/app/controllers/pages_controller.rb
150
+ - spec_app/app/controllers/test_controller.rb
145
151
  - spec_app/app/helpers/application_helper.rb
146
152
  - spec_app/app/mailers/.keep
147
153
  - spec_app/app/models/card.rb
@@ -200,6 +206,8 @@ files:
200
206
  - spec_app/public/favicon.ico
201
207
  - spec_app/public/robots.txt
202
208
  - spec_app/script/cucumber
209
+ - spec_app/spec/controllers/test_controller_spec.rb
210
+ - spec_app/spec/javascripts/helpers/append_fixture.js.coffee
203
211
  - spec_app/spec/javascripts/helpers/index.js.coffee
204
212
  - spec_app/spec/javascripts/helpers/knife.js.coffee
205
213
  - spec_app/spec/javascripts/helpers/last_request.js.coffee
@@ -229,6 +237,7 @@ files:
229
237
  - spec_app/spec/javascripts/up/syntax_spec.js.coffee
230
238
  - spec_app/spec/javascripts/up/tooltip_spec.js.coffee
231
239
  - spec_app/spec/javascripts/up/util_spec.js.coffee
240
+ - spec_app/spec/spec_helper.rb
232
241
  - spec_app/test/controllers/.keep
233
242
  - spec_app/test/fixtures/.keep
234
243
  - spec_app/test/helpers/.keep
@@ -1,13 +0,0 @@
1
- module Upjs
2
- module Rails
3
- module Request
4
-
5
- def up?
6
- headers['X-Up-Selector'].present?
7
- end
8
-
9
- ActionDispatch::Request.send(:include, self)
10
-
11
- end
12
- end
13
- end