Skip to content

Commit

Permalink
Add appraisal for Rails 6 and fix failing Resolver (#248)
Browse files Browse the repository at this point in the history
* Adds appraisal for Rails 6 and fixes Resolver

* Add comments and fix old guard clause
  • Loading branch information
Johan Halse authored Sep 18, 2019
1 parent 67dc96c commit c34e91d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
4 changes: 4 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
appraise "rails-5" do
gem "rails", "~> 5.0"
end

appraise "rails-6" do
gem "rails", "~> 6.0"
end
4 changes: 2 additions & 2 deletions gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

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

gemspec :path => "../"
gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_6.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", "~> 6.0"

gemspec path: "../"
9 changes: 6 additions & 3 deletions godmin.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]

gem.add_dependency "bcrypt", [">= 3.0", "< 4.0"]
gem.add_dependency "bootstrap_form", "~> 2.4"
gem.add_dependency "bootstrap-sass", "~> 3.3"
gem.add_dependency "bootstrap_form", "~> 2.4"
gem.add_dependency "csv_builder", "~> 2.1"
gem.add_dependency "jquery-rails", [">= 4.0", "< 5.0"]
gem.add_dependency "momentjs-rails", "~> 2.8"
gem.add_dependency "pundit", [">= 1.1", "< 2.0"]
gem.add_dependency "rails", [">= 5.0", "< 6.0"]
gem.add_dependency "rails", [">= 5.0", "< 7.0"]
gem.add_dependency "sass-rails", [">= 5.0", "< 6.0"]
gem.add_dependency "selectize-rails", "~> 0.12"

gem.add_development_dependency "appraisal"
gem.add_development_dependency "bootsnap"
gem.add_development_dependency "byebug"
gem.add_development_dependency "capybara"
gem.add_development_dependency "minitest-reporters"
gem.add_development_dependency "minitest"
gem.add_development_dependency "minitest-reporters"
gem.add_development_dependency "poltergeist"
gem.add_development_dependency "pry"
gem.add_development_dependency "puma"
gem.add_development_dependency "sqlite3"
end
25 changes: 20 additions & 5 deletions lib/godmin/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,30 @@ def initialize(path, controller_path, engine_wrapper)
@engine_wrapper = engine_wrapper
end

# This function is for Rails 6 and up since the `find_templates` function
# is deprecated. It does the same thing, just a little differently. It's
# not being run by versions previous to Rails 6.
def _find_all(name, prefix, partial, details, key, locals)
templates = []

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

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

templates
end

# This is how we find templates in Rails 5 and below.
def find_templates(name, prefix, *args)
templates = []

template_paths(prefix).each do |path|
if templates.present?
break
else
templates = super(name, path, *args)
end
break if templates.present?

templates = super(name, path, *args)
end

templates
Expand Down

0 comments on commit c34e91d

Please sign in to comment.