-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the dummy app uses the same template as real apps.
- Loading branch information
Showing
11 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,3 +98,6 @@ Gemfile.lock | |
|
||
# rspec failures | ||
.rspec_failures | ||
|
||
db/ | ||
config/initializers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Check that Rails application configuration is consistent with what we expect. | ||
require 'pathname' | ||
|
||
module Refinery | ||
module Core | ||
class EnvironmentChecker | ||
|
||
def initialize(root_path, environments: %w(development test production)) | ||
@root_path = Pathname.new(root_path) | ||
@environments = environments | ||
end | ||
|
||
def call | ||
environment_files.each do |env_file| | ||
# Refinery does not necessarily expect action_mailer to be available as | ||
# we may not always require it (currently only the authentication extension). | ||
# Rails, however, will optimistically place config entries for action_mailer. | ||
current_mailer_config = mailer_config(env_file) | ||
|
||
if current_mailer_config.present? | ||
new_mailer_config = [ | ||
" if config.respond_to?(:action_mailer)", | ||
current_mailer_config.gsub(%r{\A\n+?}, ''). # remove extraneous newlines at the start | ||
gsub(%r{^\ \ }) { |line| " #{line}" }, # add indentation on each line | ||
" end" | ||
].join("\n") | ||
|
||
env_file.write( | ||
env_file.read.gsub(current_mailer_config, new_mailer_config) | ||
) | ||
end | ||
|
||
env_file.write( | ||
env_file.read.gsub("assets.compile = false", "assets.compile = true") | ||
) | ||
end | ||
end | ||
|
||
private | ||
attr_reader :environments, :root_path | ||
|
||
def environment_files | ||
environments.map { |env| root_path.join("config", "environments", "#{env}.rb") } | ||
.select(&:file?) | ||
end | ||
|
||
def mailer_config(environment_file) | ||
root_path.join(environment_file).read.match( | ||
%r{^\s.+?config\.action_mailer\..+([\w\W]*\})?} | ||
).to_a.flatten.first | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ def change | |
t.string :image_uid | ||
t.string :image_ext | ||
|
||
t.timestamps | ||
t.timestamps null: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ def change | |
t.string :file_uid | ||
t.string :file_ext | ||
|
||
t.timestamps | ||
t.timestamps null: false | ||
end | ||
end | ||
end |
5 changes: 3 additions & 2 deletions
5
resources/lib/generators/refinery/resources/resources_generator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters