Module: Rails::ForwardCompatibleControllerTests

Defined in:
lib/rails/forward_compatible_controller_tests.rb,
lib/rails/forward_compatible_controller_tests/version.rb

Constant Summary collapse

ERROR_MESSAGE =
'Please use Rails 5 syntax. See: https://github.com/appfolio/rails-forward_compatible_controller_tests'
VERSION =
"2.4.0"

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.old_syntax_strategyObject (readonly)

Returns the value of attribute old_syntax_strategy.



10
11
12
# File 'lib/rails/forward_compatible_controller_tests.rb', line 10

def old_syntax_strategy
  @old_syntax_strategy
end

Class Method Details

.deprecateObject



12
13
14
# File 'lib/rails/forward_compatible_controller_tests.rb', line 12

def deprecate
  @old_syntax_strategy = :deprecation_warning
end

.deprecated?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/rails/forward_compatible_controller_tests.rb', line 16

def deprecated?
  @old_syntax_strategy == :deprecation_warning
end

.ignoreObject



20
21
22
# File 'lib/rails/forward_compatible_controller_tests.rb', line 20

def ignore
  @old_syntax_strategy = nil
end

.raise_exceptionObject



24
25
26
# File 'lib/rails/forward_compatible_controller_tests.rb', line 24

def raise_exception
  @old_syntax_strategy = :raise_exception
end

.raise_exception?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rails/forward_compatible_controller_tests.rb', line 28

def raise_exception?
  @old_syntax_strategy == :raise_exception
end

Instance Method Details

#xhr(request_method, action, parameters = nil, *args) ⇒ Object

Raises:

  • (Exception)


117
118
119
120
121
# File 'lib/rails/forward_compatible_controller_tests.rb', line 117

def xhr(request_method, action, parameters = nil, *args)
  raise Exception, ERROR_MESSAGE if ForwardCompatibleControllerTests.raise_exception?
  ActiveSupport::Deprecation.warn(ERROR_MESSAGE) if ForwardCompatibleControllerTests.deprecated?
  super(request_method, action, parameters, *args)
end