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.3.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.



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

def old_syntax_strategy
  @old_syntax_strategy
end

Class Method Details

.deprecateObject



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

def deprecate
  @old_syntax_strategy = :deprecation_warning
end

.deprecated?Boolean

Returns:

  • (Boolean)


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

def deprecated?
  @old_syntax_strategy == :deprecation_warning
end

.ignoreObject



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

def ignore
  @old_syntax_strategy = nil
end

.raise_exceptionObject



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

def raise_exception
  @old_syntax_strategy = :raise_exception
end

.raise_exception?Boolean

Returns:

  • (Boolean)


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

def raise_exception?
  @old_syntax_strategy == :raise_exception
end

Instance Method Details

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

Raises:

  • (Exception)


115
116
117
118
119
# File 'lib/rails/forward_compatible_controller_tests.rb', line 115

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