1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Hide assets, helper, css and js namespaces for api only apps

This commit is contained in:
Santiago Pastorino 2015-04-17 20:34:21 -03:00
parent 101df203eb
commit c19035299a
2 changed files with 20 additions and 0 deletions

View file

@ -65,6 +65,7 @@ module Rails
} }
def self.configure!(config) #:nodoc: def self.configure!(config) #:nodoc:
api_only! if config.api_only
no_color! unless config.colorize_logging no_color! unless config.colorize_logging
aliases.deep_merge! config.aliases aliases.deep_merge! config.aliases
options.deep_merge! config.options options.deep_merge! config.options
@ -102,6 +103,10 @@ module Rails
@fallbacks ||= {} @fallbacks ||= {}
end end
def self.api_only!
hide_namespaces "assets", "helper", "css", "js"
end
# Remove the color from output. # Remove the color from output.
def self.no_color! def self.no_color!
Thor::Base.shell = Thor::Shell::Basic Thor::Base.shell = Thor::Shell::Basic

View file

@ -125,5 +125,20 @@ module ApplicationTests
assert_equal expected, c.generators.options assert_equal expected, c.generators.options
end end
end end
test "api only generators hide assets, helper, js and css namespaces" do
add_to_config <<-RUBY
config.generators.api_only = true
RUBY
# Initialize the application
require "#{app_path}/config/environment"
Rails.application.load_generators
assert Rails::Generators.hidden_namespaces.include?("assets")
assert Rails::Generators.hidden_namespaces.include?("helper")
assert Rails::Generators.hidden_namespaces.include?("js")
assert Rails::Generators.hidden_namespaces.include?("css")
end
end end
end end