aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml4
-rw-r--r--actionpack/test/controller/parameters/nested_parameters_permit_test.rb (renamed from actionpack/test/controller/parameters/nested_parameters_test.rb)2
-rw-r--r--actionview/lib/action_view/digestor.rb1
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb7
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb13
-rw-r--r--activerecord/lib/active_record/internal_metadata.rb13
-rw-r--r--activerecord/lib/active_record/result.rb8
-rw-r--r--activerecord/test/cases/migration_test.rb15
-rw-r--r--activerecord/test/cases/result_test.rb10
-rw-r--r--railties/CHANGELOG.md8
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb2
-rw-r--r--railties/lib/rails/commands/console.rb12
-rw-r--r--railties/lib/rails/generators/app_base.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb2
-rw-r--r--railties/lib/rails/source_annotation_extractor.rb6
-rw-r--r--railties/test/backtrace_cleaner_test.rb24
-rw-r--r--railties/test/generators/app_generator_test.rb87
-rw-r--r--railties/test/generators/plugin_generator_test.rb81
-rw-r--r--railties/test/generators/shared_generator_tests.rb35
20 files changed, 164 insertions, 170 deletions
diff --git a/.travis.yml b/.travis.yml
index 8528a095b2..f01b58ecb3 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,11 +16,7 @@ addons:
postgresql: "9.4"
bundler_args: --without test --jobs 3 --retry 3
-#FIXME: Remove bundler uninstall on Travis when https://github.com/bundler/bundler/issues/4493 is fixed.
before_install:
- - rvm @global do gem uninstall bundler --all --ignore-dependencies --executables
- - rvm @global do gem install bundler -v '1.11.2'
- - bundle --version
- "rm ${BUNDLE_GEMFILE}.lock"
- "[ -f /tmp/beanstalkd-1.10/Makefile ] || (curl -L https://github.com/kr/beanstalkd/archive/v1.10.tar.gz | tar xz -C /tmp)"
- "pushd /tmp/beanstalkd-1.10 && make && (./beanstalkd &); popd"
diff --git a/actionpack/test/controller/parameters/nested_parameters_test.rb b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
index 7151a8567c..5cf6f0d4e8 100644
--- a/actionpack/test/controller/parameters/nested_parameters_test.rb
+++ b/actionpack/test/controller/parameters/nested_parameters_permit_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
require 'action_controller/metal/strong_parameters'
-class NestedParametersTest < ActiveSupport::TestCase
+class NestedParametersPermitTest < ActiveSupport::TestCase
def assert_filtered_out(params, key)
assert !params.has_key?(key), "key #{key.inspect} has not been filtered out"
end
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index f3c29d663c..9c18ec56ca 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -12,7 +12,6 @@ module ActionView
# * <tt>name</tt> - Template name
# * <tt>finder</tt> - An instance of <tt>ActionView::LookupContext</tt>
# * <tt>dependencies</tt> - An array of dependent views
- # * <tt>partial</tt> - Specifies whether the template is a partial
def digest(name:, finder:, dependencies: [])
dependencies ||= []
cache_key = [ name, finder.rendered_format, dependencies ].flatten.compact.join('.')
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index c7881a6c6c..3e77b92141 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -460,7 +460,6 @@ module ActiveRecord
# it can be helpful to provide these in a migration's +change+ method so it can be reverted.
# In that case, +options+ and the block will be used by create_table.
def drop_table(table_name, options = {})
- create_table_info_cache.delete(table_name) if create_table_info_cache.key?(table_name)
execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
end
@@ -900,12 +899,8 @@ module ActiveRecord
end
end
- def create_table_info_cache # :nodoc:
- @create_table_info_cache ||= {}
- end
-
def create_table_info(table_name) # :nodoc:
- create_table_info_cache[table_name] ||= select_one("SHOW CREATE TABLE #{quote_table_name(table_name)}")["Create Table"]
+ select_one("SHOW CREATE TABLE #{quote_table_name(table_name)}")["Create Table"]
end
def create_table_definition(*args) # :nodoc:
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
index 13c9b6cbd9..87f0ff7d85 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
@@ -13,19 +13,6 @@ module ActiveRecord
result
end
- # Returns a record hash with the column names as keys and column values
- # as values.
- def select_one(arel, name = nil, binds = [])
- arel, binds = binds_from_relation(arel, binds)
- @connection.query_options.merge!(as: :hash)
- select_result(to_sql(arel, binds), name, binds) do |result|
- @connection.next_result while @connection.more_results?
- result.first
- end
- ensure
- @connection.query_options.merge!(as: :array)
- end
-
# Returns an array of arrays containing the field values.
# Order is the same as that returned by +columns+.
def select_rows(sql, name = nil, binds = [])
diff --git a/activerecord/lib/active_record/internal_metadata.rb b/activerecord/lib/active_record/internal_metadata.rb
index 17a5dc1d1b..8b649eab0f 100644
--- a/activerecord/lib/active_record/internal_metadata.rb
+++ b/activerecord/lib/active_record/internal_metadata.rb
@@ -14,10 +14,6 @@ module ActiveRecord
"#{table_name_prefix}#{ActiveRecord::Base.internal_metadata_table_name}#{table_name_suffix}"
end
- def original_table_name
- "#{table_name_prefix}active_record_internal_metadatas#{table_name_suffix}"
- end
-
def []=(key, value)
find_or_initialize_by(key: key).update_attributes!(value: value)
end
@@ -30,17 +26,8 @@ module ActiveRecord
ActiveSupport::Deprecation.silence { connection.table_exists?(table_name) }
end
- def original_table_exists?
- # This method will be removed in Rails 5.1
- # Since it is only necessary when `active_record_internal_metadatas` could exist
- ActiveSupport::Deprecation.silence { connection.table_exists?(original_table_name) }
- end
-
# Creates an internal metadata table with columns +key+ and +value+
def create_table
- if original_table_exists?
- connection.rename_table(original_table_name, table_name)
- end
unless table_exists?
key_options = connection.internal_string_options_for_primary_key
diff --git a/activerecord/lib/active_record/result.rb b/activerecord/lib/active_record/result.rb
index 8e6cd6c82f..b9fd0f5326 100644
--- a/activerecord/lib/active_record/result.rb
+++ b/activerecord/lib/active_record/result.rb
@@ -75,8 +75,14 @@ module ActiveRecord
hash_rows[idx]
end
+ def first
+ return nil if @rows.empty?
+ Hash[@columns.zip(@rows.first)]
+ end
+
def last
- hash_rows.last
+ return nil if @rows.empty?
+ Hash[@columns.zip(@rows.last)]
end
def cast_values(type_overrides = {}) # :nodoc:
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 36b6662820..d499aadbae 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -445,21 +445,6 @@ class MigrationTest < ActiveRecord::TestCase
ActiveRecord::Migrator.migrations_paths = old_path
end
- def test_rename_internal_metadata_table
- original_internal_metadata_table_name = ActiveRecord::Base.internal_metadata_table_name
-
- ActiveRecord::Base.internal_metadata_table_name = "active_record_internal_metadatas"
- Reminder.reset_table_name
-
- ActiveRecord::Base.internal_metadata_table_name = original_internal_metadata_table_name
- Reminder.reset_table_name
-
- assert_equal "ar_internal_metadata", ActiveRecord::InternalMetadata.table_name
- ensure
- ActiveRecord::Base.internal_metadata_table_name = original_internal_metadata_table_name
- Reminder.reset_table_name
- end
-
def test_proper_table_name_on_migration
reminder_class = new_isolated_reminder_class
migration = ActiveRecord::Migration.new
diff --git a/activerecord/test/cases/result_test.rb b/activerecord/test/cases/result_test.rb
index dec01dfa76..83dc5347e0 100644
--- a/activerecord/test/cases/result_test.rb
+++ b/activerecord/test/cases/result_test.rb
@@ -22,6 +22,16 @@ module ActiveRecord
], result.to_hash
end
+ test "first returns first row as a hash" do
+ assert_equal(
+ {'col_1' => 'row 1 col 1', 'col_2' => 'row 1 col 2'}, result.first)
+ end
+
+ test "last returns last row as a hash" do
+ assert_equal(
+ {'col_1' => 'row 3 col 1', 'col_2' => 'row 3 col 2'}, result.last)
+ end
+
test "each with block returns row hashes" do
result.each do |row|
assert_equal ['col_1', 'col_2'], row.keys
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 83fe6f56a4..243f40a057 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,3 +1,11 @@
+* Do not run `bundle install` when generating a new plugin.
+
+ Since bundler 1.12.0, the gemspec is validated so the `bundle install`
+ command will fail just after the gem is created causing confusion to the
+ users. This change was a bug fix to correctly validate gemspecs.
+
+ *Rafael Mendonça França*
+
* Default `config.assets.quiet = true` in the development environment. Suppress
logging of `sprockets-rails` requests by default.
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index 5276eb33c9..7b7036041e 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -2,7 +2,7 @@ require 'active_support/backtrace_cleaner'
module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
- APP_DIRS_PATTERN = /^\/?(app|config|lib|test)/
+ APP_DIRS_PATTERN = /^\/?(app|config|lib|test|\(\w*\))/
RENDER_TEMPLATE_PATTERN = /:in `_render_template_\w*'/
EMPTY_STRING = ''.freeze
SLASH = '/'.freeze
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb
index ea5d20ea24..a4ab31f793 100644
--- a/railties/lib/rails/commands/console.rb
+++ b/railties/lib/rails/commands/console.rb
@@ -7,6 +7,14 @@ module Rails
class Console
include ConsoleHelper
+ module BacktraceCleaner
+ def filter_backtrace(bt)
+ if result = super
+ Rails.backtrace_cleaner.filter([result]).first
+ end
+ end
+ end
+
class << self
def parse_arguments(arguments)
options = {}
@@ -34,6 +42,10 @@ module Rails
app.load_console
@console = app.config.console || IRB
+
+ if @console == IRB
+ IRB::WorkSpace.prepend(BacktraceCleaner)
+ end
end
def sandbox?
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 0835c09323..af3c6dead3 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -242,7 +242,7 @@ module Rails
] + dev_edge_common
elsif options.edge?
[
- GemfileEntry.github('rails', 'rails/rails')
+ GemfileEntry.github('rails', 'rails/rails', '5-0-stable')
] + dev_edge_common
else
[GemfileEntry.version('rails',
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index afa76aae44..2879be5fa2 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -229,7 +229,7 @@ module Rails
def display_upgrade_guide_info
say "\nAfter this, check Rails upgrade guide at http://guides.rubyonrails.org/upgrading_ruby_on_rails.html for more details about upgrading your app."
end
- remove_task :display_upgrade_info
+ remove_task :display_upgrade_guide_info
def create_boot_file
template "config/boot.rb"
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index 56efd35a95..7f427947f5 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -258,7 +258,7 @@ task default: :test
build(:leftovers)
end
- public_task :apply_rails_template, :run_bundle
+ public_task :apply_rails_template
def run_after_bundle_callbacks
@after_bundle_callbacks.each do |callback|
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb
index 8dd87b6cc5..ca195bd752 100644
--- a/railties/lib/rails/source_annotation_extractor.rb
+++ b/railties/lib/rails/source_annotation_extractor.rb
@@ -1,9 +1,9 @@
# Implements the logic behind the rake tasks for annotations like
#
-# rake notes
-# rake notes:optimize
+# rails notes
+# rails notes:optimize
#
-# and friends. See <tt>rake -T notes</tt> and <tt>railties/lib/rails/tasks/annotations.rake</tt>.
+# and friends. See <tt>rails -T notes</tt> and <tt>railties/lib/rails/tasks/annotations.rake</tt>.
#
# Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
# represent the line where the annotation lives, its tag, and its text. Note
diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb
index 2dd74f8fd1..1b23b0de91 100644
--- a/railties/test/backtrace_cleaner_test.rb
+++ b/railties/test/backtrace_cleaner_test.rb
@@ -1,24 +1,32 @@
require 'abstract_unit'
require 'rails/backtrace_cleaner'
-class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase
+class BacktraceCleanerTest < ActiveSupport::TestCase
def setup
@cleaner = Rails::BacktraceCleaner.new
end
test "should format installed gems correctly" do
- @backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
- @result = @cleaner.clean(@backtrace, :all)
- assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0]
+ backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @cleaner.clean(backtrace, :all)
+ assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0]
end
test "should format installed gems not in Gem.default_dir correctly" do
- @target_dir = Gem.path.detect { |p| p != Gem.default_dir }
+ target_dir = Gem.path.detect { |p| p != Gem.default_dir }
# skip this test if default_dir is the only directory on Gem.path
if @target_dir
- @backtrace = [ "#{@target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
- @result = @cleaner.clean(@backtrace, :all)
- assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0]
+ backtrace = [ "#{target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ]
+ result = @cleaner.clean(backtrace, :all)
+ assert_equal "nosuchgem (1.2.3) lib/foo.rb", result[0]
end
end
+
+ test "should consider traces from irb lines as User code" do
+ backtrace = [ "from (irb):1",
+ "from /Path/to/rails/railties/lib/rails/commands/console.rb:77:in `start'",
+ "from bin/rails:4:in `<main>'" ]
+ result = @cleaner.clean(backtrace, :all)
+ assert_equal "from (irb):1", result[0]
+ end
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 058308aa13..ac1488abb3 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -597,6 +597,21 @@ class AppGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_generation_runs_bundle_install
+ assert_generates_with_bundler
+ end
+
+ def test_dev_option
+ assert_generates_with_bundler dev: true
+ rails_path = File.expand_path('../../..', Rails.root)
+ assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/
+ end
+
+ def test_edge_option
+ assert_generates_with_bundler edge: true
+ assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']#{Regexp.escape("5-0-stable")}["']$}
+ end
+
def test_spring
run_generator
assert_gem 'spring'
@@ -754,41 +769,61 @@ class AppGeneratorTest < Rails::Generators::TestCase
protected
- def stub_rails_application(root)
- Rails.application.config.root = root
- Rails.application.class.stub(:name, "Myapp") do
- yield
+ def stub_rails_application(root)
+ Rails.application.config.root = root
+ Rails.application.class.stub(:name, "Myapp") do
+ yield
+ end
end
- end
- def action(*args, &block)
- capture(:stdout) { generator.send(*args, &block) }
- end
+ def action(*args, &block)
+ capture(:stdout) { generator.send(*args, &block) }
+ end
- def assert_gem(gem, constraint = nil)
- if constraint
- assert_file "Gemfile", /^\s*gem\s+["']#{gem}["'], #{constraint}$*/
- else
- assert_file "Gemfile", /^\s*gem\s+["']#{gem}["']$*/
+ def assert_gem(gem, constraint = nil)
+ if constraint
+ assert_file "Gemfile", /^\s*gem\s+["']#{gem}["'], #{constraint}$*/
+ else
+ assert_file "Gemfile", /^\s*gem\s+["']#{gem}["']$*/
+ end
end
- end
- def assert_listen_related_configuration
- assert_gem 'listen'
- assert_gem 'spring-watcher-listen'
+ def assert_listen_related_configuration
+ assert_gem 'listen'
+ assert_gem 'spring-watcher-listen'
- assert_file 'config/environments/development.rb' do |content|
- assert_match(/^\s*config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
+ assert_file 'config/environments/development.rb' do |content|
+ assert_match(/^\s*config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
+ end
end
- end
- def assert_no_listen_related_configuration
- assert_file 'Gemfile' do |content|
- assert_no_match(/listen/, content)
+ def assert_no_listen_related_configuration
+ assert_file 'Gemfile' do |content|
+ assert_no_match(/listen/, content)
+ end
+
+ assert_file 'config/environments/development.rb' do |content|
+ assert_match(/^\s*# config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
+ end
end
- assert_file 'config/environments/development.rb' do |content|
- assert_match(/^\s*# config.file_watcher = ActiveSupport::EventedFileUpdateChecker/, content)
+ def assert_generates_with_bundler(options = {})
+ generator([destination_root], options)
+
+ command_check = -> command do
+ @install_called ||= 0
+
+ case command
+ when 'install'
+ @install_called += 1
+ assert_equal 1, @install_called, "install expected to be called once, but was called #{@install_called} times"
+ when 'exec spring binstub --all'
+ # Called when running tests with spring, let through unscathed.
+ end
+ end
+
+ generator.stub :bundle_command, command_check do
+ quietly { generator.invoke_all }
+ end
end
- end
end
diff --git a/railties/test/generators/plugin_generator_test.rb b/railties/test/generators/plugin_generator_test.rb
index 5dd4cce28a..823dcc50ee 100644
--- a/railties/test/generators/plugin_generator_test.rb
+++ b/railties/test/generators/plugin_generator_test.rb
@@ -193,13 +193,24 @@ class PluginGeneratorTest < Rails::Generators::TestCase
assert_file "test/dummy/config/database.yml", /postgres/
end
- def test_generation_runs_bundle_install_with_full_and_mountable
- result = run_generator [destination_root, "--mountable", "--full", "--dev"]
- assert_match(/run bundle install/, result)
- assert $?.success?, "Command failed: #{result}"
- assert_file "#{destination_root}/Gemfile.lock" do |contents|
- assert_match(/bukkits/, contents)
- end
+ def test_generation_runs_bundle_install
+ assert_generates_without_bundler
+ end
+
+ def test_dev_option
+ assert_generates_without_bundler(dev: true)
+ rails_path = File.expand_path('../../..', Rails.root)
+ assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/
+ end
+
+ def test_edge_option
+ assert_generates_without_bundler(edge: true)
+ assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["'],\s+branch:\s+["']#{Regexp.escape("5-0-stable")}["']$}
+ end
+
+ def test_generation_does_not_run_bundle_install_with_full_and_mountable
+ assert_generates_without_bundler(mountable: true, full: true, dev: true)
+ assert_no_file "#{destination_root}/Gemfile.lock"
end
def test_skipping_javascripts_without_mountable_option
@@ -697,48 +708,38 @@ class PluginGeneratorTest < Rails::Generators::TestCase
end
end
- def test_after_bundle_callback
- path = 'http://example.org/rails_template'
- template = %{ after_bundle { run 'echo ran after_bundle' } }
- template.instance_eval "def read; self; end" # Make the string respond to read
+ protected
- check_open = -> *args do
- assert_equal [ path, 'Accept' => 'application/x-thor-template' ], args
- template
+ def action(*args, &block)
+ silence(:stdout){ generator.send(*args, &block) }
end
- sequence = ['install', 'echo ran after_bundle']
- @sequence_step ||= 0
- ensure_bundler_first = -> command do
- assert_equal sequence[@sequence_step], command, "commands should be called in sequence #{sequence}"
- @sequence_step += 1
+ def default_files
+ ::DEFAULT_PLUGIN_FILES
end
- generator([destination_root], template: path).stub(:open, check_open, template) do
- generator.stub(:bundle_command, ensure_bundler_first) do
- generator.stub(:run, ensure_bundler_first) do
- quietly { generator.invoke_all }
- end
+ def assert_match_sqlite3(contents)
+ if defined?(JRUBY_VERSION)
+ assert_match(/group :development do\n gem 'activerecord-jdbcsqlite3-adapter'\nend/, contents)
+ else
+ assert_match(/group :development do\n gem 'sqlite3'\nend/, contents)
end
end
- assert_equal 2, @sequence_step
- end
+ def assert_generates_without_bundler(options = {})
+ generator([destination_root], options)
-protected
- def action(*args, &block)
- silence(:stdout){ generator.send(*args, &block) }
- end
-
- def default_files
- ::DEFAULT_PLUGIN_FILES
- end
+ command_check = -> command do
+ case command
+ when 'install'
+ flunk "install expected to not be called"
+ when 'exec spring binstub --all'
+ # Called when running tests with spring, let through unscathed.
+ end
+ end
- def assert_match_sqlite3(contents)
- if defined?(JRUBY_VERSION)
- assert_match(/group :development do\n gem 'activerecord-jdbcsqlite3-adapter'\nend/, contents)
- else
- assert_match(/group :development do\n gem 'sqlite3'\nend/, contents)
+ generator.stub :bundle_command, command_check do
+ quietly { generator.invoke_all }
+ end
end
- end
end
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index e83d54890a..03ea521355 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -26,30 +26,6 @@ module SharedGeneratorTests
default_files.each { |path| assert_file path }
end
- def assert_generates_with_bundler(options = {})
- generator([destination_root], options)
-
- command_check = -> command do
- @install_called ||= 0
-
- case command
- when 'install'
- @install_called += 1
- assert_equal 1, @install_called, "install expected to be called once, but was called #{@install_called} times"
- when 'exec spring binstub --all'
- # Called when running tests with spring, let through unscathed.
- end
- end
-
- generator.stub :bundle_command, command_check do
- quietly { generator.invoke_all }
- end
- end
-
- def test_generation_runs_bundle_install
- assert_generates_with_bundler
- end
-
def test_plugin_new_generate_pretend
run_generator ["testapp", "--pretend"]
default_files.each{ |path| assert_no_file File.join("testapp",path) }
@@ -114,17 +90,6 @@ module SharedGeneratorTests
end
end
- def test_dev_option
- assert_generates_with_bundler dev: true
- rails_path = File.expand_path('../../..', Rails.root)
- assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/
- end
-
- def test_edge_option
- assert_generates_with_bundler edge: true
- assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$}
- end
-
def test_skip_gemfile
assert_not_called(generator([destination_root], skip_gemfile: true), :bundle_command) do
quietly { generator.invoke_all }