rails-forward_compatible_controller_tests 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15eee973b94c06ab667f15a6ccd3cc8bda5ddd27
4
- data.tar.gz: 4fda6dba6db8862a7fc106331e6c2eda507e9382
3
+ metadata.gz: 790f7fe3a2d9e11bbf7ecbe22e5675e7c3bb00c1
4
+ data.tar.gz: 252a93b427e536a95ed434d8e0508bcc356f9d51
5
5
  SHA512:
6
- metadata.gz: b450d076c3710c659503e630d2cdf006dc3c059688c74aaa8a17180fc4331ca96665c64ab1d055d1bda22cee934d924731bfc6bb7698ecd80453232d7e55acf5
7
- data.tar.gz: 7e4871a49a73cbd4ee2816565840bfa2a45fb1fce735b6f2ba6c93ed35650c8605998e6cabf16e765f374e4183dac3a6cfd1391bc493dc62c88f49aa47f30295
6
+ metadata.gz: d869af165f25668b7cab965247f7a663447e2ea80847f2734f1b429f1c26c1fa9eac33c7dda87ff8796bb314dafd800b4f100e83865c4e27c33ca3915f23a228
7
+ data.tar.gz: 4e1e23cf89aae2969a451af71b566685e6f8f25fe781d04898860b9cbf0d1c5ad80b2de5cdee9e64cf414cf5c344c76732e202059865afead290df5c53834f25
@@ -45,8 +45,11 @@ module Rails
45
45
 
46
46
  %i[get post patch put head delete].each do |method|
47
47
  define_method(method) do |action, *args|
48
+ controller_test = self.class < ActionController::TestCase
48
49
  request_params = args[0]&.dup
49
- request_headers = args[1]&.dup
50
+ request_session = args[1]&.dup if controller_test
51
+ request_headers = args[1]&.dup unless controller_test
52
+ request_flash = args[2]&.dup if controller_test
50
53
 
51
54
  old_method = false
52
55
  xhr = false
@@ -54,27 +57,54 @@ module Rails
54
57
  xhr = request_params.delete(:xhr)
55
58
  if request_params[:params].is_a?(Hash)
56
59
  request_params.merge!(request_params.delete(:params) || {})
57
- request_headers = request_params.delete(:headers) || request_headers
60
+ request_session = request_params.delete(:session) || request_session if controller_test
61
+ request_headers = request_params.delete(:headers) || request_headers unless controller_test
62
+ request_flash = request_params.delete(:flash) || request_flash if controller_test
58
63
  elsif request_params.key?(:params)
59
- request_headers = request_params[:headers]
64
+ request_flash = request_params[:flash] if controller_test
65
+ request_session = request_params[:session] if controller_test
66
+ request_headers = request_params[:headers] unless controller_test
60
67
  request_params = request_params[:params]
61
- elsif request_params.key?(:headers)
68
+ elsif request_params.key?(:headers) && !controller_test
69
+ request_flash = nil
70
+ request_session = nil
62
71
  request_headers = request_params[:headers]
63
72
  request_params = nil
73
+ elsif request_params.key?(:session) && controller_test
74
+ request_flash = request_params[:flash]
75
+ request_session = request_params[:session]
76
+ request_headers = nil
77
+ request_params = nil
78
+ elsif request_params.key?(:flash) && controller_test
79
+ request_flash = request_params[:flash]
80
+ request_session = nil
81
+ request_headers = nil
82
+ request_params = nil
64
83
  elsif !xhr
65
84
  old_method = true
66
85
  end
67
- elsif request_headers.is_a?(Hash)
86
+ elsif request_headers.is_a?(Hash) || request_session.is_a?(Hash) ||
87
+ request_flash.is_a?(Hash)
68
88
  old_method = true
69
89
  end
70
90
 
71
91
  raise Exception, ERROR_MESSAGE if ForwardCompatibleControllerTests.raise_exception? && old_method
72
92
  ActiveSupport::Deprecation.warn(ERROR_MESSAGE) if ForwardCompatibleControllerTests.deprecated? && old_method
73
93
 
74
- ForwardCompatibleControllerTests.send(:with_ignore) do
75
- return xhr(method, action, request_params, request_headers)
76
- end if xhr
77
- super(action, request_params, request_headers)
94
+ if xhr
95
+ ForwardCompatibleControllerTests.send(:with_ignore) do
96
+ if controller_test
97
+ return xhr(method, action, request_params, request_session, request_flash)
98
+ else
99
+ return xhr(method, action, request_params, request_headers)
100
+ end
101
+ end
102
+ end
103
+ if controller_test
104
+ super(action, request_params, request_session, request_flash)
105
+ else
106
+ super(action, request_params, request_headers)
107
+ end
78
108
  end
79
109
  end
80
110
 
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module ForwardCompatibleControllerTests
3
- VERSION = "2.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-forward_compatible_controller_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-30 00:00:00.000000000 Z
11
+ date: 2018-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler