view_component 2.79.0 → 2.81.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.

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: 816041da43cddd9b2b791c005c7122781da97d7b38c068d3d587b8b66665759e
4
- data.tar.gz: 4afc380c903978336d80842509d1c9082709686cb4e1361674ce1793220e7db9
3
+ metadata.gz: bd53c4661f35fd92f4b4cf05bfcd8af23c5a4e6bd60b13a6af492393b75290fe
4
+ data.tar.gz: def906e9d722ffeb43fc79677c6c3613de4c9f7eec63eecc4d36f0feedfe5785
5
5
  SHA512:
6
- metadata.gz: 818a443353202ce4d3c63cdf3cb67ad2e1b35065f1961dac48dc5de0095331492a5ab886845f908fa7c5ca89d4ee8e02382c35973166086d3177a081720aa3c7
7
- data.tar.gz: eeae1fb4978a03e2cc2da23af48bd035b43a6dc6b9408c3b5b318f45ff2a2f3b4c9f6f83386e62d8fdad802693c6a6d42b9c222c7e3974ba58a498b75cd6e78a
6
+ metadata.gz: 2f6c8525b8e0b1366e283b870deebc95ae0920c6910846a658590c8665239fbdc1c6f0ef1681c95ee811ac9d7a995a86f7cf6764cb61e636a8e8de305567f2a7
7
+ data.tar.gz: 447035b6780c59291f2014856703fc73d13838d4765f7185657e6f26b4be60937b561cafac7a994a68c12c68f10f7c0956948cd4c44355f3d0b875d85738e2d4
@@ -39,12 +39,6 @@ module ViewComponent
39
39
  end
40
40
  end
41
41
 
42
- if Rails.env.test?
43
- def system_test_entrypoint
44
- render file: "./tmp/view_components/#{params.permit(:file)[:file]}"
45
- end
46
- end
47
-
48
42
  private
49
43
 
50
44
  # :doc:
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/application_controller"
4
+
5
+ class ViewComponentsSystemTestController < Rails::ApplicationController # :nodoc:
6
+ def system_test_entrypoint
7
+ render file: "./tmp/view_components/#{params.permit(:file)[:file]}"
8
+ end
9
+ end
data/docs/CHANGELOG.md CHANGED
@@ -10,6 +10,38 @@ nav_order: 5
10
10
 
11
11
  ## main
12
12
 
13
+ ## 2.81.0
14
+
15
+ * Adjust the way response objects are set on the preview controller to work around a recent change in Rails main.
16
+
17
+ *Cameron Dutro*
18
+
19
+ * Fix typo in "Generate a Stimulus controller" documentation.
20
+
21
+ *Ben Trewern*
22
+
23
+ * Modify the `render_in_view_context` test helper to forward its args to the block.
24
+
25
+ *Cameron Dutro*
26
+
27
+ ## 2.80.0
28
+
29
+ * Move system test endpoint out of the unrelated previews controller.
30
+
31
+ *Edwin Mak*
32
+
33
+ * Display Ruby 2.7 deprecation notice only once, when starting the application.
34
+
35
+ *Henrik Hauge Bjørnskov*
36
+
37
+ * Require Rails 5.2+ in gemspec and update documentation.
38
+
39
+ *Drew Bragg*
40
+
41
+ * Add documentation for using `with_rendered_component_path` with RSpec.
42
+
43
+ *Edwin Mak*
44
+
13
45
  ## 2.79.0
14
46
 
15
47
  * Add ability to pass explicit `preview_path` to preview generator.
@@ -30,10 +30,6 @@ module ViewComponent
30
30
  return if compiled? && !force
31
31
  return if component_class == ViewComponent::Base
32
32
 
33
- if RUBY_VERSION < "2.7.0"
34
- ViewComponent::Deprecation.deprecation_warning("Support for Ruby versions < 2.7.0")
35
- end
36
-
37
33
  component_class.superclass.compile(raise_errors: raise_errors) if should_compile_superclass?
38
34
  subclass_instance_methods = component_class.instance_methods(false)
39
35
 
@@ -121,10 +121,6 @@ module ViewComponent
121
121
  internal: true
122
122
  )
123
123
 
124
- if Rails.env.test?
125
- get("_system_test_entrypoint", to: "#{preview_controller}#system_test_entrypoint")
126
- end
127
-
128
124
  get(
129
125
  "#{options.preview_route}/*path",
130
126
  to: "#{preview_controller}#previews",
@@ -134,6 +130,12 @@ module ViewComponent
134
130
  end
135
131
  end
136
132
 
133
+ if Rails.env.test?
134
+ app.routes.prepend do
135
+ get("_system_test_entrypoint", to: "view_components_system_test#system_test_entrypoint")
136
+ end
137
+ end
138
+
137
139
  app.executor.to_run :before do
138
140
  CompileCache.invalidate! unless ActionView::Base.cache_template_loading
139
141
  end
@@ -141,6 +143,10 @@ module ViewComponent
141
143
  end
142
144
  end
143
145
 
146
+ if RUBY_VERSION < "2.7.0"
147
+ ViewComponent::Deprecation.deprecation_warning("Support for Ruby versions < 2.7.0")
148
+ end
149
+
144
150
  # :nocov:
145
151
  unless defined?(ViewComponent::Base)
146
152
  require "view_component/deprecation"
@@ -91,7 +91,7 @@ module ViewComponent
91
91
  end
92
92
 
93
93
  previews_controller.request.params[:path] = "#{from.preview_name}/#{name}"
94
- previews_controller.response = ActionDispatch::Response.new
94
+ previews_controller.set_response!(ActionDispatch::Response.new)
95
95
  result = previews_controller.previews
96
96
 
97
97
  @rendered_content = result
@@ -99,21 +99,23 @@ module ViewComponent
99
99
  Nokogiri::HTML.fragment(@rendered_content)
100
100
  end
101
101
 
102
- # Execute the given block in the view context. Internally sets `page` to be a
103
- # `Capybara::Node::Simple`, allowing for Capybara assertions to be used:
102
+ # Execute the given block in the view context (using `instance_exec`).
103
+ # Internally sets `page` to be a `Capybara::Node::Simple`, allowing for
104
+ # Capybara assertions to be used. All arguments are forwarded to the block.
104
105
  #
105
106
  # ```ruby
106
- # render_in_view_context do
107
- # render(MyComponent.new)
107
+ # render_in_view_context(arg1, arg2:) do |arg1, arg2:|
108
+ # render(MyComponent.new(arg1, arg2))
108
109
  # end
109
110
  #
110
111
  # assert_text("Hello, World!")
111
112
  # ```
112
- def render_in_view_context(&block)
113
+ def render_in_view_context(*args, &block)
113
114
  @page = nil
114
- @rendered_content = controller.view_context.instance_exec(&block)
115
+ @rendered_content = controller.view_context.instance_exec(*args, &block)
115
116
  Nokogiri::HTML.fragment(@rendered_content)
116
117
  end
118
+ ruby2_keywords(:render_in_view_context) if respond_to?(:ruby2_keywords, true)
117
119
 
118
120
  # @private
119
121
  def controller
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 79
6
+ MINOR = 81
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
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: 2.79.0
4
+ version: 2.81.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: 2022-12-12 00:00:00.000000000 Z
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 5.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '8.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 5.0.0
29
+ version: 5.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '8.0'
@@ -322,6 +322,7 @@ files:
322
322
  - app/assets/vendor/prism.min.js
323
323
  - app/controllers/concerns/view_component/preview_actions.rb
324
324
  - app/controllers/view_components_controller.rb
325
+ - app/controllers/view_components_system_test_controller.rb
325
326
  - app/helpers/preview_helper.rb
326
327
  - app/views/test_mailer/test_email.html.erb
327
328
  - app/views/view_components/_preview_source.html.erb