radiant 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of radiant might be problematic. Click here for more details.

Files changed (197) hide show
  1. data/CHANGELOG +61 -7
  2. data/CONTRIBUTORS +15 -0
  3. data/app/controllers/admin/export_controller.rb +1 -1
  4. data/app/controllers/admin/page_controller.rb +1 -0
  5. data/app/controllers/admin/user_controller.rb +2 -1
  6. data/app/controllers/application.rb +7 -8
  7. data/app/helpers/admin/node_helper.rb +84 -0
  8. data/app/helpers/admin/page_helper.rb +1 -19
  9. data/app/helpers/application_helper.rb +15 -9
  10. data/app/models/file_not_found_page.rb +2 -2
  11. data/app/models/page.rb +22 -18
  12. data/app/models/page_context.rb +9 -0
  13. data/app/models/radiant/config.rb +4 -2
  14. data/app/models/response_cache.rb +18 -12
  15. data/app/models/standard_tags.rb +111 -50
  16. data/app/views/admin/extension/index.rhtml +2 -2
  17. data/app/views/admin/layout/edit.rhtml +2 -2
  18. data/app/views/admin/layout/remove.rhtml +2 -2
  19. data/app/views/admin/page/_node.rhtml +4 -26
  20. data/app/views/admin/page/_part.rhtml +9 -14
  21. data/app/views/admin/page/edit.rhtml +38 -121
  22. data/app/views/admin/page/index.rhtml +2 -6
  23. data/app/views/admin/page/remove.rhtml +2 -2
  24. data/app/views/admin/snippet/edit.rhtml +3 -3
  25. data/app/views/admin/snippet/index.rhtml +2 -2
  26. data/app/views/admin/snippet/remove.rhtml +2 -2
  27. data/app/views/admin/user/edit.rhtml +4 -4
  28. data/app/views/admin/user/preferences.rhtml +2 -2
  29. data/app/views/admin/welcome/login.rhtml +1 -1
  30. data/config/environment.rb +79 -78
  31. data/db/schema.rb +2 -0
  32. data/lib/local_time.rb +12 -0
  33. data/lib/plugins/extension_patches/lib/fixture_loading_extension.rb +1 -1
  34. data/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb +3 -3
  35. data/lib/radiant.rb +1 -1
  36. data/lib/radiant/extension.rb +9 -3
  37. data/lib/radiant/extension_loader.rb +2 -2
  38. data/lib/tasks/extensions.rake +23 -8
  39. data/public/javascripts/admin.js +89 -0
  40. data/public/javascripts/controls.js +486 -354
  41. data/public/javascripts/dragdrop.js +90 -58
  42. data/public/javascripts/effects.js +398 -364
  43. data/public/javascripts/pngfix.js +37 -37
  44. data/public/javascripts/prototype.js +2764 -1095
  45. data/public/javascripts/ruledtable.js +10 -25
  46. data/public/javascripts/sitemap.js +74 -112
  47. data/public/javascripts/string.js +1 -7
  48. data/public/javascripts/tabcontrol.js +71 -86
  49. data/public/javascripts/tag_reference_search.js +19 -26
  50. data/public/stylesheets/admin/main.css +11 -5
  51. data/test/fixtures/extensions/01_basic/lib/new_module.rb +2 -0
  52. data/test/fixtures/page_parts.yml +16 -1
  53. data/test/fixtures/pages.yml +47 -84
  54. data/test/functional/extension_initialization_test.rb +11 -0
  55. data/test/helpers/login_test_helper.rb +12 -1
  56. data/test/helpers/page_test_helper.rb +6 -0
  57. data/test/helpers/render_test_helper.rb +11 -8
  58. data/test/test_helper.rb +1 -12
  59. data/test/unit/file_not_found_page_test.rb +5 -1
  60. data/test/unit/local_time_test.rb +45 -0
  61. data/test/unit/page_context_test.rb +32 -1
  62. data/test/unit/page_test.rb +45 -11
  63. data/test/unit/radiant/config_test.rb +1 -1
  64. data/test/unit/response_cache_test.rb +27 -2
  65. data/test/unit/standard_tags_test.rb +60 -15
  66. data/vendor/extensions/archive/README +29 -0
  67. data/vendor/extensions/archive/Rakefile +25 -0
  68. data/{app → vendor/extensions/archive/app}/models/archive_day_index_page.rb +0 -0
  69. data/{app → vendor/extensions/archive/app}/models/archive_finder.rb +8 -6
  70. data/{app → vendor/extensions/archive/app}/models/archive_month_index_page.rb +0 -0
  71. data/{app → vendor/extensions/archive/app}/models/archive_page.rb +0 -0
  72. data/{app → vendor/extensions/archive/app}/models/archive_year_index_page.rb +0 -0
  73. data/vendor/extensions/archive/archive_extension.rb +19 -0
  74. data/{lib → vendor/extensions/archive/lib}/archive_index_tags_and_methods.rb +0 -0
  75. data/vendor/extensions/archive/lib/tasks/archive_extension_tasks.rake +28 -0
  76. data/vendor/extensions/archive/test/fixtures/pages.yml +397 -0
  77. data/vendor/extensions/archive/test/functional/archive_extension_test.rb +16 -0
  78. data/{test → vendor/extensions/archive/test}/helpers/archive_index_test_helper.rb +0 -0
  79. data/vendor/extensions/archive/test/test_helper.rb +19 -0
  80. data/{test → vendor/extensions/archive/test}/unit/archive_day_index_page_test.rb +0 -0
  81. data/{test → vendor/extensions/archive/test}/unit/archive_month_index_page_test.rb +0 -0
  82. data/{test → vendor/extensions/archive/test}/unit/archive_page_test.rb +7 -1
  83. data/{test → vendor/extensions/archive/test}/unit/archive_year_index_page_test.rb +0 -0
  84. data/vendor/rails/actionmailer/CHANGELOG +10 -0
  85. data/vendor/rails/actionmailer/Rakefile +1 -1
  86. data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
  87. data/vendor/rails/actionpack/CHANGELOG +51 -2
  88. data/vendor/rails/actionpack/Rakefile +1 -1
  89. data/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +2 -2
  90. data/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +1 -1
  91. data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +3 -0
  92. data/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +1 -0
  93. data/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +2 -0
  94. data/vendor/rails/actionpack/lib/action_controller/base.rb +7 -1
  95. data/vendor/rails/actionpack/lib/action_controller/caching.rb +39 -38
  96. data/vendor/rails/actionpack/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
  97. data/vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
  98. data/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +13 -4
  99. data/vendor/rails/actionpack/lib/action_controller/cookies.rb +5 -3
  100. data/vendor/rails/actionpack/lib/action_controller/filters.rb +176 -77
  101. data/vendor/rails/actionpack/lib/action_controller/integration.rb +31 -21
  102. data/vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb +1 -1
  103. data/vendor/rails/actionpack/lib/action_controller/pagination.rb +7 -1
  104. data/vendor/rails/actionpack/lib/action_controller/resources.rb +117 -32
  105. data/vendor/rails/actionpack/lib/action_controller/routing.rb +56 -23
  106. data/vendor/rails/actionpack/lib/action_controller/test_process.rb +5 -2
  107. data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +4 -1
  108. data/vendor/rails/actionpack/lib/action_controller/verification.rb +1 -0
  109. data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
  110. data/vendor/rails/actionpack/lib/action_view/base.rb +25 -19
  111. data/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +2 -2
  112. data/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +18 -18
  113. data/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +10 -0
  114. data/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb +3 -0
  115. data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +33 -17
  116. data/vendor/rails/actionpack/test/activerecord/pagination_test.rb +9 -0
  117. data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +13 -0
  118. data/vendor/rails/actionpack/test/controller/addresses_render_test.rb +4 -1
  119. data/vendor/rails/actionpack/test/controller/base_test.rb +1 -1
  120. data/vendor/rails/actionpack/test/controller/caching_test.rb +3 -2
  121. data/vendor/rails/actionpack/test/controller/cookie_test.rb +11 -0
  122. data/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
  123. data/vendor/rails/actionpack/test/controller/filter_params_test.rb +1 -0
  124. data/vendor/rails/actionpack/test/controller/filters_test.rb +149 -26
  125. data/vendor/rails/actionpack/test/controller/integration_test.rb +93 -8
  126. data/vendor/rails/actionpack/test/controller/resources_test.rb +215 -36
  127. data/vendor/rails/actionpack/test/controller/routing_test.rb +2 -2
  128. data/vendor/rails/actionpack/test/controller/test_test.rb +16 -0
  129. data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +66 -10
  130. data/vendor/rails/actionpack/test/controller/verification_test.rb +15 -0
  131. data/vendor/rails/actionpack/test/fixtures/test/hello_world.rxml +2 -1
  132. data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +5 -0
  133. data/vendor/rails/actionpack/test/template/compiled_templates_test.rb +29 -17
  134. data/vendor/rails/actionpack/test/template/javascript_helper_test.rb +4 -4
  135. data/vendor/rails/actionpack/test/template/number_helper_test.rb +1 -1
  136. data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +13 -13
  137. data/vendor/rails/actionwebservice/CHANGELOG +14 -0
  138. data/vendor/rails/actionwebservice/Rakefile +2 -2
  139. data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +1 -1
  140. data/vendor/rails/activerecord/CHANGELOG +34 -0
  141. data/vendor/rails/activerecord/Rakefile +1 -1
  142. data/vendor/rails/activerecord/lib/active_record/acts/list.rb +14 -2
  143. data/vendor/rails/activerecord/lib/active_record/acts/tree.rb +7 -0
  144. data/vendor/rails/activerecord/lib/active_record/associations.rb +29 -14
  145. data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +5 -1
  146. data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +2 -2
  147. data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +10 -0
  148. data/vendor/rails/activerecord/lib/active_record/base.rb +12 -3
  149. data/vendor/rails/activerecord/lib/active_record/calculations.rb +2 -2
  150. data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
  151. data/vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
  152. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +2 -2
  153. data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +54 -38
  154. data/vendor/rails/activerecord/lib/active_record/deprecated_finders.rb +3 -3
  155. data/vendor/rails/activerecord/lib/active_record/fixtures.rb +1 -1
  156. data/vendor/rails/activerecord/lib/active_record/timestamp.rb +0 -9
  157. data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
  158. data/vendor/rails/activerecord/test/associations/eager_test.rb +13 -0
  159. data/vendor/rails/activerecord/test/associations/join_model_test.rb +10 -1
  160. data/vendor/rails/activerecord/test/associations_test.rb +36 -3
  161. data/vendor/rails/activerecord/test/base_test.rb +17 -4
  162. data/vendor/rails/activerecord/test/defaults_test.rb +15 -0
  163. data/vendor/rails/activerecord/test/fixtures/author.rb +1 -0
  164. data/vendor/rails/activerecord/test/fixtures/binaries.yml +437 -0
  165. data/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +13 -0
  166. data/vendor/rails/activerecord/test/fixtures/developer.rb +10 -0
  167. data/vendor/rails/activerecord/test/fixtures_test.rb +9 -5
  168. data/vendor/rails/activerecord/test/migration_test.rb +9 -10
  169. data/vendor/rails/activerecord/test/mixin_test.rb +47 -0
  170. data/vendor/rails/activerecord/test/validations_test.rb +2 -2
  171. data/vendor/rails/activesupport/CHANGELOG +16 -0
  172. data/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +9 -3
  173. data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +48 -3
  174. data/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +14 -0
  175. data/vendor/rails/activesupport/lib/active_support/dependencies.rb +3 -3
  176. data/vendor/rails/activesupport/lib/active_support/json/encoders/core.rb +5 -3
  177. data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +6 -6
  178. data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
  179. data/vendor/rails/activesupport/test/core_ext/hash_ext_test.rb +37 -0
  180. data/vendor/rails/activesupport/test/core_ext/module_test.rb +8 -0
  181. data/vendor/rails/activesupport/test/dependencies_test.rb +11 -0
  182. data/vendor/rails/activesupport/test/{json.rb → json_test.rb} +15 -5
  183. data/vendor/rails/railties/CHANGELOG +25 -1
  184. data/vendor/rails/railties/README +32 -3
  185. data/vendor/rails/railties/Rakefile +5 -5
  186. data/vendor/rails/railties/environments/boot.rb +12 -18
  187. data/vendor/rails/railties/environments/environment.rb +15 -15
  188. data/vendor/rails/railties/lib/dispatcher.rb +1 -2
  189. data/vendor/rails/railties/lib/initializer.rb +33 -9
  190. data/vendor/rails/railties/lib/rails/version.rb +1 -1
  191. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -1
  192. data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +1 -0
  193. data/vendor/rails/railties/lib/railties_path.rb +1 -1
  194. data/vendor/rails/railties/lib/tasks/framework.rake +4 -4
  195. data/vendor/rails/railties/lib/tasks/routes.rake +17 -0
  196. data/vendor/rails/release.rb +2 -2
  197. metadata +1877 -1848
@@ -8,6 +8,14 @@ ActiveRecord::Schema.define do
8
8
  ActiveRecord::Base.connection.create_table(*args, &block)
9
9
  ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
10
10
  end
11
+
12
+ create_table :sql_server_defaults, :force => true do |t|
13
+ t.column :string_with_null_default, :string, :default => nil
14
+ t.column :string_with_pretend_null_one, :string, :default => 'null'
15
+ t.column :string_with_pretend_null_two, :string, :default => '(null)'
16
+ t.column :string_with_pretend_null_three, :string, :default => 'NULL'
17
+ t.column :string_with_pretend_null_four, :string, :default => '(NULL)'
18
+ end
11
19
  end
12
20
 
13
21
  create_table :taggings, :force => true do |t|
@@ -57,4 +65,9 @@ ActiveRecord::Schema.define do
57
65
  create_table :lock_without_defaults_cust, :force => true do |t|
58
66
  t.column :custom_lock_version, :integer
59
67
  end
68
+
69
+ create_table :audit_logs, :force => true do |t|
70
+ t.column :message, :string, :null=>false
71
+ t.column :developer_id, :integer, :null=>false
72
+ end
60
73
  end
@@ -31,8 +31,18 @@ class Developer < ActiveRecord::Base
31
31
 
32
32
  has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'
33
33
 
34
+ has_many :audit_logs
35
+
34
36
  validates_inclusion_of :salary, :in => 50000..200000
35
37
  validates_length_of :name, :within => 3..20
38
+
39
+ before_create do |developer|
40
+ developer.audit_logs.build :message => "Computer created"
41
+ end
42
+ end
43
+
44
+ class AuditLog < ActiveRecord::Base
45
+ belongs_to :developer
36
46
  end
37
47
 
38
48
  DeveloperSalary = Struct.new(:amount)
@@ -12,13 +12,15 @@ class FixturesTest < Test::Unit::TestCase
12
12
  self.use_instantiated_fixtures = true
13
13
  self.use_transactional_fixtures = false
14
14
 
15
- fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes
15
+ fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries
16
16
 
17
- FIXTURES = %w( accounts companies customers
17
+ FIXTURES = %w( accounts binaries companies customers
18
18
  developers developers_projects entrants
19
19
  movies projects subscribers topics tasks )
20
20
  MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-_\w]*/
21
21
 
22
+ BINARY_FIXTURE_PATH = File.dirname(__FILE__) + '/fixtures/flowers.jpg'
23
+
22
24
  def test_clean_fixtures
23
25
  FIXTURES.each do |name|
24
26
  fixtures = nil
@@ -100,7 +102,6 @@ class FixturesTest < Test::Unit::TestCase
100
102
  assert first
101
103
  end
102
104
 
103
-
104
105
  def test_bad_format
105
106
  path = File.join(File.dirname(__FILE__), 'fixtures', 'bad_fixtures')
106
107
  Dir.entries(path).each do |file|
@@ -174,7 +175,6 @@ class FixturesTest < Test::Unit::TestCase
174
175
  end
175
176
  end
176
177
 
177
-
178
178
  def test_yml_file_in_subdirectory
179
179
  assert_equal(categories(:sub_special_1).name, "A special category in a subdir file")
180
180
  assert_equal(categories(:sub_special_1).class, SpecialCategory)
@@ -185,7 +185,11 @@ class FixturesTest < Test::Unit::TestCase
185
185
  assert_equal(categories(:sub_special_3).class, SpecialCategory)
186
186
  end
187
187
 
188
-
188
+ def test_binary_in_fixtures
189
+ assert_equal 1, @binaries.size
190
+ data = File.read(BINARY_FIXTURE_PATH).freeze
191
+ assert_equal data, @flowers.data
192
+ end
189
193
  end
190
194
 
191
195
  if Account.connection.respond_to?(:reset_pk_sequence!)
@@ -170,7 +170,7 @@ if ActiveRecord::Base.connection.supports_migrations?
170
170
  # SQL Server and Sybase will not allow you to add a NOT NULL column
171
171
  # to a table without specifying a default value, so the
172
172
  # following test must be skipped
173
- unless current_adapter?(:SQLServerAdapter, :SybaseAdapter)
173
+ unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :SQLiteAdapter)
174
174
  def test_add_column_not_null_without_default
175
175
  Person.connection.create_table :testings do |t|
176
176
  t.column :foo, :string
@@ -209,7 +209,7 @@ if ActiveRecord::Base.connection.supports_migrations?
209
209
  def test_native_decimal_insert_manual_vs_automatic
210
210
  # SQLite3 always uses float in violation of SQL
211
211
  # 16 decimal places
212
- correct_value = (current_adapter?(:SQLiteAdapter) ? '0.123456789012346E20' : '0012345678901234567890.0123456789').to_d
212
+ correct_value = '0012345678901234567890.0123456789'.to_d
213
213
 
214
214
  Person.delete_all
215
215
  Person.connection.add_column "people", "wealth", :decimal, :precision => '30', :scale => '10'
@@ -227,8 +227,9 @@ if ActiveRecord::Base.connection.supports_migrations?
227
227
  assert_kind_of BigDecimal, row.wealth
228
228
 
229
229
  # If this assert fails, that means the SELECT is broken!
230
- assert_equal correct_value, row.wealth
231
-
230
+ unless current_adapter?(:SQLite3Adapter)
231
+ assert_equal correct_value, row.wealth
232
+ end
232
233
  # Reset to old state
233
234
  Person.delete_all
234
235
 
@@ -240,8 +241,9 @@ if ActiveRecord::Base.connection.supports_migrations?
240
241
  assert_kind_of BigDecimal, row.wealth
241
242
 
242
243
  # If these asserts fail, that means the INSERT (create function, or cast to SQL) is broken!
243
- assert_equal correct_value, row.wealth
244
-
244
+ unless current_adapter?(:SQLite3Adapter)
245
+ assert_equal correct_value, row.wealth
246
+ end
245
247
  # Reset to old state
246
248
  Person.connection.del_column "people", "wealth" rescue nil
247
249
  Person.reset_column_information
@@ -267,10 +269,7 @@ if ActiveRecord::Base.connection.supports_migrations?
267
269
 
268
270
  # Test for 30 significent digits (beyond the 16 of float), 10 of them
269
271
  # after the decimal place.
270
- if current_adapter?(:SQLiteAdapter)
271
- # SQLite3 uses float in violation of SQL. Test for 16 decimal places.
272
- assert_equal BigDecimal.new('0.123456789012346E20'), bob.wealth
273
- else
272
+ unless current_adapter?(:SQLite3Adapter)
274
273
  assert_equal BigDecimal.new("0012345678901234567890.0123456789"), bob.wealth
275
274
  end
276
275
 
@@ -211,6 +211,53 @@ class ListTest < Test::Unit::TestCase
211
211
  assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
212
212
  end
213
213
 
214
+ def test_remove_from_list_should_then_fail_in_list?
215
+ assert_equal true, mixins(:list_1).in_list?
216
+ mixins(:list_1).remove_from_list
217
+ assert_equal false, mixins(:list_1).in_list?
218
+ end
219
+
220
+ def test_remove_from_list_should_set_position_to_nil
221
+ assert_equal [mixins(:list_1),
222
+ mixins(:list_2),
223
+ mixins(:list_3),
224
+ mixins(:list_4)],
225
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
226
+
227
+ mixins(:list_2).remove_from_list
228
+
229
+ assert_equal [mixins(:list_2, :reload),
230
+ mixins(:list_1, :reload),
231
+ mixins(:list_3, :reload),
232
+ mixins(:list_4, :reload)],
233
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
234
+
235
+ assert_equal 1, mixins(:list_1).pos
236
+ assert_equal nil, mixins(:list_2).pos
237
+ assert_equal 2, mixins(:list_3).pos
238
+ assert_equal 3, mixins(:list_4).pos
239
+ end
240
+
241
+ def test_remove_before_destroy_does_not_shift_lower_items_twice
242
+ assert_equal [mixins(:list_1),
243
+ mixins(:list_2),
244
+ mixins(:list_3),
245
+ mixins(:list_4)],
246
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
247
+
248
+ mixins(:list_2).remove_from_list
249
+ mixins(:list_2).destroy
250
+
251
+ assert_equal [mixins(:list_1, :reload),
252
+ mixins(:list_3, :reload),
253
+ mixins(:list_4, :reload)],
254
+ ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
255
+
256
+ assert_equal 1, mixins(:list_1).pos
257
+ assert_equal 2, mixins(:list_3).pos
258
+ assert_equal 3, mixins(:list_4).pos
259
+ end
260
+
214
261
  end
215
262
 
216
263
  class TreeTest < Test::Unit::TestCase
@@ -631,7 +631,7 @@ class ValidationsTest < Test::Unit::TestCase
631
631
  t = Topic.new('title' => 'noreplies', 'content' => 'whatever')
632
632
  assert !t.save
633
633
  assert t.errors.on(:replies)
634
- t.replies.create('title' => 'areply', 'content' => 'whateveragain')
634
+ t.replies.build('title' => 'areply', 'content' => 'whateveragain')
635
635
  assert t.valid?
636
636
  end
637
637
 
@@ -824,7 +824,7 @@ class ValidationsTest < Test::Unit::TestCase
824
824
  t = Topic.new('title' => 'あいうえお', 'content' => 'かきくけこ')
825
825
  assert !t.save
826
826
  assert t.errors.on(:replies)
827
- t.replies.create('title' => 'あいうえお', 'content' => 'かきくけこ')
827
+ t.replies.build('title' => 'あいうえお', 'content' => 'かきくけこ')
828
828
  assert t.valid?
829
829
  end
830
830
  end
@@ -1,3 +1,19 @@
1
+ *1.4.4* (October 12th, 2007)
2
+
3
+ * Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
4
+
5
+
6
+ *1.4.3* (October 4th, 2007)
7
+
8
+ * Demote Hash#to_xml to use XmlSimple#xml_in_string so it can't read files or stdin. #8453 [candlerb, Jeremy Kemper]
9
+
10
+ * Document Object#blank?. #6491 [Chris Mear]
11
+
12
+ * Update Dependencies to ignore constants inherited from ancestors. Closes #6951. [Nicholas Seckar]
13
+
14
+ * Improved multibyte performance by relying less on exception raising #8159 [Blaine]
15
+
16
+
1
17
  *1.4.2* (March 12th, 2007)
2
18
 
3
19
  * Ruby 1.8.6 and 1.9 define private Time#to_date and #to_datetime; make them
@@ -1,5 +1,11 @@
1
- class Object #:nodoc:
2
- # "", " ", nil, [], and {} are blank
1
+ class Object
2
+ # An object is blank if it's nil, empty, or a whitespace string.
3
+ # For example, "", " ", nil, [], and {} are blank.
4
+ #
5
+ # This simplifies
6
+ # if !address.nil? && !address.empty?
7
+ # to
8
+ # if !address.blank?
3
9
  def blank?
4
10
  if respond_to?(:empty?) && respond_to?(:strip)
5
11
  empty? or strip.empty?
@@ -47,4 +53,4 @@ class Numeric #:nodoc:
47
53
  def blank?
48
54
  false
49
55
  end
50
- end
56
+ end
@@ -1,5 +1,44 @@
1
1
  require 'date'
2
2
  require 'xml_simple'
3
+ require 'cgi'
4
+
5
+ # Extensions needed for Hash#to_query
6
+ class Object
7
+ def to_param #:nodoc:
8
+ to_s
9
+ end
10
+
11
+ def to_query(key) #:nodoc:
12
+ "#{CGI.escape(key.to_s)}=#{CGI.escape(to_param.to_s)}"
13
+ end
14
+ end
15
+
16
+ class Array
17
+ def to_query(key) #:nodoc:
18
+ collect { |value| value.to_query("#{key}[]") }.sort * '&'
19
+ end
20
+ end
21
+
22
+ # Locked down XmlSimple#xml_in_string
23
+ class XmlSimple
24
+ # Same as xml_in but doesn't try to smartly shoot itself in the foot.
25
+ def xml_in_string(string, options = nil)
26
+ handle_options('in', options)
27
+
28
+ @doc = parse(string)
29
+ result = collapse(@doc.root)
30
+
31
+ if @options['keeproot']
32
+ merge({}, @doc.root.name, result)
33
+ else
34
+ result
35
+ end
36
+ end
37
+
38
+ def self.xml_in_string(string, options = nil)
39
+ new.xml_in_string(string, options)
40
+ end
41
+ end
3
42
 
4
43
  module ActiveSupport #:nodoc:
5
44
  module CoreExtensions #:nodoc:
@@ -27,6 +66,12 @@ module ActiveSupport #:nodoc:
27
66
  klass.extend(ClassMethods)
28
67
  end
29
68
 
69
+ def to_query(namespace = nil)
70
+ collect do |key, value|
71
+ value.to_query(namespace ? "#{namespace}[#{key}]" : key)
72
+ end.sort * '&'
73
+ end
74
+
30
75
  def to_xml(options = {})
31
76
  options[:indent] ||= 2
32
77
  options.reverse_merge!({ :builder => Builder::XmlMarkup.new(:indent => options[:indent]),
@@ -81,14 +126,14 @@ module ActiveSupport #:nodoc:
81
126
  module ClassMethods
82
127
  def from_xml(xml)
83
128
  # TODO: Refactor this into something much cleaner that doesn't rely on XmlSimple
84
- undasherize_keys(typecast_xml_value(XmlSimple.xml_in(xml,
129
+ undasherize_keys(typecast_xml_value(XmlSimple.xml_in_string(xml,
85
130
  'forcearray' => false,
86
131
  'forcecontent' => true,
87
132
  'keeproot' => true,
88
133
  'contentkey' => '__content__')
89
- ))
134
+ ))
90
135
  end
91
-
136
+
92
137
  def create_from_xml(xml)
93
138
  ActiveSupport::Deprecation.warn("Hash.create_from_xml has been renamed to Hash.from_xml", caller)
94
139
  from_xml(xml)
@@ -18,4 +18,18 @@ class Module
18
18
  parents << Object unless parents.include? Object
19
19
  parents
20
20
  end
21
+
22
+ # Return the constants that have been defined locally by this object and not
23
+ # in an ancestor. This method may miss some constants if their definition in
24
+ # the ancestor is identical to their definition in the receiver.
25
+ def local_constants
26
+ inherited = {}
27
+ ancestors.each do |anc|
28
+ next if anc == self
29
+ anc.constants.each { |const| inherited[const] = anc.const_get(const) }
30
+ end
31
+ constants.select do |const|
32
+ ! inherited.key?(const) || inherited[const].object_id != const_get(const).object_id
33
+ end
34
+ end
21
35
  end
@@ -318,13 +318,13 @@ module Dependencies #:nodoc:
318
318
  watch_frames = descs.collect do |desc|
319
319
  if desc.is_a? Module
320
320
  mod_name = desc.name
321
- initial_constants = desc.constants
321
+ initial_constants = desc.local_constants
322
322
  elsif desc.is_a?(String) || desc.is_a?(Symbol)
323
323
  mod_name = desc.to_s
324
324
 
325
325
  # Handle the case where the module has yet to be defined.
326
326
  initial_constants = if qualified_const_defined?(mod_name)
327
- mod_name.constantize.constants
327
+ mod_name.constantize.local_constants
328
328
  else
329
329
  []
330
330
  end
@@ -349,7 +349,7 @@ module Dependencies #:nodoc:
349
349
 
350
350
  mod = mod_name.constantize
351
351
  next [] unless mod.is_a? Module
352
- new_constants = mod.constants - prior_constants
352
+ new_constants = mod.local_constants - prior_constants
353
353
 
354
354
  # Make sure no other frames takes credit for these constants.
355
355
  constant_watch_stack.each do |frame_name, constants|
@@ -23,12 +23,14 @@ module ActiveSupport
23
23
  "\n" => '\n',
24
24
  "\r" => '\r',
25
25
  "\t" => '\t',
26
- '"' => '\"',
27
- '\\' => '\\\\'
26
+ '"' => '\"',
27
+ '\\' => '\\\\',
28
+ '<' => '\\074',
29
+ '>' => '\\076'
28
30
  }
29
31
 
30
32
  define_encoder String do |string|
31
- '"' + string.gsub(/[\010\f\n\r\t"\\]/) { |s|
33
+ '"' + string.gsub(/[\010\f\n\r\t"\\<>]/) { |s|
32
34
  ESCAPED_CHARS[s]
33
35
  }.gsub(/([\xC0-\xDF][\x80-\xBF]|
34
36
  [\xE0-\xEF][\x80-\xBF]{2}|
@@ -43,7 +43,7 @@ module ActiveSupport::Multibyte #:nodoc:
43
43
 
44
44
  # Create a new Chars instance.
45
45
  def initialize(str)
46
- @string = (str.string rescue str)
46
+ @string = str.respond_to?(:string) ? str.string : str
47
47
  end
48
48
 
49
49
  # Returns -1, 0 or +1 depending on whether the Chars object is to be sorted before, equal or after the
@@ -70,18 +70,18 @@ module ActiveSupport::Multibyte #:nodoc:
70
70
  def method_missing(m, *a, &b)
71
71
  begin
72
72
  # Simulate methods with a ! at the end because we can't touch the enclosed string from the handlers.
73
- if m.to_s =~ /^(.*)\!$/
73
+ if m.to_s =~ /^(.*)\!$/ && handler.respond_to?($1)
74
74
  result = handler.send($1, @string, *a, &b)
75
75
  if result == @string
76
76
  result = nil
77
77
  else
78
78
  @string.replace result
79
79
  end
80
- else
80
+ elsif handler.respond_to?(m)
81
81
  result = handler.send(m, @string, *a, &b)
82
+ else
83
+ result = @string.send(m, *a, &b)
82
84
  end
83
- rescue NoMethodError
84
- result = @string.send(m, *a, &b)
85
85
  rescue Handlers::EncodingError
86
86
  @string.replace handler.tidy_bytes(@string)
87
87
  retry
@@ -126,4 +126,4 @@ begin
126
126
  ActiveSupport::Multibyte::Chars.handler = ActiveSupport::Multibyte::Handlers::UTF8HandlerProc
127
127
  rescue LoadError
128
128
  ActiveSupport::Multibyte::Chars.handler = ActiveSupport::Multibyte::Handlers::UTF8Handler
129
- end
129
+ end
@@ -2,7 +2,7 @@ module ActiveSupport
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 2
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end