Skip to content
Browse files

Make sure that 3.0.x apps generated reference a compatible mysql2 rel…

…ease.
  • Loading branch information...
1 parent f2c6f04 commit 2004fb9c9700a400f5c182b34ba392cd0bf0ce76 @NZKoz NZKoz committed May 17, 2011
View
7 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -405,6 +405,13 @@ def gem_for_database
end
end
+ def version_constraint_for_database_gem
+ case options[:database]
+ when "mysql" then "~> 0.2.6"
@pacoguzman
pacoguzman added a note May 26, 2011

IMHO is possible to use 0.2.7, ins't it?

@tenderlove
Ruby on Rails member
tenderlove added a note May 26, 2011

Yes. The ~> constraint lets you use "0.2.x" that is greater than or equal to "0.2.6".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ else nil
+ end
+ end
+
def mysql_socket
@mysql_socket ||= [
"/tmp/mysql.sock", # default
View
2 railties/lib/rails/generators/rails/app/templates/Gemfile
@@ -12,7 +12,7 @@ gem 'rails', '<%= Rails::VERSION::STRING %>'
<%- end -%>
<% unless options[:skip_active_record] -%>
-gem '<%= gem_for_database %>'
+gem '<%= gem_for_database %>'<%= ", '#{version_constraint_for_database_gem}'" if version_constraint_for_database_gem %>
<% end -%>
# Use unicorn as the web server
View
4 railties/test/generators/app_generator_test.rb
@@ -160,7 +160,9 @@ def test_config_database_is_added_by_default
def test_config_another_database
run_generator([destination_root, "-d", "mysql"])
assert_file "config/database.yml", /mysql/
- assert_file "Gemfile", /^gem\s+["']mysql2["']$/
+ # Ensure that the mysql2 gem is listed with a compatible version of the
+ # mysql2 gem
+ assert_file "Gemfile", /^gem\s+["']mysql2["'],\s*'~> 0.2.6'$/
end
def test_config_database_is_not_added_if_skip_active_record_is_given

0 comments on commit 2004fb9

Please sign in to comment.
Something went wrong with that request. Please try again.