Skip to content

Fix warnings and prevent Jbuilder::VERSION constant from being obliterated #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,19 @@ jobs:
gemfile:
- "rails_7_0"
- "rails_7_1"
- "rails_7_2"
- "rails_8_0"
- "rails_head"

exclude:
- ruby: '3.0'
gemfile: rails_7_2
- ruby: '3.0'
gemfile: rails_8_0
- ruby: '3.0'
gemfile: rails_head
- ruby: '3.1'
gemfile: rails_7_2
- ruby: '3.1'
gemfile: rails_8_0
- ruby: '3.1'
Expand Down
4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ appraise "rails-7-1" do
gem "rails", "~> 7.1.0"
end

appraise "rails-7-2" do
gem "rails", "~> 7.2.0"
end

appraise "rails-8-0" do
gem "rails", "~> 8.0.0"
end
Expand Down
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/env bash
#!/usr/bin/env bash
set -e

bundle install
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails_7_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rake"
gem "mocha", require: false
gem "appraisal"
gem "rails", "~> 7.2.0"

gemspec path: "../"
1 change: 0 additions & 1 deletion lib/jbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
require 'jbuilder/blank'
require 'jbuilder/key_formatter'
require 'jbuilder/errors'
require 'jbuilder/version'
require 'json'
require 'active_support/core_ext/hash/deep_merge'

Expand Down
2 changes: 1 addition & 1 deletion lib/jbuilder/errors.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require 'jbuilder/jbuilder'
require 'jbuilder/version'

class Jbuilder
class NullError < ::NoMethodError
Expand Down
2 changes: 1 addition & 1 deletion lib/jbuilder/jbuilder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

Jbuilder = Class.new(BasicObject)
require 'jbuilder/version'
2 changes: 1 addition & 1 deletion lib/jbuilder/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Jbuilder
class Jbuilder < BasicObject
VERSION = "2.13.0"
end
6 changes: 3 additions & 3 deletions test/scaffold_api_controller_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::ScaffoldControllerGenerator
arguments %w(Post title body:text images:attachments --api)
arguments %w(Post title body:text images:attachments --api --skip-routes)
destination File.expand_path('../tmp', __FILE__)
setup :prepare_destination

Expand Down Expand Up @@ -53,7 +53,7 @@ class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
end

test "don't use require and permit if there are no attributes" do
run_generator %w(Post --api)
run_generator %w(Post --api --skip-routes)

assert_file 'app/controllers/posts_controller.rb' do |content|
assert_match %r{def post_params}, content
Expand All @@ -62,7 +62,7 @@ class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
end

test 'handles virtual attributes' do
run_generator ["Message", "content:rich_text", "video:attachment", "photos:attachments"]
run_generator %w(Message content:rich_text video:attachment photos:attachments --skip-routes)

assert_file 'app/controllers/messages_controller.rb' do |content|
if Rails::VERSION::MAJOR >= 8
Expand Down
8 changes: 4 additions & 4 deletions test/scaffold_controller_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
tests Rails::Generators::ScaffoldControllerGenerator
arguments %w(Post title body:text images:attachments)
arguments %w(Post title body:text images:attachments --skip-routes)
destination File.expand_path('../tmp', __FILE__)
setup :prepare_destination

Expand Down Expand Up @@ -67,7 +67,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
end

test 'controller with namespace' do
run_generator %w(Admin::Post --model-name=Post)
run_generator %w(Admin::Post --model-name=Post --skip-routes)
assert_file 'app/controllers/admin/posts_controller.rb' do |content|
assert_instance_method :create, content do |m|
assert_match %r{format\.html \{ redirect_to \[:admin, @post\], notice: "Post was successfully created\." \}}, m
Expand All @@ -84,7 +84,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
end

test "don't use require and permit if there are no attributes" do
run_generator %w(Post)
run_generator %w(Post --skip-routes)

assert_file 'app/controllers/posts_controller.rb' do |content|
assert_match %r{def post_params}, content
Expand All @@ -93,7 +93,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
end

test 'handles virtual attributes' do
run_generator %w(Message content:rich_text video:attachment photos:attachments)
run_generator %w(Message content:rich_text video:attachment photos:attachments --skip-routes)

assert_file 'app/controllers/messages_controller.rb' do |content|
if Rails::VERSION::MAJOR >= 8
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ENV["RAILS_ENV"] ||= "test"

class << Rails
def cache
redefine_method :cache do
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
Expand Down