Skip to content
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

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ jobs:
gemfile:
- "rails_7_0"
- "rails_7_1"
- "rails_7_2"
- "rails_head"

exclude:
- ruby: '3.0'
gemfile: rails_7_2
- ruby: '3.0'
gemfile: rails_head

include:
- ruby: '3.1'
gemfile: rails_7_2
- ruby: '3.1'
gemfile: rails_head
- ruby: '3.2'
gemfile: rails_7_2
- ruby: '3.2'
gemfile: rails_head
- ruby: head
Expand Down
4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if RUBY_VERSION >= "2.7.0"
gem "rails", "~> 7.1.0"
end

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

appraise "rails-head" do
gem "rails", github: "rails/rails", branch: "main"
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 @@ -3,7 +3,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,4 +1,4 @@
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 +1 @@
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,3 +1,3 @@
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 @@ -6,7 +6,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 @@ -57,7 +57,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 @@ -68,7 +68,7 @@ class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase

if Rails::VERSION::MAJOR >= 6
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 @@ -70,7 +70,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase

if Rails::VERSION::MAJOR >= 6
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 @@ -88,7 +88,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 @@ -98,7 +98,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase

if Rails::VERSION::MAJOR >= 6
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