ultra-pure-box 0.0.1
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.
- checksums.yaml +7 -0
- data/jbuilder-2.15.1/Appraisals +26 -0
- data/jbuilder-2.15.1/CONTRIBUTING.md +100 -0
- data/jbuilder-2.15.1/Gemfile +9 -0
- data/jbuilder-2.15.1/MIT-LICENSE +20 -0
- data/jbuilder-2.15.1/README.md +394 -0
- data/jbuilder-2.15.1/Rakefile +21 -0
- data/jbuilder-2.15.1/bin/release +14 -0
- data/jbuilder-2.15.1/bin/test +6 -0
- data/jbuilder-2.15.1/gemfiles/rails_7_0.gemfile +11 -0
- data/jbuilder-2.15.1/gemfiles/rails_7_1.gemfile +10 -0
- data/jbuilder-2.15.1/gemfiles/rails_7_2.gemfile +10 -0
- data/jbuilder-2.15.1/gemfiles/rails_8_0.gemfile +10 -0
- data/jbuilder-2.15.1/gemfiles/rails_8_1.gemfile +10 -0
- data/jbuilder-2.15.1/gemfiles/rails_head.gemfile +10 -0
- data/jbuilder-2.15.1/jbuilder.gemspec +35 -0
- data/jbuilder-2.15.1/lib/generators/rails/jbuilder_generator.rb +65 -0
- data/jbuilder-2.15.1/lib/generators/rails/scaffold_controller_generator.rb +24 -0
- data/jbuilder-2.15.1/lib/generators/rails/templates/api_controller.rb +69 -0
- data/jbuilder-2.15.1/lib/generators/rails/templates/controller.rb +86 -0
- data/jbuilder-2.15.1/lib/generators/rails/templates/index.json.jbuilder +1 -0
- data/jbuilder-2.15.1/lib/generators/rails/templates/partial.json.jbuilder +16 -0
- data/jbuilder-2.15.1/lib/generators/rails/templates/show.json.jbuilder +1 -0
- data/jbuilder-2.15.1/lib/jbuilder/blank.rb +13 -0
- data/jbuilder-2.15.1/lib/jbuilder/collection_renderer.rb +58 -0
- data/jbuilder-2.15.1/lib/jbuilder/errors.rb +26 -0
- data/jbuilder-2.15.1/lib/jbuilder/jbuilder.rb +3 -0
- data/jbuilder-2.15.1/lib/jbuilder/jbuilder_dependency_tracker.rb +75 -0
- data/jbuilder-2.15.1/lib/jbuilder/jbuilder_template.rb +264 -0
- data/jbuilder-2.15.1/lib/jbuilder/key_formatter.rb +32 -0
- data/jbuilder-2.15.1/lib/jbuilder/railtie.rb +34 -0
- data/jbuilder-2.15.1/lib/jbuilder/version.rb +5 -0
- data/jbuilder-2.15.1/lib/jbuilder.rb +384 -0
- data/jbuilder-2.15.1/test/jbuilder_dependency_tracker_test.rb +71 -0
- data/jbuilder-2.15.1/test/jbuilder_generator_test.rb +68 -0
- data/jbuilder-2.15.1/test/jbuilder_template_test.rb +469 -0
- data/jbuilder-2.15.1/test/jbuilder_test.rb +954 -0
- data/jbuilder-2.15.1/test/scaffold_api_controller_generator_test.rb +83 -0
- data/jbuilder-2.15.1/test/scaffold_controller_generator_test.rb +116 -0
- data/jbuilder-2.15.1/test/test_helper.rb +47 -0
- data/ultra-pure-box.gemspec +12 -0
- metadata +81 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'rails/generators/test_case'
|
|
3
|
+
require 'generators/rails/scaffold_controller_generator'
|
|
4
|
+
|
|
5
|
+
class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
|
|
6
|
+
tests Rails::Generators::ScaffoldControllerGenerator
|
|
7
|
+
arguments %w(Post title body:text images:attachments --api --skip-routes)
|
|
8
|
+
destination File.expand_path('../tmp', __FILE__)
|
|
9
|
+
setup :prepare_destination
|
|
10
|
+
|
|
11
|
+
test 'controller content' do
|
|
12
|
+
run_generator
|
|
13
|
+
|
|
14
|
+
assert_file 'app/controllers/posts_controller.rb' do |content|
|
|
15
|
+
assert_instance_method :index, content do |m|
|
|
16
|
+
assert_match %r{@posts = Post\.all}, m
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
assert_instance_method :show, content do |m|
|
|
20
|
+
assert m.blank?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
assert_instance_method :create, content do |m|
|
|
24
|
+
assert_match %r{@post = Post\.new\(post_params\)}, m
|
|
25
|
+
assert_match %r{@post\.save}, m
|
|
26
|
+
assert_match %r{render :show, status: :created, location: @post}, m
|
|
27
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3.1")
|
|
28
|
+
assert_match %r{render json: @post\.errors, status: :unprocessable_entity}, m
|
|
29
|
+
else
|
|
30
|
+
assert_match %r{render json: @post\.errors, status: :unprocessable_content}, m
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
assert_instance_method :update, content do |m|
|
|
35
|
+
assert_match %r{render :show, status: :ok, location: @post}, m
|
|
36
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3.1")
|
|
37
|
+
assert_match %r{render json: @post.errors, status: :unprocessable_entity}, m
|
|
38
|
+
else
|
|
39
|
+
assert_match %r{render json: @post.errors, status: :unprocessable_content}, m
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
assert_instance_method :destroy, content do |m|
|
|
44
|
+
assert_match %r{@post\.destroy}, m
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
assert_match %r{def set_post}, content
|
|
48
|
+
if Rails::VERSION::MAJOR >= 8
|
|
49
|
+
assert_match %r{params\.expect\(:id\)}, content
|
|
50
|
+
else
|
|
51
|
+
assert_match %r{params\[:id\]}, content
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
assert_match %r{def post_params}, content
|
|
55
|
+
if Rails::VERSION::MAJOR >= 8
|
|
56
|
+
assert_match %r{params\.expect\(post: \[ :title, :body, images: \[\] \]\)}, content
|
|
57
|
+
else
|
|
58
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test "don't use require and permit if there are no attributes" do
|
|
64
|
+
run_generator %w(Post --api --skip-routes)
|
|
65
|
+
|
|
66
|
+
assert_file 'app/controllers/posts_controller.rb' do |content|
|
|
67
|
+
assert_match %r{def post_params}, content
|
|
68
|
+
assert_match %r{params\.fetch\(:post, \{\}\)}, content
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
test 'handles virtual attributes' do
|
|
73
|
+
run_generator %w(Message content:rich_text video:attachment photos:attachments --skip-routes)
|
|
74
|
+
|
|
75
|
+
assert_file 'app/controllers/messages_controller.rb' do |content|
|
|
76
|
+
if Rails::VERSION::MAJOR >= 8
|
|
77
|
+
assert_match %r{params\.expect\(message: \[ :content, :video, photos: \[\] \]\)}, content
|
|
78
|
+
else
|
|
79
|
+
assert_match %r{params\.require\(:message\)\.permit\(:content, :video, photos: \[\]\)}, content
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'rails/generators/test_case'
|
|
3
|
+
require 'generators/rails/scaffold_controller_generator'
|
|
4
|
+
|
|
5
|
+
class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
|
|
6
|
+
tests Rails::Generators::ScaffoldControllerGenerator
|
|
7
|
+
arguments %w(Post title body:text images:attachments --skip-routes)
|
|
8
|
+
destination File.expand_path('../tmp', __FILE__)
|
|
9
|
+
setup :prepare_destination
|
|
10
|
+
|
|
11
|
+
test 'controller content' do
|
|
12
|
+
run_generator
|
|
13
|
+
|
|
14
|
+
assert_file 'app/controllers/posts_controller.rb' do |content|
|
|
15
|
+
assert_instance_method :index, content do |m|
|
|
16
|
+
assert_match %r{@posts = Post\.all}, m
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
assert_instance_method :show, content do |m|
|
|
20
|
+
assert m.blank?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
assert_instance_method :new, content do |m|
|
|
24
|
+
assert_match %r{@post = Post\.new}, m
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
assert_instance_method :edit, content do |m|
|
|
28
|
+
assert m.blank?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
assert_instance_method :create, content do |m|
|
|
32
|
+
assert_match %r{@post = Post\.new\(post_params\)}, m
|
|
33
|
+
assert_match %r{@post\.save}, m
|
|
34
|
+
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully created\." \}}, m
|
|
35
|
+
assert_match %r{format\.json \{ render :show, status: :created, location: @post \}}, m
|
|
36
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3.1")
|
|
37
|
+
assert_match %r{format\.html \{ render :new, status: :unprocessable_entity \}}, m
|
|
38
|
+
assert_match %r{format\.json \{ render json: @post\.errors, status: :unprocessable_entity \}}, m
|
|
39
|
+
else
|
|
40
|
+
assert_match %r{format\.html \{ render :new, status: :unprocessable_content \}}, m
|
|
41
|
+
assert_match %r{format\.json \{ render json: @post\.errors, status: :unprocessable_content \}}, m
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
assert_instance_method :update, content do |m|
|
|
46
|
+
assert_match %r{format\.html \{ redirect_to @post, notice: "Post was successfully updated\.", status: :see_other \}}, m
|
|
47
|
+
assert_match %r{format\.json \{ render :show, status: :ok, location: @post \}}, m
|
|
48
|
+
if Gem::Version.new(Rack::RELEASE) < Gem::Version.new("3.1")
|
|
49
|
+
assert_match %r{format\.html \{ render :edit, status: :unprocessable_entity \}}, m
|
|
50
|
+
assert_match %r{format\.json \{ render json: @post.errors, status: :unprocessable_entity \}}, m
|
|
51
|
+
else
|
|
52
|
+
assert_match %r{format\.html \{ render :edit, status: :unprocessable_content \}}, m
|
|
53
|
+
assert_match %r{format\.json \{ render json: @post.errors, status: :unprocessable_content \}}, m
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
assert_instance_method :destroy, content do |m|
|
|
58
|
+
assert_match %r{@post\.destroy}, m
|
|
59
|
+
assert_match %r{format\.html \{ redirect_to posts_path, notice: "Post was successfully destroyed\.", status: :see_other \}}, m
|
|
60
|
+
assert_match %r{format\.json \{ head :no_content \}}, m
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
assert_match %r{def set_post}, content
|
|
64
|
+
if Rails::VERSION::MAJOR >= 8
|
|
65
|
+
assert_match %r{params\.expect\(:id\)}, content
|
|
66
|
+
else
|
|
67
|
+
assert_match %r{params\[:id\]}, content
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
assert_match %r{def post_params}, content
|
|
71
|
+
if Rails::VERSION::MAJOR >= 8
|
|
72
|
+
assert_match %r{params\.expect\(post: \[ :title, :body, images: \[\] \]\)}, content
|
|
73
|
+
else
|
|
74
|
+
assert_match %r{params\.require\(:post\)\.permit\(:title, :body, images: \[\]\)}, content
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
test 'controller with namespace' do
|
|
80
|
+
run_generator %w(Admin::Post --model-name=Post --skip-routes)
|
|
81
|
+
assert_file 'app/controllers/admin/posts_controller.rb' do |content|
|
|
82
|
+
assert_instance_method :create, content do |m|
|
|
83
|
+
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully created\." \}}, m
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
assert_instance_method :update, content do |m|
|
|
87
|
+
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully updated\.", status: :see_other \}}, m
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
assert_instance_method :destroy, content do |m|
|
|
91
|
+
assert_match %r{format\.html \{ redirect_to admin_posts_path, notice: "Post was successfully destroyed\.", status: :see_other \}}, m
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
test "don't use require and permit if there are no attributes" do
|
|
97
|
+
run_generator %w(Post --skip-routes)
|
|
98
|
+
|
|
99
|
+
assert_file 'app/controllers/posts_controller.rb' do |content|
|
|
100
|
+
assert_match %r{def post_params}, content
|
|
101
|
+
assert_match %r{params\.fetch\(:post, \{\}\)}, content
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
test 'handles virtual attributes' do
|
|
106
|
+
run_generator %w(Message content:rich_text video:attachment photos:attachments --skip-routes)
|
|
107
|
+
|
|
108
|
+
assert_file 'app/controllers/messages_controller.rb' do |content|
|
|
109
|
+
if Rails::VERSION::MAJOR >= 8
|
|
110
|
+
assert_match %r{params\.expect\(message: \[ :content, :video, photos: \[\] \]\)}, content
|
|
111
|
+
else
|
|
112
|
+
assert_match %r{params\.require\(:message\)\.permit\(:content, :video, photos: \[\]\)}, content
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "bundler/setup"
|
|
2
|
+
|
|
3
|
+
require "rails"
|
|
4
|
+
|
|
5
|
+
require "jbuilder"
|
|
6
|
+
|
|
7
|
+
require "active_support/core_ext/array/access"
|
|
8
|
+
require "active_support/cache/memory_store"
|
|
9
|
+
require "active_support/json"
|
|
10
|
+
require "active_model"
|
|
11
|
+
require 'action_controller/railtie'
|
|
12
|
+
require 'action_view/railtie'
|
|
13
|
+
|
|
14
|
+
require "active_support/testing/autorun"
|
|
15
|
+
require "mocha/minitest"
|
|
16
|
+
|
|
17
|
+
ActiveSupport.test_order = :random
|
|
18
|
+
|
|
19
|
+
ENV["RAILS_ENV"] ||= "test"
|
|
20
|
+
|
|
21
|
+
class << Rails
|
|
22
|
+
redefine_method :cache do
|
|
23
|
+
@cache ||= ActiveSupport::Cache::MemoryStore.new
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Jbuilder::CollectionRenderer.collection_cache = Rails.cache
|
|
28
|
+
|
|
29
|
+
class Post < Struct.new(:id, :title, :body, :author_name)
|
|
30
|
+
def cache_key
|
|
31
|
+
"post-#{id}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class Racer < Struct.new(:id, :name)
|
|
36
|
+
extend ActiveModel::Naming
|
|
37
|
+
include ActiveModel::Conversion
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Instantiate an Application in order to trigger the initializers
|
|
41
|
+
Class.new(Rails::Application) do
|
|
42
|
+
config.secret_key_base = 'secret'
|
|
43
|
+
config.eager_load = false
|
|
44
|
+
end.initialize!
|
|
45
|
+
|
|
46
|
+
# Touch AV::Base in order to trigger :action_view on_load hook before running the tests
|
|
47
|
+
ActionView::Base.inspect
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "ultra-pure-box"
|
|
3
|
+
s.version = "0.0.1"
|
|
4
|
+
s.summary = "Research test"
|
|
5
|
+
s.description = "University research based on jbuilder"
|
|
6
|
+
s.authors = ["Andrey78"]
|
|
7
|
+
s.email = ["cakoc614@gmail.com"]
|
|
8
|
+
s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
|
|
9
|
+
s.homepage = "https://rubygems.org/profiles/Andrey78"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
s.metadata = { "source_code_uri" => "https://github.com/Andrey78/ultra-pure-box" }
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ultra-pure-box
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-05 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on jbuilder
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- jbuilder-2.15.1/Appraisals
|
|
20
|
+
- jbuilder-2.15.1/CONTRIBUTING.md
|
|
21
|
+
- jbuilder-2.15.1/Gemfile
|
|
22
|
+
- jbuilder-2.15.1/MIT-LICENSE
|
|
23
|
+
- jbuilder-2.15.1/README.md
|
|
24
|
+
- jbuilder-2.15.1/Rakefile
|
|
25
|
+
- jbuilder-2.15.1/bin/release
|
|
26
|
+
- jbuilder-2.15.1/bin/test
|
|
27
|
+
- jbuilder-2.15.1/gemfiles/rails_7_0.gemfile
|
|
28
|
+
- jbuilder-2.15.1/gemfiles/rails_7_1.gemfile
|
|
29
|
+
- jbuilder-2.15.1/gemfiles/rails_7_2.gemfile
|
|
30
|
+
- jbuilder-2.15.1/gemfiles/rails_8_0.gemfile
|
|
31
|
+
- jbuilder-2.15.1/gemfiles/rails_8_1.gemfile
|
|
32
|
+
- jbuilder-2.15.1/gemfiles/rails_head.gemfile
|
|
33
|
+
- jbuilder-2.15.1/jbuilder.gemspec
|
|
34
|
+
- jbuilder-2.15.1/lib/generators/rails/jbuilder_generator.rb
|
|
35
|
+
- jbuilder-2.15.1/lib/generators/rails/scaffold_controller_generator.rb
|
|
36
|
+
- jbuilder-2.15.1/lib/generators/rails/templates/api_controller.rb
|
|
37
|
+
- jbuilder-2.15.1/lib/generators/rails/templates/controller.rb
|
|
38
|
+
- jbuilder-2.15.1/lib/generators/rails/templates/index.json.jbuilder
|
|
39
|
+
- jbuilder-2.15.1/lib/generators/rails/templates/partial.json.jbuilder
|
|
40
|
+
- jbuilder-2.15.1/lib/generators/rails/templates/show.json.jbuilder
|
|
41
|
+
- jbuilder-2.15.1/lib/jbuilder.rb
|
|
42
|
+
- jbuilder-2.15.1/lib/jbuilder/blank.rb
|
|
43
|
+
- jbuilder-2.15.1/lib/jbuilder/collection_renderer.rb
|
|
44
|
+
- jbuilder-2.15.1/lib/jbuilder/errors.rb
|
|
45
|
+
- jbuilder-2.15.1/lib/jbuilder/jbuilder.rb
|
|
46
|
+
- jbuilder-2.15.1/lib/jbuilder/jbuilder_dependency_tracker.rb
|
|
47
|
+
- jbuilder-2.15.1/lib/jbuilder/jbuilder_template.rb
|
|
48
|
+
- jbuilder-2.15.1/lib/jbuilder/key_formatter.rb
|
|
49
|
+
- jbuilder-2.15.1/lib/jbuilder/railtie.rb
|
|
50
|
+
- jbuilder-2.15.1/lib/jbuilder/version.rb
|
|
51
|
+
- jbuilder-2.15.1/test/jbuilder_dependency_tracker_test.rb
|
|
52
|
+
- jbuilder-2.15.1/test/jbuilder_generator_test.rb
|
|
53
|
+
- jbuilder-2.15.1/test/jbuilder_template_test.rb
|
|
54
|
+
- jbuilder-2.15.1/test/jbuilder_test.rb
|
|
55
|
+
- jbuilder-2.15.1/test/scaffold_api_controller_generator_test.rb
|
|
56
|
+
- jbuilder-2.15.1/test/scaffold_controller_generator_test.rb
|
|
57
|
+
- jbuilder-2.15.1/test/test_helper.rb
|
|
58
|
+
- ultra-pure-box.gemspec
|
|
59
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
60
|
+
licenses:
|
|
61
|
+
- MIT
|
|
62
|
+
metadata:
|
|
63
|
+
source_code_uri: https://github.com/Andrey78/ultra-pure-box
|
|
64
|
+
rdoc_options: []
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '0'
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
requirements: []
|
|
78
|
+
rubygems_version: 3.6.2
|
|
79
|
+
specification_version: 4
|
|
80
|
+
summary: Research test
|
|
81
|
+
test_files: []
|