diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:36:34 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:36:34 +0200 |
commit | 63fff600accb41b56a3e6ac403d9b1732de3086d (patch) | |
tree | eabc84f16214eade7d44386de14a23415a9c3e3d /actionview/test/activerecord | |
parent | 5b6eb1d58b48fada298215b2cccda89f993890c3 (diff) | |
download | rails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.gz rails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.bz2 rails-63fff600accb41b56a3e6ac403d9b1732de3086d.zip |
modernizes hash syntax in actionview
Diffstat (limited to 'actionview/test/activerecord')
4 files changed, 37 insertions, 37 deletions
diff --git a/actionview/test/activerecord/controller_runtime_test.rb b/actionview/test/activerecord/controller_runtime_test.rb index e1946194b9..590559f592 100644 --- a/actionview/test/activerecord/controller_runtime_test.rb +++ b/actionview/test/activerecord/controller_runtime_test.rb @@ -9,11 +9,11 @@ ActionController::Base.include(ActiveRecord::Railties::ControllerRuntime) class ControllerRuntimeLogSubscriberTest < ActionController::TestCase class LogSubscriberController < ActionController::Base def show - render :inline => "<%= Project.all %>" + render inline: "<%= Project.all %>" end def zero - render :inline => "Zero DB runtime" + render inline: "Zero DB runtime" end def create @@ -24,11 +24,11 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase def redirect Project.all - redirect_to :action => "show" + redirect_to action: "show" end def db_after_render - render :inline => "Hello world" + render inline: "Hello world" Project.all ActiveRecord::LogSubscriber.runtime += 100 end diff --git a/actionview/test/activerecord/form_helper_activerecord_test.rb b/actionview/test/activerecord/form_helper_activerecord_test.rb index 21c25ddbec..8c83c536c1 100644 --- a/actionview/test/activerecord/form_helper_activerecord_test.rb +++ b/actionview/test/activerecord/form_helper_activerecord_test.rb @@ -39,12 +39,12 @@ class FormHelperActiveRecordTest < ActionView::TestCase def test_nested_fields_for_with_child_index_option_override_on_a_nested_attributes_collection_association form_for(@developer) do |f| - concat f.fields_for(:projects, @developer.projects.first, :child_index => "abc") { |cf| + concat f.fields_for(:projects, @developer.projects.first, child_index: "abc") { |cf| concat cf.text_field(:name) } end - expected = whole_form("/developers/123", "edit_developer_123", "edit_developer", :method => "patch") do + expected = whole_form("/developers/123", "edit_developer_123", "edit_developer", method: "patch") do '<input id="developer_projects_attributes_abc_name" name="developer[projects_attributes][abc][name]" type="text" value="project #321" />' + '<input id="developer_projects_attributes_abc_id" name="developer[projects_attributes][abc][id]" type="hidden" value="321" />' end diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb index e72488e42e..1aac4b9c56 100644 --- a/actionview/test/activerecord/polymorphic_routes_test.rb +++ b/actionview/test/activerecord/polymorphic_routes_test.rb @@ -95,7 +95,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_string_with_options with_test_routes do - assert_equal "http://example.com/projects?id=10", polymorphic_url("projects", :id => 10) + assert_equal "http://example.com/projects?id=10", polymorphic_url("projects", id: 10) end end @@ -107,7 +107,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_symbol_with_options with_test_routes do - assert_equal "http://example.com/projects?id=10", polymorphic_url(:projects, :id => 10) + assert_equal "http://example.com/projects?id=10", polymorphic_url(:projects, id: 10) end end @@ -179,7 +179,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_nil_id with_test_routes do exception = assert_raise ArgumentError do - polymorphic_url({ :id => nil }) + polymorphic_url({ id: nil }) end assert_equal "Nil location provided. Can't build URI.", exception.message end @@ -233,8 +233,8 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_class_with_options with_test_routes do - assert_equal "http://example.com/projects?foo=bar", polymorphic_url(@project.class, { :foo => :bar }) - assert_equal "/projects?foo=bar", polymorphic_path(@project.class, { :foo => :bar }) + assert_equal "http://example.com/projects?foo=bar", polymorphic_url(@project.class, { foo: :bar }) + assert_equal "/projects?foo=bar", polymorphic_path(@project.class, { foo: :bar }) end end @@ -274,7 +274,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_record_and_action with_test_routes do - assert_equal "http://example.com/projects/new", polymorphic_url(@project, :action => "new") + assert_equal "http://example.com/projects/new", polymorphic_url(@project, action: "new") end end @@ -303,35 +303,35 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_url_helper_prefixed_with_edit_with_url_options with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}/edit?param1=10", edit_polymorphic_url(@project, :param1 => "10") + assert_equal "http://example.com/projects/#{@project.id}/edit?param1=10", edit_polymorphic_url(@project, param1: "10") end end def test_url_helper_with_url_options with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}?param1=10", polymorphic_url(@project, :param1 => "10") + assert_equal "http://example.com/projects/#{@project.id}?param1=10", polymorphic_url(@project, param1: "10") end end def test_format_option with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(@project, :format => :pdf) + assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(@project, format: :pdf) end end def test_format_option_with_url_options with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf?param1=10", polymorphic_url(@project, :format => :pdf, :param1 => "10") + assert_equal "http://example.com/projects/#{@project.id}.pdf?param1=10", polymorphic_url(@project, format: :pdf, param1: "10") end end def test_id_and_format_option with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(:id => @project, :format => :pdf) + assert_equal "http://example.com/projects/#{@project.id}.pdf", polymorphic_url(id: @project, format: :pdf) end end @@ -373,7 +373,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_new_with_array_and_namespace with_admin_test_routes do - assert_equal "http://example.com/admin/projects/new", polymorphic_url([:admin, @project], :action => "new") + assert_equal "http://example.com/admin/projects/new", polymorphic_url([:admin, @project], action: "new") end end @@ -426,7 +426,7 @@ class PolymorphicRoutesTest < ActionController::TestCase with_test_routes do @project.save @task.save - assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}.pdf", polymorphic_url([@project, :bid, @task], :format => :pdf) + assert_equal "http://example.com/projects/#{@project.id}/bid/tasks/#{@task.id}.pdf", polymorphic_url([@project, :bid, @task], format: :pdf) end end @@ -474,13 +474,13 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_hash with_test_routes do @project.save - assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(:id => @project) + assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(id: @project) end end def test_polymorphic_path_accepts_options with_test_routes do - assert_equal "/projects/new", polymorphic_path(@project, :action => "new") + assert_equal "/projects/new", polymorphic_path(@project, action: "new") end end @@ -527,7 +527,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_with_irregular_plural_record_and_action with_test_routes do - assert_equal "http://example.com/taxes/new", polymorphic_url(@tax, :action => "new") + assert_equal "http://example.com/taxes/new", polymorphic_url(@tax, action: "new") end end @@ -561,7 +561,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def test_new_with_irregular_plural_array_and_namespace with_admin_test_routes do - assert_equal "http://example.com/admin/taxes/new", polymorphic_url([:admin, @tax], :action => "new") + assert_equal "http://example.com/admin/taxes/new", polymorphic_url([:admin, @tax], action: "new") end end @@ -622,7 +622,7 @@ class PolymorphicRoutesTest < ActionController::TestCase def with_namespaced_routes(name) with_routing do |set| set.draw do - scope(:module => name) do + scope(module: name) do resources :blogs do resources :posts do resources :faxes diff --git a/actionview/test/activerecord/render_partial_with_record_identification_test.rb b/actionview/test/activerecord/render_partial_with_record_identification_test.rb index 868238d2cf..55886da30f 100644 --- a/actionview/test/activerecord/render_partial_with_record_identification_test.rb +++ b/actionview/test/activerecord/render_partial_with_record_identification_test.rb @@ -3,46 +3,46 @@ require "active_record_unit" class RenderPartialWithRecordIdentificationController < ActionController::Base def render_with_has_many_and_belongs_to_association @developer = Developer.find(1) - render :partial => @developer.projects + render partial: @developer.projects end def render_with_has_many_association @topic = Topic.find(1) - render :partial => @topic.replies + render partial: @topic.replies end def render_with_scope - render :partial => Reply.base + render partial: Reply.base end def render_with_has_many_through_association @developer = Developer.first - render :partial => @developer.topics + render partial: @developer.topics end def render_with_has_one_association @company = Company.find(1) - render :partial => @company.mascot + render partial: @company.mascot end def render_with_belongs_to_association @reply = Reply.find(1) - render :partial => @reply.topic + render partial: @reply.topic end def render_with_record @developer = Developer.first - render :partial => @developer + render partial: @developer end def render_with_record_collection @developers = Developer.all - render :partial => @developers + render partial: @developers end def render_with_record_collection_and_spacer_template @developer = Developer.find(1) - render :partial => @developer.projects, :spacer_template => "test/partial_only" + render partial: @developer.projects, spacer_template: "test/partial_only" end end @@ -98,22 +98,22 @@ end module Fun class NestedController < ActionController::Base def render_with_record_in_nested_controller - render :partial => Game.new("Pong") + render partial: Game.new("Pong") end def render_with_record_collection_in_nested_controller - render :partial => [ Game.new("Pong"), Game.new("Tank") ] + render partial: [ Game.new("Pong"), Game.new("Tank") ] end end module Serious class NestedDeeperController < ActionController::Base def render_with_record_in_deeper_nested_controller - render :partial => Game.new("Chess") + render partial: Game.new("Chess") end def render_with_record_collection_in_deeper_nested_controller - render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ] + render partial: [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ] end end end |