aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb3
-rw-r--r--actionpack/test/activerecord/render_partial_with_record_identification_test.rb2
-rw-r--r--actionpack/test/controller/record_identifier_test.rb2
-rw-r--r--actionpack/test/controller/redirect_test.rb2
-rw-r--r--actionpack/test/lib/controller/fake_models.rb4
-rw-r--r--actionpack/test/template/active_record_helper_i18n_test.rb3
-rw-r--r--actionpack/test/template/active_record_helper_test.rb18
-rw-r--r--actionpack/test/template/atom_feed_helper_test.rb9
-rw-r--r--actionpack/test/template/compiled_templates_test.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb22
-rw-r--r--actionpack/test/template/prototype_helper_test.rb8
-rw-r--r--actionpack/test/template/record_tag_helper_test.rb4
-rw-r--r--actionpack/test/template/test_test.rb2
-rw-r--r--actionpack/test/template/url_helper_test.rb4
14 files changed, 49 insertions, 36 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 30e795a7a2..6e71b85645 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -20,6 +20,7 @@ require 'action_controller/testing/process'
require 'action_view/test_case'
require 'action_controller/testing/integration'
require 'active_support/dependencies'
+require 'active_model'
$tags[:new_base] = true
@@ -97,7 +98,7 @@ module ActionController
partials = hax[:partials]
if expected_count = options[:count]
found = partials.detect { |p, _| p.identifier.match(expected_partial) }
- actual_count = found.nil? ? 0 : found.second
+ actual_count = found.nil? ? 0 : found[1]
msg = build_message(message,
"expecting ? to be rendered ? time(s) but rendered ? time(s)",
expected_partial, expected_count, actual_count)
diff --git a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
index 2a31f3be44..0122bc7d8f 100644
--- a/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
+++ b/actionpack/test/activerecord/render_partial_with_record_identification_test.rb
@@ -126,7 +126,7 @@ class RenderPartialWithRecordIdentificationController < ActionController::Base
end
class Game < Struct.new(:name, :id)
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
def to_param
id.to_s
end
diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb
index 28bc608d47..10f51639cf 100644
--- a/actionpack/test/controller/record_identifier_test.rb
+++ b/actionpack/test/controller/record_identifier_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
class Comment
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
attr_reader :id
def save; @id = 1 end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index 453a77e7bc..a71c39e504 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -4,7 +4,7 @@ class WorkshopsController < ActionController::Base
end
class Workshop
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
attr_accessor :id, :new_record
def initialize(id, new_record)
diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb
index 9e6f14d373..07f01e1c47 100644
--- a/actionpack/test/lib/controller/fake_models.rb
+++ b/actionpack/test/lib/controller/fake_models.rb
@@ -1,7 +1,7 @@
require "active_model"
class Customer < Struct.new(:name, :id)
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
def to_param
id.to_s
@@ -16,7 +16,7 @@ end
module Quiz
class Question < Struct.new(:name, :id)
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
def to_param
id.to_s
diff --git a/actionpack/test/template/active_record_helper_i18n_test.rb b/actionpack/test/template/active_record_helper_i18n_test.rb
index 9d04c882c8..63032e4e5c 100644
--- a/actionpack/test/template/active_record_helper_i18n_test.rb
+++ b/actionpack/test/template/active_record_helper_i18n_test.rb
@@ -1,7 +1,8 @@
require 'abstract_unit'
class ActiveRecordHelperI18nTest < Test::Unit::TestCase
- include ActionView::Helpers::ActiveRecordHelper
+ include ActionView::Context
+ include ActionView::Helpers::ActiveModelHelper
attr_reader :request
diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb
index e1be048838..c1bbdae8fb 100644
--- a/actionpack/test/template/active_record_helper_test.rb
+++ b/actionpack/test/template/active_record_helper_test.rb
@@ -1,22 +1,20 @@
require 'abstract_unit'
class ActiveRecordHelperTest < ActionView::TestCase
- tests ActionView::Helpers::ActiveRecordHelper
+ tests ActionView::Helpers::ActiveModelHelper
silence_warnings do
- Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on)
- Post.class_eval do
- alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast)
- alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast)
- alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast)
+ class Post < Struct.new(:title, :author_name, :body, :secret, :written_on)
+ extend ActiveModel::APICompliant
end
- User = Struct.new("User", :email)
- User.class_eval do
- alias_method :email_before_type_cast, :email unless respond_to?(:email_before_type_cast)
+ class User < Struct.new(:email)
+ extend ActiveModel::APICompliant
end
- Column = Struct.new("Column", :type, :name, :human_name)
+ class Column < Struct.new(:type, :name, :human_name)
+ extend ActiveModel::APICompliant
+ end
end
class DirtyPost
diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb
index 6f1179f359..89ff01ab0e 100644
--- a/actionpack/test/template/atom_feed_helper_test.rb
+++ b/actionpack/test/template/atom_feed_helper_test.rb
@@ -1,7 +1,12 @@
require 'abstract_unit'
-Scroll = Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at)
-Scroll.extend ActiveModel::Naming
+class Scroll < Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at)
+ extend ActiveModel::APICompliant
+
+ def new_record?
+ true
+ end
+end
class ScrollsController < ActionController::Base
FEEDS = {}
diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb
index 9c268aef27..7734e6da73 100644
--- a/actionpack/test/template/compiled_templates_test.rb
+++ b/actionpack/test/template/compiled_templates_test.rb
@@ -3,7 +3,7 @@ require 'controller/fake_models'
class CompiledTemplatesTest < Test::Unit::TestCase
def setup
- @compiled_templates = ActionView::Base::CompiledTemplates
+ @compiled_templates = ActionView::CompiledTemplates
@compiled_templates.instance_methods.each do |m|
@compiled_templates.send(:remove_method, m) if m =~ /^_render_template_/
end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index 515f73c339..883afd985b 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -1,11 +1,9 @@
require 'abstract_unit'
silence_warnings do
- Post = Struct.new(:title, :author_name, :body, :secret, :written_on, :cost)
- Post.class_eval do
- alias_method :title_before_type_cast, :title unless respond_to?(:title_before_type_cast)
- alias_method :body_before_type_cast, :body unless respond_to?(:body_before_type_cast)
- alias_method :author_name_before_type_cast, :author_name unless respond_to?(:author_name_before_type_cast)
+ class Post < Struct.new(:title, :author_name, :body, :secret, :written_on, :cost)
+ extend ActiveModel::APICompliant
+
alias_method :secret?, :secret
def new_record=(boolean)
@@ -27,6 +25,8 @@ silence_warnings do
end
class Comment
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :post_id
def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
@@ -43,6 +43,8 @@ silence_warnings do
end
class Tag
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :post_id
def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end
@@ -59,6 +61,8 @@ silence_warnings do
end
class CommentRelevance
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :comment_id
def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end
@@ -71,6 +75,8 @@ silence_warnings do
end
class TagRelevance
+ extend ActiveModel::APICompliant
+
attr_reader :id
attr_reader :tag_id
def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end
@@ -1024,8 +1030,8 @@ class FormHelperTest < ActionView::TestCase
end
def test_default_form_builder
- old_default_form_builder, ActionView::Base.default_form_builder =
- ActionView::Base.default_form_builder, LabelledFormBuilder
+ old_default_form_builder, ActionView.default_form_builder =
+ ActionView.default_form_builder, LabelledFormBuilder
form_for(:post, @post) do |f|
concat f.text_field(:title)
@@ -1042,7 +1048,7 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
ensure
- ActionView::Base.default_form_builder = old_default_form_builder
+ ActionView.default_form_builder = old_default_form_builder
end
def test_default_form_builder_with_active_record_helpers
diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb
index a7a1bc99f3..301a110076 100644
--- a/actionpack/test/template/prototype_helper_test.rb
+++ b/actionpack/test/template/prototype_helper_test.rb
@@ -1,10 +1,12 @@
require 'abstract_unit'
+require 'active_model'
Bunny = Struct.new(:Bunny, :id)
-Bunny.extend ActiveModel::Naming
+Bunny.extend ActiveModel::APICompliant
class Author
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
+
attr_reader :id
def save; @id = 1 end
def new_record?; @id.nil? end
@@ -14,7 +16,7 @@ class Author
end
class Article
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
attr_reader :id
attr_reader :author_id
def save; @id = 1; @author_id = 1 end
diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb
index 5b840d123b..bae26f555d 100644
--- a/actionpack/test/template/record_tag_helper_test.rb
+++ b/actionpack/test/template/record_tag_helper_test.rb
@@ -1,12 +1,12 @@
require 'abstract_unit'
class Post
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
def id
45
end
def body
- "What a wonderful world!"
+ super || "What a wonderful world!"
end
end
diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb
index f32d0b3d42..98307fbae4 100644
--- a/actionpack/test/template/test_test.rb
+++ b/actionpack/test/template/test_test.rb
@@ -41,7 +41,7 @@ class PeopleHelperTest < ActionView::TestCase
def test_link_to_person
person = mock(:name => "David")
- person.class.extend ActiveModel::Naming
+ person.class.extend ActiveModel::APICompliant
expects(:mocha_mock_path).with(person).returns("/people/1")
assert_equal '<a href="/people/1">David</a>', link_to_person(person)
end
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index f0364fd660..4569689534 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -494,7 +494,7 @@ class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
end
class Workshop
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
attr_accessor :id, :new_record
def initialize(id, new_record)
@@ -511,7 +511,7 @@ class Workshop
end
class Session
- extend ActiveModel::Naming
+ extend ActiveModel::APICompliant
attr_accessor :id, :workshop_id, :new_record
def initialize(id, new_record)