Skip to content

Commit 13b1271

Browse files
author
Luca Guidi
committed
Deprecated globalize? in favor of in_place_translations?
1 parent af269d1 commit 13b1271

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

Diff for: app/helpers/click_to_globalize_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module ClickToGlobalizeHelper
33

44
# Render +app/views/shared/_click_to_globalize.html.erb+.
55
def click_to_globalize
6-
render :file => @@click_partial if globalize?
6+
render :file => @@click_partial if in_place_translations?
77
end
88

99
# Get form_authenticity_token if the application is protected from forgery.

Diff for: lib/click_to_globalize.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,37 @@ module Controller
7878
def self.included(recipient)
7979
recipient.send :include, InstanceMethods
8080
recipient.class_eval do
81-
helper_method :globalize?
81+
helper_method :in_place_translations?
8282
end
8383
end
8484

8585
module InstanceMethods
86+
include ActiveSupport::Deprecation
87+
88+
# This is the <b>on/off</b> switch for the Click to Globalize features.
89+
# Override this method in your controllers for custom conditions.
90+
#
91+
# Example:
92+
#
93+
# def in_place_translations?
94+
# current_user.admin?
95+
# end
96+
def in_place_translations?
97+
true
98+
end
99+
86100
# This is the <b>on/off</b> switch for the Click to Globalize features.
87101
# Override this method in your controllers for custom conditions.
88102
#
103+
# NOTICE: this method has been deprecated in favor of <tt>in_place_translations?</tt>
104+
#
89105
# Example:
90106
#
91107
# def globalize?
92108
# current_user.admin?
93109
# end
94110
def globalize?
111+
::ActiveSupport::Deprecation.warn("You should use in_place_translations?", caller)
95112
true
96113
end
97114
end

Diff for: test/functional/translations_controller_test.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class TranslationsControllerTest < ActionController::TestCase
1010
test "should have translation mode enabled by default" do
11-
assert @controller.globalize?
11+
assert @controller.in_place_translations?
1212
end
1313

1414
test "routing" do
@@ -50,7 +50,11 @@ class AnApplicationControllerTest < ActionController::TestCase
5050
setup :load_translations
5151

5252
test "should have translation mode enabled by default" do
53-
assert @controller.globalize?
53+
assert @controller.in_place_translations?
54+
end
55+
56+
test "globalize? deprecation" do
57+
assert_deprecated("You should use in_place_translations?"){ @controller.globalize? }
5458
end
5559

5660
test "should return translated contents" do
@@ -63,7 +67,7 @@ class AnApplicationControllerTest < ActionController::TestCase
6367
end
6468

6569
test "should always render the action" do
66-
@controller.stubs(:globalize?).returns false
70+
@controller.stubs(:in_place_translations?).returns false
6771

6872
get :index, params
6973
assert_response :success

Diff for: test/test_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def render(options = nil, extra_options = {}, &block)
2929
ActionView::Base.new.render options, extra_options, &block
3030
end
3131

32-
def globalize?
33-
ApplicationController.new.globalize?
32+
def in_place_translations?
33+
ApplicationController.new.in_place_translations?
3434
end
3535
end

0 commit comments

Comments
 (0)