view_component 2.59.0 → 2.61.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: ca82494216cd6b91d9a073bd1ab025cbe48049560893a500e72caff01141e02f
4
- data.tar.gz: 9eecd79663f09edb31cae5a104b861c4922a99a92307f583b0703b11053a2d60
3
+ metadata.gz: f46bf10c68e5273401ec52134ae2cf55d844f9b01c55121e082146364194e144
4
+ data.tar.gz: 81ec5867c81158b0c06fdab309674f2f5a9cef7cf0546575308084ac928116c6
5
5
  SHA512:
6
- metadata.gz: 4e04336d18bd57be41e3ae4637ae1978a4884a352fced4b852a40901fa1ff02a13e6266ab4c669fbb3669fa718eecbfd8a5b13c54df79cbb9b692e278f02f35e
7
- data.tar.gz: 2fed6153f148f683afe4cd27c909051aedfc92e9f896e6fe41736083d05217e7df15ac12799291fd2299ca59c1ee12e7ec1145ac9be5ee78cacb81d55fccf548
6
+ metadata.gz: 05450d5c3e5376fe7aa4a2a934ee2b7179cafb91681cf1b6ed7f1469bd3db29f92d0ba6e96930e36403f7e250a3b7b8aeb7cc061aa30954d2d8524c6d7081d6b
7
+ data.tar.gz: 91101a168fee89fd23dad833c769027db7022a852b07b918d427b40a8b1997b861827724f7390dd470f4e69e1a8351638a43cd2d34f6df9bf20c64be0eb61d43
data/docs/CHANGELOG.md CHANGED
@@ -9,6 +9,18 @@ title: Changelog
9
9
 
10
10
  ## main
11
11
 
12
+ ## 2.61.0
13
+
14
+ * Ensure side-effects in `content` are consistently evaluated before components are rendered. This change effectively means that `content` is evaluated for every component render where `render?` returns true. As a result, code that is passed to a component via a block/content will now always be evaluated, before `#call`, which can reveal bugs in existing components.
15
+
16
+ *Blake Williams*
17
+
18
+ ## 2.60.0
19
+
20
+ * Add support for `render_preview` in RSpec tests.
21
+
22
+ *Thomas Hutterer*
23
+
12
24
  ## 2.59.0
13
25
 
14
26
  * Expose Capybara DSL methods directly inside tests.
@@ -124,6 +124,10 @@ module ViewComponent
124
124
  before_render
125
125
 
126
126
  if render?
127
+ # preload content to support slot delegation and to consistently perform
128
+ # side-effects that may exist in the block
129
+ content
130
+
127
131
  perform_render
128
132
  else
129
133
  ""
@@ -15,11 +15,21 @@ module ViewComponent
15
15
  #
16
16
  # MyComponentTest -> MyComponentPreview etc.
17
17
  #
18
+ # In RSpec, `Preview` is appended to `described_class`.
19
+ #
18
20
  # @param preview [String] The name of the preview to be rendered.
19
21
  # @return [Nokogiri::HTML]
20
22
  def render_preview(name)
21
23
  begin
22
- preview_klass = self.class.name.gsub("Test", "Preview")
24
+ preview_klass = if respond_to?(:described_class)
25
+ if described_class.nil?
26
+ raise "`render_preview` expected a described_class, but it is nil."
27
+ end
28
+
29
+ "#{described_class}Preview"
30
+ else
31
+ self.class.name.gsub("Test", "Preview")
32
+ end
23
33
  preview_klass = preview_klass.constantize
24
34
  rescue NameError
25
35
  raise NameError.new(
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 59
6
+ MINOR = 61
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.59.0
4
+ version: 2.61.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-13 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport