jbuilder 2.7.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +39 -45
- data/Appraisals +17 -11
- data/CHANGELOG.md +12 -0
- data/Gemfile +0 -1
- data/MIT-LICENSE +1 -1
- data/README.md +32 -16
- data/gemfiles/rails_4_2.gemfile +1 -4
- data/gemfiles/rails_5_0.gemfile +1 -4
- data/gemfiles/rails_5_1.gemfile +1 -4
- data/gemfiles/rails_5_2.gemfile +10 -0
- data/gemfiles/rails_head.gemfile +10 -0
- data/jbuilder.gemspec +1 -2
- data/lib/generators/rails/jbuilder_generator.rb +8 -2
- data/lib/generators/rails/scaffold_controller_generator.rb +6 -0
- data/lib/generators/rails/templates/api_controller.rb +1 -1
- data/lib/generators/rails/templates/controller.rb +1 -1
- data/lib/generators/rails/templates/index.json.jbuilder +1 -1
- data/lib/generators/rails/templates/partial.json.jbuilder +1 -1
- data/lib/jbuilder/jbuilder_template.rb +7 -6
- data/lib/jbuilder.rb +2 -2
- data/test/jbuilder_dependency_tracker_test.rb +1 -1
- data/test/jbuilder_generator_test.rb +13 -5
- data/test/jbuilder_template_test.rb +193 -338
- data/test/jbuilder_test.rb +2 -2
- data/test/scaffold_api_controller_generator_test.rb +6 -2
- data/test/scaffold_controller_generator_test.rb +6 -2
- data/test/test_helper.rb +25 -6
- metadata +5 -18
data/test/jbuilder_test.rb
CHANGED
@@ -49,7 +49,7 @@ end
|
|
49
49
|
|
50
50
|
|
51
51
|
class JbuilderTest < ActiveSupport::TestCase
|
52
|
-
|
52
|
+
teardown do
|
53
53
|
Jbuilder.send :class_variable_set, '@@key_formatter', nil
|
54
54
|
end
|
55
55
|
|
@@ -75,7 +75,7 @@ class JbuilderTest < ActiveSupport::TestCase
|
|
75
75
|
end
|
76
76
|
|
77
77
|
assert result.has_key?('content')
|
78
|
-
|
78
|
+
assert_nil result['content']
|
79
79
|
end
|
80
80
|
|
81
81
|
test 'multiple keys' do
|
@@ -6,7 +6,7 @@ if Rails::VERSION::MAJOR > 4
|
|
6
6
|
|
7
7
|
class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
|
8
8
|
tests Rails::Generators::ScaffoldControllerGenerator
|
9
|
-
arguments %w(Post title body:text --api)
|
9
|
+
arguments %w(Post title body:text images:attachments --api)
|
10
10
|
destination File.expand_path('../tmp', __FILE__)
|
11
11
|
setup :prepare_destination
|
12
12
|
|
@@ -39,7 +39,11 @@ if Rails::VERSION::MAJOR > 4
|
|
39
39
|
end
|
40
40
|
|
41
41
|
assert_match %r{def post_params}, content
|
42
|
-
|
42
|
+
if Rails::VERSION::MAJOR >= 6
|
43
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
44
|
+
else
|
45
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, :images\)}, content
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
@@ -4,7 +4,7 @@ require 'generators/rails/scaffold_controller_generator'
|
|
4
4
|
|
5
5
|
class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
6
6
|
tests Rails::Generators::ScaffoldControllerGenerator
|
7
|
-
arguments %w(Post title body:text)
|
7
|
+
arguments %w(Post title body:text images:attachments)
|
8
8
|
destination File.expand_path('../tmp', __FILE__)
|
9
9
|
setup :prepare_destination
|
10
10
|
|
@@ -51,7 +51,11 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
51
51
|
end
|
52
52
|
|
53
53
|
assert_match %r{def post_params}, content
|
54
|
-
|
54
|
+
if Rails::VERSION::MAJOR >= 6
|
55
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
56
|
+
else
|
57
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, :images\)}, content
|
58
|
+
end
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
data/test/test_helper.rb
CHANGED
@@ -1,14 +1,33 @@
|
|
1
1
|
require "bundler/setup"
|
2
|
+
|
2
3
|
require "active_support"
|
4
|
+
require "active_support/core_ext/array/access"
|
5
|
+
require "active_support/cache/memory_store"
|
6
|
+
require "active_model"
|
7
|
+
require "action_view"
|
3
8
|
require "rails/version"
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
10
|
+
require "jbuilder"
|
11
|
+
|
12
|
+
require "active_support/testing/autorun"
|
13
|
+
require "mocha/setup"
|
14
|
+
|
15
|
+
ActiveSupport.test_order = :random
|
16
|
+
|
17
|
+
class << Rails
|
18
|
+
def cache
|
19
|
+
@cache ||= ActiveSupport::Cache::MemoryStore.new
|
20
|
+
end
|
9
21
|
end
|
10
22
|
|
23
|
+
class Post < Struct.new(:id, :body, :author_name); end
|
11
24
|
|
12
|
-
|
13
|
-
|
25
|
+
class Racer < Struct.new(:id, :name)
|
26
|
+
extend ActiveModel::Naming
|
27
|
+
include ActiveModel::Conversion
|
14
28
|
end
|
29
|
+
|
30
|
+
ActionView::Template.register_template_handler :jbuilder, JbuilderHandler
|
31
|
+
|
32
|
+
ActionView::Base.remove_possible_method :fragment_name_with_digest
|
33
|
+
ActionView::Base.remove_possible_method :cache_fragment_name
|
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.9.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:
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.2.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: multi_json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.2'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.2'
|
41
27
|
description:
|
42
28
|
email: david@basecamp.com
|
43
29
|
executables: []
|
@@ -56,6 +42,8 @@ files:
|
|
56
42
|
- gemfiles/rails_4_2.gemfile
|
57
43
|
- gemfiles/rails_5_0.gemfile
|
58
44
|
- gemfiles/rails_5_1.gemfile
|
45
|
+
- gemfiles/rails_5_2.gemfile
|
46
|
+
- gemfiles/rails_head.gemfile
|
59
47
|
- jbuilder.gemspec
|
60
48
|
- lib/generators/rails/jbuilder_generator.rb
|
61
49
|
- lib/generators/rails/scaffold_controller_generator.rb
|
@@ -98,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
86
|
- !ruby/object:Gem::Version
|
99
87
|
version: '0'
|
100
88
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.6.11
|
89
|
+
rubygems_version: 3.0.3
|
103
90
|
signing_key:
|
104
91
|
specification_version: 4
|
105
92
|
summary: Create JSON structures via a Builder-style DSL
|