jquery-rails 4.2.1 → 4.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 465698ea71d2cfda07c7bc5dab8cb50fb34ab56f
4
- data.tar.gz: c937ef622e018d620633e6fd613c67b7198c23f7
2
+ SHA256:
3
+ metadata.gz: aec69fba390c8f18171f492bd99d8dc2a6cf6e3e8c124beae74ac6420e98e2dd
4
+ data.tar.gz: 18a8be95db572fe6c5c219c556862a2d04d6cd024ce06c28801d367bb5a8009f
5
5
  SHA512:
6
- metadata.gz: bb9015f2ba8cfa59a8d1a5e820ff3f70c74e3fef6116253849e1a92e5aab0fc2deb8596974d9b149f3f5a57c892124c52d9b135a44bd75fd8188f143439225c3
7
- data.tar.gz: 56932e346d376defd1cb9189b70d3e31c116abe6e0fbb6e17f5ab3252b65e6d788999bf1ce3f49cca5f89819c755afbd478e27fde899e42d1b47e0bbc5dfb9b6
6
+ metadata.gz: c83564699021f023a06e88221a3a9feb06070ba40709493dbd358af558f29a8ef96a79d063080ad8cef864d680731f3aecb4d01a74a5c384e731124c10145a8a
7
+ data.tar.gz: 6d89ffac1ce80f8d5c2765621220ec5b3d90bf80ba9a22ce2acbb6f13cfab285b096b2314175ccd5a96a348482d4b67b4bb19395e945814f3e9dc0a416a93aef
data/.travis.yml CHANGED
@@ -4,15 +4,20 @@ language: ruby
4
4
  rvm:
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - 2.1
8
- - 2.2.5
9
- - 2.3.0
7
+ - 2.1.10
8
+ - 2.2.9
9
+ - 2.3.6
10
+ - 2.4.10
11
+ - 2.5.8
12
+ - 2.6.6
13
+ - 2.7.1
10
14
  - jruby
11
15
  - ruby-head
12
16
  matrix:
13
17
  fast_finish: true
14
18
  allow_failures:
15
19
  - rvm: jruby
20
+ - rvm: ruby-head
16
21
  notifications:
17
22
  email: false
18
23
  irc:
data/CHANGELOG.md CHANGED
@@ -1,6 +1,61 @@
1
- ## 4.2.0
1
+ ## 4.6.1
2
+
3
+ - update jquery to 3.7.1
4
+
5
+ ## 4.6.0
6
+
7
+ - update jquery to 3.7.0
8
+
9
+ ## 4.5.1
10
+
11
+ - update jquery to 3.6.1
12
+ - update jquery-ujs to 1.2.3
13
+
14
+ ## 4.5.0
15
+
16
+ - update jquery to 3.6.0
17
+
18
+ ## 4.4.0
19
+
20
+ - update jquery to 3.5.1 (note: [3.5.0 contains important security updates](https://github.com/advisories/GHSA-jpcq-cgw6-v4j6))
21
+ - unescape dollar signs and backticks in `assert_select_jquery` to match
22
+ Rails updated behavior.
23
+
24
+ ## 4.3.5
25
+
26
+ - update jquery to 3.4.1
27
+
28
+ ## 4.3.4
29
+
30
+ - update jquery to 3.4.0
31
+
32
+ ## 4.3.3
33
+
34
+ - update jquery to 3.3.1
35
+
36
+ ## 4.3.2
37
+
38
+ - update jquery to 3.3.0
39
+ - Add possibility to test HTML: all, attribute prefix, attribute contains,
40
+ attribute ends with, child, and class selectors
41
+ - Fix matching multiple calls for the same selector/function exception
42
+
43
+ ## 4.3.1
44
+
45
+ - update jquery to 3.2.1
46
+
47
+ ## 4.3.0
48
+
49
+ - update jquery to 3.2.0
50
+ - Add possibility to test HTML attribute selectors
51
+
52
+ ## 4.2.2
53
+
54
+ - update jquery to 3.1.1
55
+
56
+ ## 4.2.1
2
57
 
3
- - Update jQuery to 3.1.0
58
+ - update jquery to 3.1.0
4
59
 
5
60
  ## 4.2.0
6
61
 
data/Gemfile CHANGED
@@ -1,6 +1,22 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', group: :test
3
+ gem "mime-types", "< 3", group: :test
4
+
5
+ if RUBY_VERSION >= '2.2.2'
6
+ gem 'rails'
7
+ gem 'rack'
8
+ gem 'json', '>= 2'
9
+ else
10
+ gem 'rails', '~> 4.2.0'
11
+ gem 'rack', '~>1.6'
12
+ gem 'json', '~> 1.8.0'
13
+ end
14
+
15
+ if RUBY_VERSION >= '2.1'
16
+ gem 'nokogiri'
17
+ else
18
+ gem 'nokogiri', '~> 1.6.0'
19
+ end
4
20
 
5
21
  # Specify your gem's dependencies in jquery-rails.gemspec
6
22
  gemspec
data/README.md CHANGED
@@ -24,6 +24,12 @@ versions of jQuery.
24
24
 
25
25
  ## Installation
26
26
 
27
+ Add
28
+ ```
29
+ gem 'jquery-rails'
30
+ ```
31
+ to your Gemfile.
32
+
27
33
  The jquery and jquery-ujs files will be added to the asset pipeline and available for you to use. If they're not already in `app/assets/javascripts/application.js` by default, add these lines:
28
34
 
29
35
  ```js
@@ -31,6 +37,12 @@ The jquery and jquery-ujs files will be added to the asset pipeline and availabl
31
37
  //= require jquery_ujs
32
38
  ```
33
39
 
40
+ If you are running Rails 5.1 and up, and if you have included `//= require rails-ujs`, then `jquery_ujs` is not needed anymore. You can just add:
41
+
42
+ ```js
43
+ //= require jquery
44
+ ```
45
+
34
46
  If you want to use jQuery 2, you can require `jquery2` instead:
35
47
 
36
48
  ```js
@@ -66,4 +78,4 @@ jquery-rails is released under the [MIT License](MIT-LICENSE).
66
78
 
67
79
  ## Acknowledgements
68
80
 
69
- Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/organizations/rails/teams/617) for making jquery-rails an official part of Rails 3.1.
81
+ Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/orgs/rails/people) for making jquery-rails an official part of Rails 3.1.
data/VERSIONS.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  | Gem | jQuery | jQuery UJS | jQuery UI |
4
4
  |--------|--------|------------| ----------|
5
+ | 4.6.1 | 1.12.4 & 2.2.4 & 3.7.1 | 1.2.3 | - |
6
+ | 4.6.0 | 1.12.4 & 2.2.4 & 3.7.0 | 1.2.3 | - |
7
+ | 4.5.1 | 1.12.4 & 2.2.4 & 3.6.1 | 1.2.3 | - |
8
+ | 4.5.0 | 1.12.4 & 2.2.4 & 3.6.0 | 1.2.2 | - |
9
+ | 4.4.0 | 1.12.4 & 2.2.4 & 3.5.1 | 1.2.2 | - |
10
+ | 4.3.5 | 1.12.4 & 2.2.4 & 3.4.1 | 1.2.2 | - |
11
+ | 4.3.4 | 1.12.4 & 2.2.4 & 3.4.0 | 1.2.2 | - |
12
+ | 4.3.3 | 1.12.4 & 2.2.4 & 3.3.1 | 1.2.2 | - |
13
+ | 4.3.2 | 1.12.4 & 2.2.4 & 3.3.0 | 1.2.2 | - |
14
+ | 4.3.1 | 1.12.4 & 2.2.4 & 3.2.1 | 1.2.2 | - |
15
+ | 4.3.0 | 1.12.4 & 2.2.4 & 3.2.0 | 1.2.2 | - |
16
+ | 4.2.2 | 1.12.4 & 2.2.4 & 3.1.1 | 1.2.2 | - |
5
17
  | 4.2.1 | 1.12.4 & 2.2.4 & 3.1.0 | 1.2.2 | - |
6
18
  | 4.2.0 | 1.12.4 & 2.2.4 & 3.0.0 | 1.2.2 | - |
7
19
  | 4.1.1 | 1.12.1 & 2.2.1 | 1.2.1 | - |
@@ -47,14 +47,14 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
47
47
  # assert_select '.product'
48
48
  # end
49
49
 
50
- PATTERN_HTML = "['\"]((\\\\\"|[^\"])*)['\"]"
50
+ PATTERN_HTML = "['\"]((\\\\\"|\\\\'|[^\"'])*)['\"]"
51
51
  PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
52
- SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\);"
52
+ SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\)[;]?"
53
53
 
54
54
  def assert_select_jquery(*args, &block)
55
55
  jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
56
56
  jquery_opt = args.first.is_a?(Symbol) ? args.shift : nil
57
- id = args.first.is_a?(String) ? args.shift : nil
57
+ id = args.first.is_a?(String) ? escape_id(args.shift) : nil
58
58
 
59
59
  target_pattern = "['\"]#{id || '.*'}['\"]"
60
60
  method_pattern = "#{jquery_method || '\\w+'}"
@@ -91,14 +91,14 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
91
91
 
92
92
  if block_given?
93
93
  @selected ||= nil
94
- fragments = Nokogiri::HTML::Document.new
94
+ fragments = Nokogiri::HTML::Document.new.fragment
95
95
 
96
96
  if matched_pattern
97
97
  response.body.scan(Regexp.new(matched_pattern)).each do |match|
98
98
  flunk 'This function can\'t have HTML argument' if match.is_a?(String)
99
99
 
100
- doc = Nokogiri::HTML::Document.parse(unescape_js(match.first))
101
- doc.root.children.each do |child|
100
+ doc = Nokogiri::HTML::DocumentFragment.parse(unescape_js(match.first))
101
+ doc.children.each do |child|
102
102
  fragments << child if child.element?
103
103
  end
104
104
  end
@@ -124,8 +124,28 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
124
124
  unescaped.gsub!('\n', "\n")
125
125
  unescaped.gsub!('\076', '>')
126
126
  unescaped.gsub!('\074', '<')
127
+ unescaped.gsub!(/\\\$/, '$')
128
+ unescaped.gsub!(/\\`/, '`')
127
129
  # js encodes non-ascii characters.
128
130
  unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
129
131
  unescaped
130
132
  end
133
+
134
+ def escape_id(selector)
135
+ return unless selector
136
+
137
+ id = selector.gsub('[', '\[')
138
+ id.gsub!(']', '\]')
139
+ id.gsub!('*', '\*')
140
+ id.gsub!('(', '\(')
141
+ id.gsub!(')', '\)')
142
+ id.gsub!('.', '\.')
143
+ id.gsub!('|', '\|')
144
+ id.gsub!('^', '\^')
145
+ id.gsub!('$', '\$')
146
+ id.gsub!('+', "\\\\+")
147
+ id.gsub!(',', '\,')
148
+
149
+ id
150
+ end
131
151
  end
@@ -1,9 +1,9 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "4.2.1"
3
+ VERSION = "4.6.1"
4
4
  JQUERY_VERSION = "1.12.4"
5
5
  JQUERY_2_VERSION = "2.2.4"
6
- JQUERY_3_VERSION = "3.1.0"
7
- JQUERY_UJS_VERSION = "1.2.2"
6
+ JQUERY_3_VERSION = "3.7.1"
7
+ JQUERY_UJS_VERSION = "1.2.3"
8
8
  end
9
9
  end
@@ -1,3 +1,4 @@
1
+ require 'ostruct'
1
2
  require_relative 'test_helper'
2
3
  require_relative '../lib/jquery/assert_select'
3
4
 
@@ -8,11 +9,22 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
8
9
  JAVASCRIPT_TEST_OUTPUT = <<-JS
9
10
  $("#card").show("blind", 1000);
10
11
  $("#id").html('<div><p>something</p></div>');
12
+ $('#card').html('<div><p>something else</p></div>');
11
13
  jQuery("#id").replaceWith("<div><p>something</p></div>");
12
14
  $("<div><p>something</p></div>").appendTo("#id");
15
+ $("<div><p>something else</p></div>").appendTo("#id");
13
16
  jQuery("<div><p>something</p></div>").prependTo("#id");
14
17
  $('#id').remove();
15
18
  jQuery("#id").hide();
19
+ $("[data-placeholder~=name]").remove();
20
+ $("#cart tr:not(.total_line) > *").remove();
21
+ $("[href|=\"val\"][href$=\"val\"][href^=\"val\"]").remove();
22
+ $("tr + td, li").remove();
23
+
24
+ // without semicolon
25
+ $("#browser_cart").hide("blind", 1000)
26
+
27
+ $('#item').html('<div><span>\\`Total\\`: \\$12.34</span></div>');
16
28
  JS
17
29
 
18
30
  setup do
@@ -22,23 +34,39 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
22
34
  def test_target_as_receiver
23
35
  assert_nothing_raised do
24
36
  assert_select_jquery :show, :blind, '#card'
37
+ assert_select_jquery :hide, :blind, '#browser_cart'
25
38
  assert_select_jquery :html, '#id' do
26
39
  assert_select 'p', 'something'
27
40
  end
28
41
  assert_select_jquery :replaceWith, '#id' do
29
42
  assert_select 'p', 'something'
30
43
  end
44
+ assert_select_jquery :remove, "[data-placeholder~=name]"
45
+ assert_select_jquery :remove, "#cart tr:not(.total_line) > *"
46
+ assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]"
47
+ assert_select_jquery :remove, "tr + td, li"
48
+
49
+ assert_select_jquery :html, '#item' do
50
+ assert_select 'span', '`Total`: $12.34'
51
+ end
31
52
  end
32
53
 
33
54
  assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do
34
55
  assert_select_jquery :show, :some_wrong
35
56
  end
57
+
58
+ assert_raise Minitest::Assertion, "<something else> was expected but was <something>" do
59
+ assert_select_jquery :html, '#id' do
60
+ assert_select 'p', 'something else'
61
+ end
62
+ end
36
63
  end
37
64
 
38
65
  def test_target_as_argument
39
66
  assert_nothing_raised do
40
67
  assert_select_jquery :appendTo, '#id' do
41
68
  assert_select 'p', 'something'
69
+ assert_select 'p', 'something else'
42
70
  end
43
71
  assert_select_jquery :prependTo, '#id' do
44
72
  assert_select 'p', 'something'