controller-testing-kwargs 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e9f386c0399326befa5c12f08f2749bd6410e87
4
- data.tar.gz: a2918efa20ef69bf9df070c0e35f3ee09bca200a
3
+ metadata.gz: 1f1e9fa13a7f2d234aa3450dc9a87af826b91d62
4
+ data.tar.gz: 454e3ca38063041226b0162f16525ffacbd3b9ad
5
5
  SHA512:
6
- metadata.gz: 0755f8476ecbaf759db162fd564f25849ffeb95f00e3b8913e16dd280573538360b9e3f7dd5a000b712b4bbf4fd99c4c1dacf46f014d23ec10f53091089c4308
7
- data.tar.gz: 197a1d0519e2512de82a26f0394af4022ff343fe8f25490f0acbfd2a8a962627c5ecf242db8d59d907024cfcac0029c2e2cf0316bea45f91032d5b2c34bc8bdb
6
+ metadata.gz: 82c241dec360d3b6d2f2b2c7c8065311c234feb9f7c28ebd61225b927b602489f87c154db98c5f97ffd7b8c29ad4e627516c6a9b6d4dc2c3fa0c382f71e1f1af
7
+ data.tar.gz: b7fffdc81950c4251136e976c83e646d1ecdae19ea487b5ac4c6468f43c8b79c66350710e49afb2874ce3f3e44991e2a6964a196daa21adc84de4be38c1f9480
@@ -7,28 +7,40 @@ module Controller
7
7
  ERROR_MESSAGE = 'Please use Rails 5 syntax. See: https://github.com/appfolio/controller-testing-kwargs'
8
8
 
9
9
  class <<self
10
- @on_old = :deprecate
10
+ @action = :deprecation_warning
11
11
 
12
- attr_reader :on_old
12
+ attr_reader :action
13
13
 
14
14
  def deprecate
15
- @on_old = :warn
15
+ @action = :deprecation_warning
16
16
  end
17
17
 
18
18
  def deprecated?
19
- @on_old == :warn
19
+ @action == :deprecation_warning
20
20
  end
21
21
 
22
22
  def ignore
23
- @on_old = :ignore
23
+ @action = nil
24
24
  end
25
25
 
26
26
  def raise_exception
27
- @on_old = :raise
27
+ @action = :raise_exceptioon
28
28
  end
29
29
 
30
30
  def raise_exception?
31
- @on_old == :raise
31
+ @action == :raise_exceptioon
32
+ end
33
+
34
+ private
35
+
36
+ def with_ignore
37
+ previous_action = @action
38
+ @action = nil
39
+ begin
40
+ yield
41
+ ensure
42
+ @action = previous_action
43
+ end
32
44
  end
33
45
  end
34
46
 
@@ -60,15 +72,9 @@ module Controller
60
72
  raise Exception, ERROR_MESSAGE if Controller::Testing::Kwargs.raise_exception? && old_method
61
73
  ActiveSupport::Deprecation.warn(ERROR_MESSAGE) if Controller::Testing::Kwargs.deprecated? && old_method
62
74
 
63
- if xhr
64
- previous_value = Controller::Testing::Kwargs.on_old
65
- Controller::Testing::Kwargs.ignore
66
- begin
67
- return xhr(method, action, request_params, request_headers)
68
- ensure
69
- Controller::Testing::Kwargs.instance_variable_set(:@on_old, previous_value)
70
- end
71
- end
75
+ Controller::Testing::Kwargs.send(:with_ignore) do
76
+ return xhr(method, action, request_params, request_headers)
77
+ end if xhr
72
78
  super(action, request_params, request_headers)
73
79
  end
74
80
  end
@@ -1,7 +1,7 @@
1
1
  module Controller
2
2
  module Testing
3
3
  module Kwargs
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controller-testing-kwargs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Shaffer