aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/test/controller/render_other_test.rb11
-rw-r--r--actionpack/test/controller/send_file_test.rb8
-rw-r--r--activerecord/lib/active_record/connection_adapters/column.rb15
-rw-r--r--activerecord/test/cases/column_definition_test.rb20
4 files changed, 14 insertions, 40 deletions
diff --git a/actionpack/test/controller/render_other_test.rb b/actionpack/test/controller/render_other_test.rb
index b5e74e373d..af50e11261 100644
--- a/actionpack/test/controller/render_other_test.rb
+++ b/actionpack/test/controller/render_other_test.rb
@@ -1,9 +1,5 @@
require 'abstract_unit'
-ActionController.add_renderer :simon do |says, options|
- self.content_type = Mime::TEXT
- self.response_body = "Simon says: #{says}"
-end
class RenderOtherTest < ActionController::TestCase
class TestController < ActionController::Base
@@ -15,7 +11,14 @@ class RenderOtherTest < ActionController::TestCase
tests TestController
def test_using_custom_render_option
+ ActionController.add_renderer :simon do |says, options|
+ self.content_type = Mime::TEXT
+ self.response_body = "Simon says: #{says}"
+ end
+
get :render_simon_says
assert_equal "Simon says: foo", @response.body
+ ensure
+ ActionController.remove_renderer :simon
end
end
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index aee139b95e..2c833aa2e5 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -32,14 +32,18 @@ end
class SendFileTest < ActionController::TestCase
include TestFileUtils
- Mime::Type.register "image/png", :png unless defined? Mime::PNG
-
def setup
+ @mime_type_defined = defined? Mime::PNG
+ Mime::Type.register "image/png", :png unless @mime_type_defined
@controller = SendFileController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
+ teardown do
+ Mime::Type.unregister :png unless @mime_type_defined
+ end
+
def test_file_nostream
@controller.options = { :stream => false }
response = nil
diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb
index 86232f9d3f..a62617ab47 100644
--- a/activerecord/lib/active_record/connection_adapters/column.rb
+++ b/activerecord/lib/active_record/connection_adapters/column.rb
@@ -14,12 +14,9 @@ module ActiveRecord
end
attr_reader :name, :default, :cast_type, :null, :sql_type, :default_function
- attr_accessor :coder
-
- alias :encoded? :coder
delegate :type, :precision, :scale, :limit, :klass, :text?, :number?, :binary?,
- :type_cast_for_write, :type_cast_for_database, to: :cast_type
+ :type_cast, :type_cast_for_write, :type_cast_for_database, to: :cast_type
# Instantiates a new column in the table.
#
@@ -37,22 +34,12 @@ module ActiveRecord
@null = null
@default = extract_default(default)
@default_function = nil
- @coder = nil
end
def has_default?
!default.nil?
end
- # Casts value to an appropriate instance.
- def type_cast(value)
- if encoded?
- coder.load(value)
- else
- cast_type.type_cast(value)
- end
- end
-
# Returns the human name of the column name.
#
# ===== Examples
diff --git a/activerecord/test/cases/column_definition_test.rb b/activerecord/test/cases/column_definition_test.rb
index 45e48900ee..bcfd66b4bf 100644
--- a/activerecord/test/cases/column_definition_test.rb
+++ b/activerecord/test/cases/column_definition_test.rb
@@ -11,26 +11,6 @@ module ActiveRecord
@viz = @adapter.schema_creation
end
- def test_can_set_coder
- column = Column.new("title", nil, Type::String.new, "varchar(20)")
- column.coder = YAML
- assert_equal YAML, column.coder
- end
-
- def test_encoded?
- column = Column.new("title", nil, Type::String.new, "varchar(20)")
- assert !column.encoded?
-
- column.coder = YAML
- assert column.encoded?
- end
-
- def test_type_case_coded_column
- column = Column.new("title", nil, Type::String.new, "varchar(20)")
- column.coder = YAML
- assert_equal "hello", column.type_cast("--- hello")
- end
-
# Avoid column definitions in create table statements like:
# `title` varchar(255) DEFAULT NULL
def test_should_not_include_default_clause_when_default_is_null