Skip to content

Commit

Permalink
Merge pull request #267 from varvet/rails-7
Browse files Browse the repository at this point in the history
Rails 7 support
  • Loading branch information
anderscarling authored May 4, 2022
2 parents d50776d + bd7ddc4 commit 116286c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ rvm:
gemfile:
- gemfiles/rails_5.gemfile
- gemfiles/rails_6.gemfile
- gemfiles/rails_7.gemfile

matrix:
exclude:
- rvm: 3.0.1
gemfile: gemfiles/rails_5.gemfile
- rvm: 3.1.1
gemfile: gemfiles/rails_5.gemfile
- rvm: 2.6.7
gemfile: gemfiles/rails_7.gemfile

addons:
code_climate:
Expand Down
8 changes: 8 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "admin", path: "../test/dummy/admin", group: [:test, :development]
gem "rails", "~> 7.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion godmin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "jquery-rails", [">= 4.0", "< 5.0"]
gem.add_dependency "momentjs-rails", "~> 2.8"
gem.add_dependency "pundit", [">= 2.2.0", "< 3.0"]
gem.add_dependency "rails", [">= 5.0", "< 7.0"]
gem.add_dependency "rails", [">= 5.0", "< 8.0"]
gem.add_dependency "sass-rails", [">= 5.0", "< 7.0"]
gem.add_dependency "selectize-rails", "~> 0.12"

Expand Down
5 changes: 2 additions & 3 deletions lib/godmin/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ def initialize(path, controller_path, engine_wrapper)
def _find_all(name, prefix, partial, details, key, locals)
templates = []

template_paths(prefix).each do |p|
template_paths(prefix).each do |template_path|
break if templates.present?

path = Path.build(name, "#{@path}/#{p}", partial)
templates = query(path, details, details[:formats], locals, cache: !!key)
templates = super(name, template_path, partial, details, key, locals)
end

templates
Expand Down
27 changes: 20 additions & 7 deletions test/generators/resource_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ class ResourceGeneratorTest < ::Rails::Generators::TestCase
setup :prepare_destination
teardown :prepare_destination

setup do
@__env_ci = ENV["CI"]
ENV.delete("CI")
end

teardown do
ENV["CI"] = @__env_ci if @__env_ci
end

def system!(cmd)
system(cmd) or fail("Failed to execute: #{cmd}")
end

def test_resource_generator_in_standalone_install
system "cd #{destination_root} && rails new . --skip-test --skip-spring --skip-bundle --skip-git --quiet"
system "cd #{destination_root} && bin/rails generate godmin:install --quiet"
system "cd #{destination_root} && bin/rails generate godmin:resource foo bar --quiet"
system! "cd #{destination_root} && rails new . --skip-test --skip-spring --skip-bundle --skip-git --quiet"
system! "cd #{destination_root} && bin/rails generate godmin:install --quiet"
system! "cd #{destination_root} && bin/rails generate godmin:resource foo bar --quiet"

assert_file "config/routes.rb", /resources :foos/
assert_file "app/views/shared/_navigation.html.erb", /<%= navbar_item Foo %>/
Expand Down Expand Up @@ -40,10 +53,10 @@ class FooService
end

def test_resource_generator_in_engine_install
system "cd #{destination_root} && rails new . --skip-test --skip-spring --skip-bundle --skip-git --quiet"
system "cd #{destination_root} && bin/rails plugin new fakemin --mountable --quiet"
system "cd #{destination_root} && fakemin/bin/rails generate godmin:install --quiet"
system "cd #{destination_root} && fakemin/bin/rails generate godmin:resource foo bar --quiet"
system! "cd #{destination_root} && rails new . --skip-test --skip-spring --skip-bundle --skip-git --quiet"
system! "cd #{destination_root} && bin/rails plugin new fakemin --mountable --quiet"
system! "cd #{destination_root} && fakemin/bin/rails generate godmin:install --quiet"
system! "cd #{destination_root} && fakemin/bin/rails generate godmin:resource foo bar --quiet"

assert_file "fakemin/config/routes.rb", /resources :foos/
assert_file "fakemin/app/views/fakemin/shared/_navigation.html.erb", /<%= navbar_item Foo %>/
Expand Down

0 comments on commit 116286c

Please sign in to comment.