view_component 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e505722b47ce320345cbb123e06e5138362a3b9abc5fe8cc77c5849a71e8baf5
4
- data.tar.gz: c9f053e92c067b2743ae64d8135334518a14933710c81ad68e058d0cd076b610
3
+ metadata.gz: dfae7c952ad3086e6df45516e19bdbf8699b3c87209675dbe6e98d07d7457678
4
+ data.tar.gz: 11b457c1aa7784e98b4e09913e6206083ad8e6e6c0bb66832ee7b91f097a481a
5
5
  SHA512:
6
- metadata.gz: 3e3aab08e8665557c94e0f8df5c7f0f484b056bc9e0a85247a7d718cedfc3ff8aa3a2a6875fd4660626b15c0f6e002ac50797fdcce822f610ca91581afff8c9e
7
- data.tar.gz: 2f25ccc3bcfefb4e3096a5c9289922b648353ba42c333ad963d59cc95f8bd1cf4d1db0f178494ad6cb4a59af6832a852b3b15f34f80dc3c2ebfa6cf78d65b445
6
+ metadata.gz: d90880b28c40393b2d198e71df13a12fe078069aeeb8c629fd34b96e636b67120017cb9d49948fe4f73f2a41dbd2d345ba5465728d940668a895ce5ca6407ee5
7
+ data.tar.gz: da53115421cdad2b9522bb6db4d518c0851dde9d5e6191a677316bd1a8fe56945be99ac3632e3a9b2f069f69141f32fa77797c6d8d3f056a4bb7e8323a465b71
@@ -59,7 +59,7 @@ module ViewComponent
59
59
  def find_preview
60
60
  candidates = []
61
61
  params[:path].to_s.scan(%r{/|$}) { candidates << Regexp.last_match.pre_match }
62
- preview = candidates.detect { |candidate| ViewComponent::Preview.exists?(candidate) }
62
+ preview = candidates.sort_by(&:length).reverse_each.detect { |candidate| ViewComponent::Preview.exists?(candidate) }
63
63
 
64
64
  if preview
65
65
  @preview = ViewComponent::Preview.find(preview)
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,20 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 3.3.0
14
+
15
+ * Include InlineTemplate by default in Base. **Note:** It's no longer necessary to include `ViewComponent::InlineTemplate` to use inline templates.
16
+
17
+ *Joel Hawksley*
18
+
19
+ * Allow Setting host when using the `with_request_url` test helper.
20
+
21
+ *Daniel Alfaro*
22
+
23
+ * Resolve ambiguous preview paths when using components without the Component suffix.
24
+
25
+ *Reed Law*
26
+
13
27
  ## 3.2.0
14
28
 
15
29
  * Fix viewcomponent.org Axe violations.
@@ -7,6 +7,7 @@ require "view_component/compile_cache"
7
7
  require "view_component/compiler"
8
8
  require "view_component/config"
9
9
  require "view_component/errors"
10
+ require "view_component/inline_template"
10
11
  require "view_component/preview"
11
12
  require "view_component/slotable"
12
13
  require "view_component/translatable"
@@ -29,6 +30,7 @@ module ViewComponent
29
30
  attr_writer :config
30
31
  end
31
32
 
33
+ include ViewComponent::InlineTemplate
32
34
  include ViewComponent::Slotable
33
35
  include ViewComponent::Translatable
34
36
  include ViewComponent::WithContentHelper
@@ -39,7 +39,7 @@ module ViewComponent # :nodoc:
39
39
  end
40
40
 
41
41
  def inline_template
42
- @__vc_inline_template
42
+ @__vc_inline_template if defined?(@__vc_inline_template)
43
43
  end
44
44
 
45
45
  def inline_template_language
@@ -4,8 +4,10 @@ task stats: "view_component:statsetup"
4
4
 
5
5
  namespace :view_component do
6
6
  task :statsetup do
7
+ # :nocov:
7
8
  require "rails/code_statistics"
8
9
 
9
10
  ::STATS_DIRECTORIES << ["ViewComponents", ViewComponent::Base.view_component_path]
11
+ # :nocov:
10
12
  end
11
13
  end
@@ -156,7 +156,9 @@ module ViewComponent
156
156
  # ```
157
157
  #
158
158
  # @param path [String] The path to set for the current request.
159
- def with_request_url(path)
159
+ # @param host [String] The host to set for the current request.
160
+ def with_request_url(path, host: nil)
161
+ old_request_host = vc_test_request.host
160
162
  old_request_path_info = vc_test_request.path_info
161
163
  old_request_path_parameters = vc_test_request.path_parameters
162
164
  old_request_query_parameters = vc_test_request.query_parameters
@@ -164,12 +166,14 @@ module ViewComponent
164
166
  old_controller = defined?(@vc_test_controller) && @vc_test_controller
165
167
 
166
168
  path, query = path.split("?", 2)
169
+ vc_test_request.host = host if host
167
170
  vc_test_request.path_info = path
168
171
  vc_test_request.path_parameters = Rails.application.routes.recognize_path_with_request(vc_test_request, path, {})
169
172
  vc_test_request.set_header("action_dispatch.request.query_parameters", Rack::Utils.parse_nested_query(query))
170
173
  vc_test_request.set_header(Rack::QUERY_STRING, query)
171
174
  yield
172
175
  ensure
176
+ vc_test_request.host = old_request_host
173
177
  vc_test_request.path_info = old_request_path_info
174
178
  vc_test_request.path_parameters = old_request_path_parameters
175
179
  vc_test_request.set_header("action_dispatch.request.query_parameters", old_request_query_parameters)
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 3
6
- MINOR = 2
6
+ MINOR = 3
7
7
  PATCH = 0
8
8
  PRE = nil
9
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ViewComponent Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-12 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport