File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
lib/generators/active_record Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ def session_table_name
1919 end
2020 current_table_name
2121 end
22+
23+ def migration_version
24+ "[#{ ActiveRecord ::Migration . current_version } ]" if ActiveRecord ::Migration . respond_to? ( :current_version )
25+ end
2226 end
2327 end
2428end
Original file line number Diff line number Diff line change 1- class <%= migration_class_name %> < ActiveRecord::Migration
1+ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
22 def change
33 create_table :< %= session_table_name %> do |t |
44 t . string :session_id , :null => false
Original file line number Diff line number Diff line change @@ -8,21 +8,25 @@ class SessionMigrationGeneratorTest < Rails::Generators::TestCase
88 destination 'tmp'
99 setup :prepare_destination
1010
11+ def active_record_version
12+ "\\ [#{ ActiveRecord ::Migration . current_version } \\ ]" if ActiveRecord ::Migration . respond_to? ( :current_version )
13+ end
14+
1115 def test_session_migration_with_default_name
1216 run_generator
13- assert_migration "db/migrate/add_sessions_table.rb" , /class AddSessionsTable < ActiveRecord::Migration/
17+ assert_migration "db/migrate/add_sessions_table.rb" , /class AddSessionsTable < ActiveRecord::Migration#{ active_record_version } /
1418 end
1519
1620 def test_session_migration_with_given_name
1721 run_generator [ "create_session_table" ]
18- assert_migration "db/migrate/create_session_table.rb" , /class CreateSessionTable < ActiveRecord::Migration/
22+ assert_migration "db/migrate/create_session_table.rb" , /class CreateSessionTable < ActiveRecord::Migration#{ active_record_version } /
1923 end
2024
2125 def test_session_migration_with_custom_table_name
2226 ActiveRecord ::SessionStore ::Session . table_name = "custom_table_name"
2327 run_generator
2428 assert_migration "db/migrate/add_sessions_table.rb" do |migration |
25- assert_match ( /class AddSessionsTable < ActiveRecord::Migration/ , migration )
29+ assert_match ( /class AddSessionsTable < ActiveRecord::Migration#{ active_record_version } / , migration )
2630 assert_match ( /create_table :custom_table_name/ , migration )
2731 end
2832 ensure
You can’t perform that action at this time.
0 commit comments