From bb530923bcd5c643f9bfca8e36cd3fa36365032d Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 19 Jul 2009 21:53:02 +0900 Subject: Simplify required "ActionView compliant" API --- actionpack/test/abstract_unit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 30e795a7a2..292d138fbd 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -97,7 +97,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) -- cgit v1.2.3 From 0f2914be405410e824b40dcff28e5dfa541bdb2a Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 19 Jul 2009 22:12:15 +0900 Subject: Separate ActionView::Context so something else can easily be made into an AV context --- actionpack/test/template/compiled_templates_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/test') 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 -- cgit v1.2.3 From b20d68446d2fe98d129385a17a3a4cdacd4b5025 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sun, 19 Jul 2009 22:30:00 +0900 Subject: Move default_form_builder to ActionView so it'll work in environments not using ActionView::Base --- actionpack/test/template/form_helper_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 515f73c339..bc24ea3556 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1024,8 +1024,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 +1042,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 -- cgit v1.2.3 From 5ffaaa71d149c9807260c950c9a61d01fe734827 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 20 Jul 2009 00:27:04 +0900 Subject: Define ActiveModel API Compliance - Define to_model on AR - Define to_model on ActiveModel::APICompliant - Update test fixtures to be API Compliant - Start using to_model in AP --- actionpack/test/abstract_unit.rb | 1 + .../render_partial_with_record_identification_test.rb | 2 +- actionpack/test/controller/record_identifier_test.rb | 2 +- actionpack/test/controller/redirect_test.rb | 2 +- actionpack/test/lib/controller/fake_models.rb | 4 ++-- actionpack/test/template/active_record_helper_test.rb | 16 +++++++--------- actionpack/test/template/atom_feed_helper_test.rb | 9 +++++++-- actionpack/test/template/prototype_helper_test.rb | 8 +++++--- actionpack/test/template/record_tag_helper_test.rb | 2 +- actionpack/test/template/test_test.rb | 2 +- actionpack/test/template/url_helper_test.rb | 4 ++-- 11 files changed, 29 insertions(+), 23 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 292d138fbd..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 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_test.rb b/actionpack/test/template/active_record_helper_test.rb index e1be048838..950072e45b 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -4,19 +4,17 @@ class ActiveRecordHelperTest < ActionView::TestCase tests ActionView::Helpers::ActiveRecordHelper 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/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..861958ffa9 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' class Post - extend ActiveModel::Naming + extend ActiveModel::APICompliant def id 45 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 'David', 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) -- cgit v1.2.3 From 13e18dd94000cef2b2058b96d62de16b7d3a2200 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 20 Jul 2009 00:58:59 +0900 Subject: Update some tests and add a to_model to form helpers --- actionpack/test/template/active_record_helper_i18n_test.rb | 1 + actionpack/test/template/form_helper_test.rb | 10 +++++----- actionpack/test/template/record_tag_helper_test.rb | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/active_record_helper_i18n_test.rb b/actionpack/test/template/active_record_helper_i18n_test.rb index 9d04c882c8..7dda9fe275 100644 --- a/actionpack/test/template/active_record_helper_i18n_test.rb +++ b/actionpack/test/template/active_record_helper_i18n_test.rb @@ -1,6 +1,7 @@ require 'abstract_unit' class ActiveRecordHelperI18nTest < Test::Unit::TestCase + include ActionView::Context include ActionView::Helpers::ActiveRecordHelper attr_reader :request diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index bc24ea3556..431ac35e54 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 diff --git a/actionpack/test/template/record_tag_helper_test.rb b/actionpack/test/template/record_tag_helper_test.rb index 861958ffa9..bae26f555d 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -6,7 +6,7 @@ class Post 45 end def body - "What a wonderful world!" + super || "What a wonderful world!" end end -- cgit v1.2.3 From b00cac4adc0413418ffd2c59b52c8f64acff406b Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 20 Jul 2009 01:22:24 +0900 Subject: Finish convert_to_object updates --- actionpack/test/template/form_helper_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 431ac35e54..883afd985b 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -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 -- cgit v1.2.3 From f2f5cdc8bcd9df3a297ea02b80dbdb21790de732 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 20 Jul 2009 01:28:15 +0900 Subject: Rename ActiveRecordHelper to ActiveModelHelper --- actionpack/test/template/active_record_helper_i18n_test.rb | 2 +- actionpack/test/template/active_record_helper_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/active_record_helper_i18n_test.rb b/actionpack/test/template/active_record_helper_i18n_test.rb index 7dda9fe275..63032e4e5c 100644 --- a/actionpack/test/template/active_record_helper_i18n_test.rb +++ b/actionpack/test/template/active_record_helper_i18n_test.rb @@ -2,7 +2,7 @@ require 'abstract_unit' class ActiveRecordHelperI18nTest < Test::Unit::TestCase include ActionView::Context - include ActionView::Helpers::ActiveRecordHelper + 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 950072e45b..c1bbdae8fb 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -1,7 +1,7 @@ require 'abstract_unit' class ActiveRecordHelperTest < ActionView::TestCase - tests ActionView::Helpers::ActiveRecordHelper + tests ActionView::Helpers::ActiveModelHelper silence_warnings do class Post < Struct.new(:title, :author_name, :body, :secret, :written_on) -- cgit v1.2.3 From d80316ad3269e11c2be9be0727ae518f5e427d24 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Mon, 20 Jul 2009 16:13:21 -0700 Subject: First effort at new Ajax helpers --- actionpack/test/javascript/ajax_test.rb | 115 ++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 actionpack/test/javascript/ajax_test.rb (limited to 'actionpack/test') diff --git a/actionpack/test/javascript/ajax_test.rb b/actionpack/test/javascript/ajax_test.rb new file mode 100644 index 0000000000..b67a91dad3 --- /dev/null +++ b/actionpack/test/javascript/ajax_test.rb @@ -0,0 +1,115 @@ +require "abstract_unit" + +class AjaxTestCase < ActiveSupport::TestCase + include ActionView::Helpers::AjaxHelper + include ActionView::Helpers::TagHelper + + def assert_html(html, matches) + matches.each do |match| + assert_match Regexp.new(Regexp.escape(match)), html + end + end + + def self.assert_callbacks_work(&blk) + define_method(:assert_callbacks_work, &blk) + + [:complete, :failure, :success, :interactive, :loaded, :loading, 404].each do |callback| + test "#{callback} callback" do + markup = assert_callbacks_work(callback) + assert_html markup, %W(data-#{callback}-code="undoRequestCompleted\(request\)") + end + end + end +end + +class LinkToRemoteTest < AjaxTestCase + def url_for(hash) + "/blog/destroy/4" + end + + def link(options = {}) + link_to_remote("Delete this post", "/blog/destroy/3", options) + end + + test "with no update" do + assert_html link, %w(href="/blog/destroy/3" Delete\ this\ post data-remote="true") + end + + test "basic" do + assert_html link(:update => "#posts"), + %w(data-update-success="#posts") + end + + test "using a url hash" do + link = link_to_remote("Delete this post", {:controller => :blog}, :update => "#posts") + assert_html link, %w(href="/blog/destroy/4" data-update-success="#posts") + end + + test "with :html options" do + expected = %{Delete this post} + assert_equal expected, link(:update => "#posts", :html => {"data-custom" => "me"}) + end + + test "with a hash for :update" do + link = link(:update => {:success => "#posts", :failure => "#error"}) + assert_match /data-update-success="#posts"/, link + assert_match /data-update-failure="#error"/, link + end + + test "with positional parameters" do + link = link(:position => :top, :update => "#posts") + assert_match /data\-update\-position="top"/, link + end + + test "with an optional method" do + link = link(:method => "delete") + assert_match /data-method="delete"/, link + end + + class LegacyLinkToRemoteTest < AjaxTestCase + include ActionView::Helpers::AjaxHelper::Rails2Compatibility + + def link(options) + link_to_remote("Delete this post", "/blog/destroy/3", options) + end + + test "basic link_to_remote with :url =>" do + expected = %{Delete this post} + assert_equal expected, + link_to_remote("Delete this post", :url => "/blog/destroy/3", :update => "#posts") + end + + assert_callbacks_work do |callback| + link(callback => "undoRequestCompleted(request)") + end + end +end + +class ButtonToRemoteTest < AjaxTestCase + def button(options, html = {}) + button_to_remote("Remote outpost", options, html) + end + + def url_for(*) + "/whatnot" + end + + class StandardTest < ButtonToRemoteTest + test "basic" do + button = button({:url => {:action => "whatnot"}}, {:class => "fine"}) + [/input/, /class="fine"/, /type="button"/, /value="Remote outpost"/, + /data-url="\/whatnot"/].each do |match| + assert_match match, button + end + end + end + + class LegacyButtonToRemoteTest < ButtonToRemoteTest + include ActionView::Helpers::AjaxHelper::Rails2Compatibility + + assert_callbacks_work do |callback| + button(callback => "undoRequestCompleted(request)") + end + end + +end \ No newline at end of file -- cgit v1.2.3 From 92c00d75869b173f44ff9d68f219a99e6dc3bd82 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 21 Jul 2009 00:51:57 -0500 Subject: AMo conversion helper --- .../render_partial_with_record_identification_test.rb | 3 ++- actionpack/test/controller/record_identifier_test.rb | 3 ++- actionpack/test/controller/redirect_test.rb | 3 ++- actionpack/test/lib/controller/fake_models.rb | 6 ++++-- actionpack/test/template/active_record_helper_test.rb | 9 ++++++--- actionpack/test/template/atom_feed_helper_test.rb | 3 ++- actionpack/test/template/form_helper_test.rb | 15 ++++++++++----- actionpack/test/template/prototype_helper_test.rb | 12 ++++++++---- actionpack/test/template/record_tag_helper_test.rb | 3 ++- actionpack/test/template/test_test.rb | 2 +- actionpack/test/template/url_helper_test.rb | 6 ++++-- 11 files changed, 43 insertions(+), 22 deletions(-) (limited to 'actionpack/test') 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 0122bc7d8f..df50c3dc6f 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,8 @@ class RenderPartialWithRecordIdentificationController < ActionController::Base end class Game < Struct.new(:name, :id) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion 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 10f51639cf..44e49ed3f8 100644 --- a/actionpack/test/controller/record_identifier_test.rb +++ b/actionpack/test/controller/record_identifier_test.rb @@ -1,7 +1,8 @@ require 'abstract_unit' class Comment - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion 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 a71c39e504..b3321303c0 100644 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -4,7 +4,8 @@ class WorkshopsController < ActionController::Base end class Workshop - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion 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 07f01e1c47..c6726432ec 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -1,7 +1,8 @@ require "active_model" class Customer < Struct.new(:name, :id) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion def to_param id.to_s @@ -16,7 +17,8 @@ end module Quiz class Question < Struct.new(:name, :id) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion def to_param id.to_s diff --git a/actionpack/test/template/active_record_helper_test.rb b/actionpack/test/template/active_record_helper_test.rb index c1bbdae8fb..b07ce6cf5d 100644 --- a/actionpack/test/template/active_record_helper_test.rb +++ b/actionpack/test/template/active_record_helper_test.rb @@ -5,15 +5,18 @@ class ActiveRecordHelperTest < ActionView::TestCase silence_warnings do class Post < Struct.new(:title, :author_name, :body, :secret, :written_on) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion end class User < Struct.new(:email) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion end class Column < Struct.new(:type, :name, :human_name) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion end end diff --git a/actionpack/test/template/atom_feed_helper_test.rb b/actionpack/test/template/atom_feed_helper_test.rb index 89ff01ab0e..3acaecd142 100644 --- a/actionpack/test/template/atom_feed_helper_test.rb +++ b/actionpack/test/template/atom_feed_helper_test.rb @@ -1,7 +1,8 @@ require 'abstract_unit' class Scroll < Struct.new(:id, :to_param, :title, :body, :updated_at, :created_at) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion def new_record? true diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 883afd985b..99160dd8b1 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -2,7 +2,8 @@ require 'abstract_unit' silence_warnings do class Post < Struct.new(:title, :author_name, :body, :secret, :written_on, :cost) - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion alias_method :secret?, :secret @@ -25,7 +26,8 @@ silence_warnings do end class Comment - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_reader :id attr_reader :post_id @@ -43,7 +45,8 @@ silence_warnings do end class Tag - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_reader :id attr_reader :post_id @@ -61,7 +64,8 @@ silence_warnings do end class CommentRelevance - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_reader :id attr_reader :comment_id @@ -75,7 +79,8 @@ silence_warnings do end class TagRelevance - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_reader :id attr_reader :tag_id diff --git a/actionpack/test/template/prototype_helper_test.rb b/actionpack/test/template/prototype_helper_test.rb index 301a110076..acbf311212 100644 --- a/actionpack/test/template/prototype_helper_test.rb +++ b/actionpack/test/template/prototype_helper_test.rb @@ -1,11 +1,14 @@ require 'abstract_unit' require 'active_model' -Bunny = Struct.new(:Bunny, :id) -Bunny.extend ActiveModel::APICompliant +class Bunny < Struct.new(:Bunny, :id) + extend ActiveModel::Naming + include ActiveModel::Conversion +end class Author - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_reader :id def save; @id = 1 end @@ -16,7 +19,8 @@ class Author end class Article - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion 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 bae26f555d..4144fea678 100644 --- a/actionpack/test/template/record_tag_helper_test.rb +++ b/actionpack/test/template/record_tag_helper_test.rb @@ -1,7 +1,8 @@ require 'abstract_unit' class Post - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion def id 45 end diff --git a/actionpack/test/template/test_test.rb b/actionpack/test/template/test_test.rb index 98307fbae4..f32d0b3d42 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::APICompliant + person.class.extend ActiveModel::Naming expects(:mocha_mock_path).with(person).returns("/people/1") assert_equal 'David', link_to_person(person) end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 4569689534..9eeb26831c 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -494,7 +494,8 @@ class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase end class Workshop - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_accessor :id, :new_record def initialize(id, new_record) @@ -511,7 +512,8 @@ class Workshop end class Session - extend ActiveModel::APICompliant + extend ActiveModel::Naming + include ActiveModel::Conversion attr_accessor :id, :workshop_id, :new_record def initialize(id, new_record) -- cgit v1.2.3