jquery-rails 4.3.1 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8c5d85690ee85928e2a30da55fa2b5aef44b96ed
4
- data.tar.gz: 9c89df4fbd6151582e4db8681690234da7528309
2
+ SHA256:
3
+ metadata.gz: dcc6d11eb09cef26ed783513d708893c0d8fcede0b5027fc5906e59feeb880b9
4
+ data.tar.gz: 0e0c30ec8043042ccdc6099fb6f5f2b6055f8b52a42298fb35144280d15661da
5
5
  SHA512:
6
- metadata.gz: 2309598856c6a21cfea1dde8f8261b992641f6c6711fe87b508af6ab82e44675c5e8c75d4f670282186e25637ab4a557248c3f08639bd183ae06a994aecffcd5
7
- data.tar.gz: b8e53ac98827eba878369fa1e3ed6f94c35be7fa91bf2f7a4812fbf6345d16474fec5689520a7cb8f5911b78be3818dd9bc2272a719174270ab41cef87b5e824
6
+ metadata.gz: a417086a5430147e22d452f1d192494d89890b7417257f759c721023f71a3f620a4f7328a5a5bd1c7e746786b861bc90aa1ba0174749b0a3f9dcef72a5e2ea78
7
+ data.tar.gz: badccf9a2417c5ac5623f667317ac33e2e27cf8aaf562be71a139f207006fd8469234e2cd48fdcd9860e658710dff4bd53272066e688033fceddeced9267af6d
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,3 +1,28 @@
1
+ ## 4.4.0
2
+
3
+ - update jquery to 3.5.1 (note: [3.5.0 contains important security updates](https://github.com/advisories/GHSA-jpcq-cgw6-v4j6))
4
+ - unescape dollar signs and backticks in `assert_select_jquery` to match
5
+ Rails updated behavior.
6
+
7
+ ## 4.3.5
8
+
9
+ - update jquery to 3.4.1
10
+
11
+ ## 4.3.4
12
+
13
+ - update jquery to 3.4.0
14
+
15
+ ## 4.3.3
16
+
17
+ - update jquery to 3.3.1
18
+
19
+ ## 4.3.2
20
+
21
+ - update jquery to 3.3.0
22
+ - Add possibility to test HTML: all, attribute prefix, attribute contains,
23
+ attribute ends with, child, and class selectors
24
+ - Fix matching mutiple calls for the same selector/function exception
25
+
1
26
  ## 4.3.1
2
27
 
3
28
  - update jquery to 3.2.1
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,11 @@
2
2
 
3
3
  | Gem | jQuery | jQuery UJS | jQuery UI |
4
4
  |--------|--------|------------| ----------|
5
+ | 4.4.0 | 1.12.4 & 2.2.4 & 3.5.1 | 1.2.2 | - |
6
+ | 4.3.5 | 1.12.4 & 2.2.4 & 3.4.1 | 1.2.2 | - |
7
+ | 4.3.4 | 1.12.4 & 2.2.4 & 3.4.0 | 1.2.2 | - |
8
+ | 4.3.3 | 1.12.4 & 2.2.4 & 3.3.1 | 1.2.2 | - |
9
+ | 4.3.2 | 1.12.4 & 2.2.4 & 3.3.0 | 1.2.2 | - |
5
10
  | 4.3.1 | 1.12.4 & 2.2.4 & 3.2.1 | 1.2.2 | - |
6
11
  | 4.3.0 | 1.12.4 & 2.2.4 & 3.2.0 | 1.2.2 | - |
7
12
  | 4.2.2 | 1.12.4 & 2.2.4 & 3.1.1 | 1.2.2 | - |
@@ -47,9 +47,9 @@ 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
@@ -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,6 +124,8 @@ 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
@@ -134,6 +136,15 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
134
136
 
135
137
  id = selector.gsub('[', '\[')
136
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!(',', '\,')
137
148
 
138
149
  id
139
150
  end
@@ -1,9 +1,9 @@
1
1
  module Jquery
2
2
  module Rails
3
- VERSION = "4.3.1"
3
+ VERSION = "4.4.0"
4
4
  JQUERY_VERSION = "1.12.4"
5
5
  JQUERY_2_VERSION = "2.2.4"
6
- JQUERY_3_VERSION = "3.2.1"
6
+ JQUERY_3_VERSION = "3.5.1"
7
7
  JQUERY_UJS_VERSION = "1.2.2"
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,12 +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();
16
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>');
17
28
  JS
18
29
 
19
30
  setup do
@@ -23,6 +34,7 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
23
34
  def test_target_as_receiver
24
35
  assert_nothing_raised do
25
36
  assert_select_jquery :show, :blind, '#card'
37
+ assert_select_jquery :hide, :blind, '#browser_cart'
26
38
  assert_select_jquery :html, '#id' do
27
39
  assert_select 'p', 'something'
28
40
  end
@@ -30,17 +42,31 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
30
42
  assert_select 'p', 'something'
31
43
  end
32
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
33
52
  end
34
53
 
35
54
  assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do
36
55
  assert_select_jquery :show, :some_wrong
37
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
38
63
  end
39
64
 
40
65
  def test_target_as_argument
41
66
  assert_nothing_raised do
42
67
  assert_select_jquery :appendTo, '#id' do
43
68
  assert_select 'p', 'something'
69
+ assert_select 'p', 'something else'
44
70
  end
45
71
  assert_select_jquery :prependTo, '#id' do
46
72
  assert_select 'p', 'something'