Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 2 commits into from

3 participants

@senny
Owner

The plugin new generator always adds the dummy app rake tasks,
when a dummy app was created.

Closes #8224

I had to backport the commit 00fbee5 also. Otherwise the error from #6251 would popup.

@dabit dabit Fixes issue #6251
Plugin generator crashes when using the --dummy-path option

Code was assuming the application name in `config/application.rb`
was module Dummy.
00fbee5
railties/CHANGELOG.md
@@ -8,7 +13,6 @@
*Rafael Mendonça França*
-
@rafaelfranca Owner

This line should be here

@senny Owner
senny added a note

I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@senny senny backport #8139, `plugin new` adds dummy app tasks when necessary. …
The `plugin new` generator always adds the dummy app rake tasks,
when a dummy app was created.

Closes #8224

Conflicts:

	railties/CHANGELOG.md
e69058c
@rafaelfranca rafaelfranca merged commit f2a98a9 into rails:3-2-stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 15, 2012
  1. @dabit @senny

    Fixes issue #6251

    dabit authored senny committed
    Plugin generator crashes when using the --dummy-path option
    
    Code was assuming the application name in `config/application.rb`
    was module Dummy.
  2. @senny

    backport #8139, `plugin new` adds dummy app tasks when necessary. …

    senny authored
    The `plugin new` generator always adds the dummy app rake tasks,
    when a dummy app was created.
    
    Closes #8224
    
    Conflicts:
    
    	railties/CHANGELOG.md
This page is out of date. Refresh to see the latest.
View
5 railties/CHANGELOG.md
@@ -1,5 +1,10 @@
## 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*
## Rails 3.2.8 (Aug 9, 2012) ##
View
8 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -204,7 +204,7 @@ def create_test_files
end
def create_test_dummy_files
- return if options[:skip_test_unit] && options[:dummy_path] == 'test/dummy'
+ return unless with_dummy_app?
create_dummy_app
end
@@ -242,6 +242,10 @@ def mountable?
options[:mountable]
end
+ def with_dummy_app?
+ options[:skip_test_unit].blank? || options[:dummy_path] != 'test/dummy'
+ end
+
def self.banner
"rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
end
@@ -282,7 +286,7 @@ def application_definition
dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root)
unless options[:pretend] || !File.exists?(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
View
2  railties/lib/rails/generators/rails/plugin_new/templates/Rakefile
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
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__)
load 'rails/tasks/engine.rake'
<% end %>
View
6 railties/test/generators/plugin_new_generator_test.rb
@@ -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")))
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
FileUtils.cd(Rails.root)
assert_no_match(/It works from file!.*It works_from_file/, run_generator([destination_root, "-m", "lib/template.rb"]))
Something went wrong with that request. Please try again.