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

backport #8139, plugin new adds dummy app tasks when necessary #8227

Merged
merged 2 commits into from
Nov 15, 2012
Merged
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
5 changes: 5 additions & 0 deletions railties/CHANGELOG.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,10 @@
## Rails 3.2.9 (Nov 12, 2012) ## ## Rails 3.2.9 (Nov 12, 2012) ##


* Add dummy app Rake tasks when --skip-test-unit and --dummy-path is passed to the plugin generator. [Backport #8139]
Fix #8121

*Yves Senn*

* Update supported ruby versions error message in ruby_version_check.rb *Lihan Li* * Update supported ruby versions error message in ruby_version_check.rb *Lihan Li*


## Rails 3.2.8 (Aug 9, 2012) ## ## Rails 3.2.8 (Aug 9, 2012) ##
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def create_test_files
end end


def create_test_dummy_files def create_test_dummy_files
return if options[:skip_test_unit] && options[:dummy_path] == 'test/dummy' return unless with_dummy_app?
create_dummy_app create_dummy_app
end end


Expand Down Expand Up @@ -242,6 +242,10 @@ def mountable?
options[:mountable] options[:mountable]
end end


def with_dummy_app?
options[:skip_test_unit].blank? || options[:dummy_path] != 'test/dummy'
end

def self.banner def self.banner
"rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]" "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
end end
Expand Down Expand Up @@ -282,7 +286,7 @@ def application_definition
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root) dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
unless options[:pretend] || !File.exists?(dummy_application_path) unless options[:pretend] || !File.exists?(dummy_application_path)
contents = File.read(dummy_application_path) contents = File.read(dummy_application_path)
contents[(contents.index("module Dummy"))..-1] contents[(contents.index(/module ([\w]+)\n(.*)class Application/m))..-1]
end end
end end
end end
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb')
end end


<% if full? && !options[:skip_active_record] && !options[:skip_test_unit] -%> <% if full? && !options[:skip_active_record] && with_dummy_app? -%>
APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__) APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
load 'rails/tasks/engine.rake' load 'rails/tasks/engine.rake'
<% end %> <% end %>
Expand Down
6 changes: 6 additions & 0 deletions railties/test/generators/plugin_new_generator_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def test_generating_test_files_in_full_mode_without_unit_test_files
assert_no_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile"))) assert_no_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile")))
end end


def test_generating_adds_dummy_app_rake_tasks_without_unit_test_files
run_generator [destination_root, "-T", "--mountable", '--dummy-path', 'my_dummy_app']

assert_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile")))
end

def test_ensure_that_plugin_options_are_not_passed_to_app_generator def test_ensure_that_plugin_options_are_not_passed_to_app_generator
FileUtils.cd(Rails.root) FileUtils.cd(Rails.root)
assert_no_match(/It works from file!.*It works_from_file/, run_generator([destination_root, "-m", "lib/template.rb"])) assert_no_match(/It works from file!.*It works_from_file/, run_generator([destination_root, "-m", "lib/template.rb"]))
Expand Down