jbuilder 2.12.0 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +0 -43
- data/Appraisals +0 -27
- data/CONTRIBUTING.md +1 -7
- data/bin/release +14 -0
- data/bin/test +6 -0
- data/jbuilder.gemspec +3 -1
- data/lib/generators/rails/templates/api_controller.rb +6 -0
- data/lib/generators/rails/templates/controller.rb +9 -3
- data/lib/jbuilder/jbuilder_template.rb +20 -11
- data/lib/jbuilder/version.rb +3 -0
- data/lib/jbuilder.rb +2 -6
- data/test/jbuilder_template_test.rb +16 -0
- data/test/scaffold_api_controller_generator_test.rb +15 -2
- data/test/scaffold_controller_generator_test.rb +21 -8
- metadata +8 -10
- data/gemfiles/rails_5_0.gemfile +0 -11
- data/gemfiles/rails_5_1.gemfile +0 -11
- data/gemfiles/rails_5_2.gemfile +0 -11
- data/gemfiles/rails_6_0.gemfile +0 -10
- data/gemfiles/rails_6_1.gemfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23152c62d2a748a3a3b190dba588de44dbb8577aff5ad930fa6aa7e29e935e50
|
4
|
+
data.tar.gz: 1a79f24f284ede18d9aea34702fe7bff5f70064c8dd6d8a372e8bd9ec4f5d266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fb3a664bd96a0263ed6a155b385a634efcb26e157a1e8d7592da3f3baa1a4ed6d717bead553169d1fd6e540a35f1847925195e07ede281e6d845e6f649cd537
|
7
|
+
data.tar.gz: c9d1fd1cc89b68ffea4b5b6090ae2ed1de25e75442923a2dc9b16fda0bdfbdb7470d8ada71657d06ad8db1c64c41acacf1e1235891c794c146b3e16758978cff
|
data/.github/workflows/ruby.yml
CHANGED
@@ -15,64 +15,21 @@ jobs:
|
|
15
15
|
fail-fast: false
|
16
16
|
matrix:
|
17
17
|
ruby:
|
18
|
-
- "2.7"
|
19
18
|
- "3.0"
|
20
19
|
- "3.1"
|
21
20
|
- "3.2"
|
22
21
|
- "3.3"
|
23
22
|
|
24
23
|
gemfile:
|
25
|
-
- "rails_6_1"
|
26
24
|
- "rails_7_0"
|
27
25
|
- "rails_7_1"
|
28
26
|
- "rails_head"
|
29
27
|
|
30
28
|
exclude:
|
31
|
-
- ruby: 2.7
|
32
|
-
gemfile: rails_head
|
33
29
|
- ruby: '3.0'
|
34
30
|
gemfile: rails_head
|
35
31
|
|
36
32
|
include:
|
37
|
-
- ruby: 2.2
|
38
|
-
gemfile: rails_5_0
|
39
|
-
- ruby: 2.2
|
40
|
-
gemfile: rails_5_1
|
41
|
-
- ruby: 2.3
|
42
|
-
gemfile: rails_5_0
|
43
|
-
- ruby: 2.3
|
44
|
-
gemfile: rails_5_1
|
45
|
-
- ruby: 2.3
|
46
|
-
gemfile: rails_5_2
|
47
|
-
- ruby: 2.4
|
48
|
-
gemfile: rails_5_0
|
49
|
-
- ruby: 2.4
|
50
|
-
gemfile: rails_5_1
|
51
|
-
- ruby: 2.4
|
52
|
-
gemfile: rails_5_2
|
53
|
-
- ruby: 2.5
|
54
|
-
gemfile: rails_5_0
|
55
|
-
- ruby: 2.5
|
56
|
-
gemfile: rails_5_1
|
57
|
-
- ruby: 2.5
|
58
|
-
gemfile: rails_5_2
|
59
|
-
- ruby: 2.5
|
60
|
-
gemfile: rails_6_0
|
61
|
-
- ruby: 2.5
|
62
|
-
gemfile: rails_6_1
|
63
|
-
- ruby: 2.6
|
64
|
-
gemfile: rails_5_0
|
65
|
-
- ruby: 2.6
|
66
|
-
gemfile: rails_5_1
|
67
|
-
- ruby: 2.6
|
68
|
-
gemfile: rails_5_2
|
69
|
-
- ruby: 2.6
|
70
|
-
gemfile: rails_6_0
|
71
|
-
- ruby: 2.6
|
72
|
-
gemfile: rails_6_1
|
73
|
-
- ruby: 2.7
|
74
|
-
gemfile: rails_6_0
|
75
|
-
|
76
33
|
- ruby: '3.1'
|
77
34
|
gemfile: rails_head
|
78
35
|
- ruby: '3.2'
|
data/Appraisals
CHANGED
@@ -1,30 +1,3 @@
|
|
1
|
-
if RUBY_VERSION < "2.7.0"
|
2
|
-
appraise "rails-5-0" do
|
3
|
-
gem "rails", "~> 5.0.0"
|
4
|
-
gem "loofah", "< 2.21.0"
|
5
|
-
end
|
6
|
-
|
7
|
-
appraise "rails-5-1" do
|
8
|
-
gem "rails", "~> 5.1.0"
|
9
|
-
gem "loofah", "< 2.21.0"
|
10
|
-
end
|
11
|
-
|
12
|
-
appraise "rails-5-2" do
|
13
|
-
gem "rails", "~> 5.2.0"
|
14
|
-
gem "loofah", "< 2.21.0"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
if RUBY_VERSION >= "2.5.0"
|
19
|
-
appraise "rails-6-0" do
|
20
|
-
gem "rails", "~> 6.0.0"
|
21
|
-
end
|
22
|
-
|
23
|
-
appraise "rails-6-1" do
|
24
|
-
gem "rails", "~> 6.1.0"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
1
|
if RUBY_VERSION >= "2.7.0"
|
29
2
|
appraise "rails-7-0" do
|
30
3
|
gem "rails", "~> 7.0.0"
|
data/CONTRIBUTING.md
CHANGED
@@ -33,13 +33,7 @@ git checkout -b my-feature-branch
|
|
33
33
|
|
34
34
|
#### Bundle Install and Test
|
35
35
|
|
36
|
-
Ensure that you can build the project and run tests
|
37
|
-
|
38
|
-
```
|
39
|
-
bundle install
|
40
|
-
appraisal install
|
41
|
-
appraisal rake test
|
42
|
-
```
|
36
|
+
Ensure that you can build the project and run tests using `bin/test`.
|
43
37
|
|
44
38
|
#### Write Tests
|
45
39
|
|
data/bin/release
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
VERSION=$1
|
4
|
+
|
5
|
+
printf "class Jbuilder\n VERSION = \"$VERSION\"\nend\n" > ./lib/jbuilder/version.rb
|
6
|
+
bundle
|
7
|
+
git add lib/jbuilder/version.rb
|
8
|
+
git commit -m "Bump version for $VERSION"
|
9
|
+
git push
|
10
|
+
git tag v$VERSION
|
11
|
+
git push --tags
|
12
|
+
gem build jbuilder.gemspec
|
13
|
+
gem push "jbuilder-$VERSION.gem" --host https://rubygems.org
|
14
|
+
rm "jbuilder-$VERSION.gem"
|
data/bin/test
ADDED
data/jbuilder.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
require_relative "lib/jbuilder/version"
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'jbuilder'
|
3
|
-
s.version =
|
5
|
+
s.version = Jbuilder::VERSION
|
4
6
|
s.authors = 'David Heinemeier Hansson'
|
5
7
|
s.email = 'david@basecamp.com'
|
6
8
|
s.summary = 'Create JSON structures via a Builder-style DSL'
|
@@ -48,13 +48,19 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
48
48
|
private
|
49
49
|
# Use callbacks to share common setup or constraints between actions.
|
50
50
|
def set_<%= singular_table_name %>
|
51
|
+
<%- if Rails::VERSION::MAJOR >= 8 -%>
|
52
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params.expect(:id)") %>
|
53
|
+
<%- else -%>
|
51
54
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
55
|
+
<%- end -%>
|
52
56
|
end
|
53
57
|
|
54
58
|
# Only allow a list of trusted parameters through.
|
55
59
|
def <%= "#{singular_table_name}_params" %>
|
56
60
|
<%- if attributes_names.empty? -%>
|
57
61
|
params.fetch(<%= ":#{singular_table_name}" %>, {})
|
62
|
+
<%- elsif Rails::VERSION::MAJOR >= 8 -%>
|
63
|
+
params.expect(<%= singular_table_name %>: [ <%= permitted_params %> ])
|
58
64
|
<%- else -%>
|
59
65
|
params.require(<%= ":#{singular_table_name}" %>).permit(<%= permitted_params %>)
|
60
66
|
<%- end -%>
|
@@ -30,7 +30,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
30
30
|
|
31
31
|
respond_to do |format|
|
32
32
|
if @<%= orm_instance.save %>
|
33
|
-
format.html { redirect_to <%=
|
33
|
+
format.html { redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully created.") %> }
|
34
34
|
format.json { render :show, status: :created, location: <%= "@#{singular_table_name}" %> }
|
35
35
|
else
|
36
36
|
format.html { render :new, status: :unprocessable_entity }
|
@@ -43,7 +43,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
43
43
|
def update
|
44
44
|
respond_to do |format|
|
45
45
|
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
46
|
-
format.html { redirect_to <%=
|
46
|
+
format.html { redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %> }
|
47
47
|
format.json { render :show, status: :ok, location: <%= "@#{singular_table_name}" %> }
|
48
48
|
else
|
49
49
|
format.html { render :edit, status: :unprocessable_entity }
|
@@ -57,7 +57,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
57
57
|
@<%= orm_instance.destroy %>
|
58
58
|
|
59
59
|
respond_to do |format|
|
60
|
-
format.html { redirect_to <%= index_helper %>
|
60
|
+
format.html { redirect_to <%= index_helper %>_path, status: :see_other, notice: <%= %("#{human_name} was successfully destroyed.") %> }
|
61
61
|
format.json { head :no_content }
|
62
62
|
end
|
63
63
|
end
|
@@ -65,13 +65,19 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
65
65
|
private
|
66
66
|
# Use callbacks to share common setup or constraints between actions.
|
67
67
|
def set_<%= singular_table_name %>
|
68
|
+
<%- if Rails::VERSION::MAJOR >= 8 -%>
|
69
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params.expect(:id)") %>
|
70
|
+
<%- else -%>
|
68
71
|
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
72
|
+
<%- end -%>
|
69
73
|
end
|
70
74
|
|
71
75
|
# Only allow a list of trusted parameters through.
|
72
76
|
def <%= "#{singular_table_name}_params" %>
|
73
77
|
<%- if attributes_names.empty? -%>
|
74
78
|
params.fetch(<%= ":#{singular_table_name}" %>, {})
|
79
|
+
<%- elsif Rails::VERSION::MAJOR >= 8 -%>
|
80
|
+
params.expect(<%= singular_table_name %>: [ <%= permitted_params %> ])
|
75
81
|
<%- else -%>
|
76
82
|
params.require(<%= ":#{singular_table_name}" %>).permit(<%= permitted_params %>)
|
77
83
|
<%- end -%>
|
@@ -155,21 +155,30 @@ class JbuilderTemplate < Jbuilder
|
|
155
155
|
::Kernel.raise ::NotImplementedError, "The `:spacer_template' option is not supported in collection rendering."
|
156
156
|
end
|
157
157
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
158
|
+
if collection.present?
|
159
|
+
results = CollectionRenderer
|
160
|
+
.new(@context.lookup_context, options) { |&block| _scope(&block) }
|
161
|
+
.render_collection_with_partial(collection, partial, @context, nil)
|
162
|
+
|
163
|
+
array! if results.respond_to?(:body) && results.body.nil?
|
164
|
+
else
|
165
|
+
array!
|
166
|
+
end
|
163
167
|
elsif as && options.key?(:collection) && !CollectionRenderer.supported?
|
164
168
|
# For Rails <= 5.2:
|
165
169
|
as = as.to_sym
|
166
170
|
collection = options.delete(:collection)
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
|
172
|
+
if collection.present?
|
173
|
+
locals = options.delete(:locals)
|
174
|
+
array! collection do |member|
|
175
|
+
member_locals = locals.clone
|
176
|
+
member_locals.merge! collection: collection
|
177
|
+
member_locals.merge! as => member
|
178
|
+
_render_partial options.merge(locals: member_locals)
|
179
|
+
end
|
180
|
+
else
|
181
|
+
array!
|
173
182
|
end
|
174
183
|
else
|
175
184
|
_render_partial options
|
data/lib/jbuilder.rb
CHANGED
@@ -3,12 +3,9 @@ require 'jbuilder/jbuilder'
|
|
3
3
|
require 'jbuilder/blank'
|
4
4
|
require 'jbuilder/key_formatter'
|
5
5
|
require 'jbuilder/errors'
|
6
|
+
require 'jbuilder/version'
|
6
7
|
require 'json'
|
7
8
|
require 'active_support/core_ext/hash/deep_merge'
|
8
|
-
begin
|
9
|
-
require 'ostruct'
|
10
|
-
rescue LoadError
|
11
|
-
end
|
12
9
|
|
13
10
|
class Jbuilder
|
14
11
|
@@key_formatter = nil
|
@@ -31,7 +28,6 @@ class Jbuilder
|
|
31
28
|
end
|
32
29
|
|
33
30
|
BLANK = Blank.new
|
34
|
-
NON_ENUMERABLES = defined?(::OpenStruct) ? [::Struct, ::OpenStruct].to_set : [::Struct].to_set
|
35
31
|
|
36
32
|
def set!(key, value = BLANK, *args, &block)
|
37
33
|
result = if ::Kernel.block_given?
|
@@ -354,7 +350,7 @@ class Jbuilder
|
|
354
350
|
end
|
355
351
|
|
356
352
|
def _is_collection?(object)
|
357
|
-
_object_respond_to?(object, :map, :count) &&
|
353
|
+
_object_respond_to?(object, :map, :count) && !(::Struct === object)
|
358
354
|
end
|
359
355
|
|
360
356
|
def _blank?(value=@attributes)
|
@@ -98,10 +98,12 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
|
|
98
98
|
end
|
99
99
|
|
100
100
|
test "nil partial collection by name" do
|
101
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
101
102
|
assert_equal [], render('json.partial! "post", collection: @posts, as: :post', posts: nil)
|
102
103
|
end
|
103
104
|
|
104
105
|
test "nil partial collection by options" do
|
106
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
105
107
|
assert_equal [], render('json.partial! partial: "post", collection: @posts, as: :post', posts: nil)
|
106
108
|
end
|
107
109
|
|
@@ -113,7 +115,13 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
|
|
113
115
|
assert_equal "Pavel", result[5]["author"]["first_name"]
|
114
116
|
end
|
115
117
|
|
118
|
+
test "empty array of partials from empty collection" do
|
119
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
120
|
+
assert_equal [], render('json.array! @posts, partial: "post", as: :post', posts: [])
|
121
|
+
end
|
122
|
+
|
116
123
|
test "empty array of partials from nil collection" do
|
124
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
117
125
|
assert_equal [], render('json.array! @posts, partial: "post", as: :post', posts: nil)
|
118
126
|
end
|
119
127
|
|
@@ -126,10 +134,17 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
|
|
126
134
|
end
|
127
135
|
|
128
136
|
test "empty array of partials under key from nil collection" do
|
137
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
129
138
|
result = render('json.posts @posts, partial: "post", as: :post', posts: nil)
|
130
139
|
assert_equal [], result["posts"]
|
131
140
|
end
|
132
141
|
|
142
|
+
test "empty array of partials under key from an empy collection" do
|
143
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
144
|
+
result = render('json.posts @posts, partial: "post", as: :post', posts: [])
|
145
|
+
assert_equal [], result["posts"]
|
146
|
+
end
|
147
|
+
|
133
148
|
test "object fragment caching" do
|
134
149
|
render(<<-JBUILDER)
|
135
150
|
json.cache! "cache-key" do
|
@@ -293,6 +308,7 @@ class JbuilderTemplateTest < ActiveSupport::TestCase
|
|
293
308
|
|
294
309
|
if JbuilderTemplate::CollectionRenderer.supported?
|
295
310
|
test "returns an empty array for an empty collection" do
|
311
|
+
Jbuilder::CollectionRenderer.expects(:new).never
|
296
312
|
result = render('json.array! @posts, partial: "post", as: :post, cached: true', posts: [])
|
297
313
|
|
298
314
|
# Do not use #assert_empty as it is important to ensure that the type of the JSON result is an array.
|
@@ -38,8 +38,17 @@ if Rails::VERSION::MAJOR > 4
|
|
38
38
|
assert_match %r{@post\.destroy}, m
|
39
39
|
end
|
40
40
|
|
41
|
+
assert_match %r{def set_post}, content
|
42
|
+
if Rails::VERSION::MAJOR >= 8
|
43
|
+
assert_match %r{params\.expect\(:id\)}, content
|
44
|
+
else
|
45
|
+
assert_match %r{params\[:id\]}, content
|
46
|
+
end
|
47
|
+
|
41
48
|
assert_match %r{def post_params}, content
|
42
|
-
if Rails::VERSION::MAJOR >=
|
49
|
+
if Rails::VERSION::MAJOR >= 8
|
50
|
+
assert_match %r{params\.expect\(post: \[ :title, :body, images: \[\] \]\)}, content
|
51
|
+
elsif Rails::VERSION::MAJOR >= 6
|
43
52
|
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
44
53
|
else
|
45
54
|
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, :images\)}, content
|
@@ -62,7 +71,11 @@ if Rails::VERSION::MAJOR > 4
|
|
62
71
|
run_generator ["Message", "content:rich_text", "video:attachment", "photos:attachments"]
|
63
72
|
|
64
73
|
assert_file 'app/controllers/messages_controller.rb' do |content|
|
65
|
-
|
74
|
+
if Rails::VERSION::MAJOR >= 8
|
75
|
+
assert_match %r{params\.expect\(message: \[ :content, :video, photos: \[\] \]\)}, content
|
76
|
+
else
|
77
|
+
assert_match %r{params\.require\(:message\)\.permit\(:content, :video, photos: \[\]\)}, content
|
78
|
+
end
|
66
79
|
end
|
67
80
|
end
|
68
81
|
end
|
@@ -31,14 +31,14 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
31
31
|
assert_instance_method :create, content do |m|
|
32
32
|
assert_match %r{@post = Post\.new\(post_params\)}, m
|
33
33
|
assert_match %r{@post\.save}, m
|
34
|
-
assert_match %r{format\.html \{ redirect_to
|
34
|
+
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully created\." \}}, m
|
35
35
|
assert_match %r{format\.json \{ render :show, status: :created, location: @post \}}, m
|
36
36
|
assert_match %r{format\.html \{ render :new, status: :unprocessable_entity \}}, m
|
37
37
|
assert_match %r{format\.json \{ render json: @post\.errors, status: :unprocessable_entity \}}, m
|
38
38
|
end
|
39
39
|
|
40
40
|
assert_instance_method :update, content do |m|
|
41
|
-
assert_match %r{format\.html \{ redirect_to
|
41
|
+
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully updated\." \}}, m
|
42
42
|
assert_match %r{format\.json \{ render :show, status: :ok, location: @post \}}, m
|
43
43
|
assert_match %r{format\.html \{ render :edit, status: :unprocessable_entity \}}, m
|
44
44
|
assert_match %r{format\.json \{ render json: @post.errors, status: :unprocessable_entity \}}, m
|
@@ -46,12 +46,21 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
46
46
|
|
47
47
|
assert_instance_method :destroy, content do |m|
|
48
48
|
assert_match %r{@post\.destroy}, m
|
49
|
-
assert_match %r{format\.html \{ redirect_to
|
49
|
+
assert_match %r{format\.html \{ redirect_to posts_path, status: :see_other, notice: "Post was successfully destroyed\." \}}, m
|
50
50
|
assert_match %r{format\.json \{ head :no_content \}}, m
|
51
51
|
end
|
52
52
|
|
53
|
+
assert_match %r{def set_post}, content
|
54
|
+
if Rails::VERSION::MAJOR >= 8
|
55
|
+
assert_match %r{params\.expect\(:id\)}, content
|
56
|
+
else
|
57
|
+
assert_match %r{params\[:id\]}, content
|
58
|
+
end
|
59
|
+
|
53
60
|
assert_match %r{def post_params}, content
|
54
|
-
if Rails::VERSION::MAJOR >=
|
61
|
+
if Rails::VERSION::MAJOR >= 8
|
62
|
+
assert_match %r{params\.expect\(post: \[ :title, :body, images: \[\] \]\)}, content
|
63
|
+
elsif Rails::VERSION::MAJOR >= 6
|
55
64
|
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
56
65
|
else
|
57
66
|
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, :images\)}, content
|
@@ -64,15 +73,15 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
64
73
|
run_generator %w(Admin::Post --model-name=Post)
|
65
74
|
assert_file 'app/controllers/admin/posts_controller.rb' do |content|
|
66
75
|
assert_instance_method :create, content do |m|
|
67
|
-
assert_match %r{format\.html \{ redirect_to
|
76
|
+
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully created\." \}}, m
|
68
77
|
end
|
69
78
|
|
70
79
|
assert_instance_method :update, content do |m|
|
71
|
-
assert_match %r{format\.html \{ redirect_to
|
80
|
+
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully updated\." \}}, m
|
72
81
|
end
|
73
82
|
|
74
83
|
assert_instance_method :destroy, content do |m|
|
75
|
-
assert_match %r{format\.html \{ redirect_to
|
84
|
+
assert_match %r{format\.html \{ redirect_to admin_posts_path, status: :see_other, notice: "Post was successfully destroyed\." \}}, m
|
76
85
|
end
|
77
86
|
end
|
78
87
|
end
|
@@ -92,7 +101,11 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
92
101
|
run_generator %w(Message content:rich_text video:attachment photos:attachments)
|
93
102
|
|
94
103
|
assert_file 'app/controllers/messages_controller.rb' do |content|
|
95
|
-
|
104
|
+
if Rails::VERSION::MAJOR >= 8
|
105
|
+
assert_match %r{params\.expect\(message: \[ :content, :video, photos: \[\] \]\)}, content
|
106
|
+
else
|
107
|
+
assert_match %r{params\.require\(:message\)\.permit\(:content, :video, photos: \[\]\)}, content
|
108
|
+
end
|
96
109
|
end
|
97
110
|
end
|
98
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -52,11 +52,8 @@ files:
|
|
52
52
|
- MIT-LICENSE
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
|
-
-
|
56
|
-
-
|
57
|
-
- gemfiles/rails_5_2.gemfile
|
58
|
-
- gemfiles/rails_6_0.gemfile
|
59
|
-
- gemfiles/rails_6_1.gemfile
|
55
|
+
- bin/release
|
56
|
+
- bin/test
|
60
57
|
- gemfiles/rails_7_0.gemfile
|
61
58
|
- gemfiles/rails_7_1.gemfile
|
62
59
|
- gemfiles/rails_head.gemfile
|
@@ -77,6 +74,7 @@ files:
|
|
77
74
|
- lib/jbuilder/jbuilder_template.rb
|
78
75
|
- lib/jbuilder/key_formatter.rb
|
79
76
|
- lib/jbuilder/railtie.rb
|
77
|
+
- lib/jbuilder/version.rb
|
80
78
|
- test/jbuilder_dependency_tracker_test.rb
|
81
79
|
- test/jbuilder_generator_test.rb
|
82
80
|
- test/jbuilder_template_test.rb
|
@@ -89,9 +87,9 @@ licenses:
|
|
89
87
|
- MIT
|
90
88
|
metadata:
|
91
89
|
bug_tracker_uri: https://github.com/rails/jbuilder/issues
|
92
|
-
changelog_uri: https://github.com/rails/jbuilder/releases/tag/v2.
|
90
|
+
changelog_uri: https://github.com/rails/jbuilder/releases/tag/v2.13.0
|
93
91
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
94
|
-
source_code_uri: https://github.com/rails/jbuilder/tree/v2.
|
92
|
+
source_code_uri: https://github.com/rails/jbuilder/tree/v2.13.0
|
95
93
|
rubygems_mfa_required: 'true'
|
96
94
|
post_install_message:
|
97
95
|
rdoc_options: []
|
@@ -108,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
106
|
- !ruby/object:Gem::Version
|
109
107
|
version: '0'
|
110
108
|
requirements: []
|
111
|
-
rubygems_version: 3.5.
|
109
|
+
rubygems_version: 3.5.16
|
112
110
|
signing_key:
|
113
111
|
specification_version: 4
|
114
112
|
summary: Create JSON structures via a Builder-style DSL
|
data/gemfiles/rails_5_0.gemfile
DELETED
data/gemfiles/rails_5_1.gemfile
DELETED
data/gemfiles/rails_5_2.gemfile
DELETED
data/gemfiles/rails_6_0.gemfile
DELETED