simple_workflow 1.5.1 → 1.6.0
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 +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +92 -84
- data/Rakefile +4 -2
- data/lib/simple_workflow.rb +2 -0
- data/lib/simple_workflow/controller.rb +5 -3
- data/lib/simple_workflow/detour.rb +3 -2
- data/lib/simple_workflow/helper.rb +2 -0
- data/lib/simple_workflow/middleware.rb +8 -12
- data/lib/simple_workflow/railtie.rb +2 -0
- data/lib/simple_workflow/test_helper.rb +2 -0
- data/lib/simple_workflow/version.rb +3 -1
- data/test/controller_test.rb +7 -3
- data/test/helper_test.rb +12 -6
- data/test/middleware_test.rb +11 -5
- data/test/test_app.rb +2 -0
- data/test/test_helper.rb +2 -0
- metadata +18 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 347f4e6b9181b3bdb9181f847ec3d42aaf25721f
|
|
4
|
+
data.tar.gz: 2343af04ef43d5d4059fbf87b0807aab3d7851a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa32bf4b657422f1809c85cc41edd5d9a216606cc935ae024f366433ad2aaae7bd575b5290d436e317159e146c41a77743c1e92cb8c4c630e09d66c3b9870d93
|
|
7
|
+
data.tar.gz: 1e4e13ef6299d58e656b48202f0111df101681c681c457622cb6554f1a510cf5dc2c75ca7ddbfefc315308fd800499e723561297f4a88570712965d64a41c4a3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,148 +1,156 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple_workflow (1.
|
|
5
|
-
rails (>= 4, < 5.
|
|
4
|
+
simple_workflow (1.6.0)
|
|
5
|
+
rails (>= 4.2, < 5.3)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
actioncable (5.
|
|
11
|
-
actionpack (= 5.
|
|
10
|
+
actioncable (5.2.0)
|
|
11
|
+
actionpack (= 5.2.0)
|
|
12
12
|
nio4r (~> 2.0)
|
|
13
|
-
websocket-driver (
|
|
14
|
-
actionmailer (5.
|
|
15
|
-
actionpack (= 5.
|
|
16
|
-
actionview (= 5.
|
|
17
|
-
activejob (= 5.
|
|
13
|
+
websocket-driver (>= 0.6.1)
|
|
14
|
+
actionmailer (5.2.0)
|
|
15
|
+
actionpack (= 5.2.0)
|
|
16
|
+
actionview (= 5.2.0)
|
|
17
|
+
activejob (= 5.2.0)
|
|
18
18
|
mail (~> 2.5, >= 2.5.4)
|
|
19
19
|
rails-dom-testing (~> 2.0)
|
|
20
|
-
actionpack (5.
|
|
21
|
-
actionview (= 5.
|
|
22
|
-
activesupport (= 5.
|
|
20
|
+
actionpack (5.2.0)
|
|
21
|
+
actionview (= 5.2.0)
|
|
22
|
+
activesupport (= 5.2.0)
|
|
23
23
|
rack (~> 2.0)
|
|
24
|
-
rack-test (
|
|
24
|
+
rack-test (>= 0.6.3)
|
|
25
25
|
rails-dom-testing (~> 2.0)
|
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
27
|
-
actionview (5.
|
|
28
|
-
activesupport (= 5.
|
|
27
|
+
actionview (5.2.0)
|
|
28
|
+
activesupport (= 5.2.0)
|
|
29
29
|
builder (~> 3.1)
|
|
30
30
|
erubi (~> 1.4)
|
|
31
31
|
rails-dom-testing (~> 2.0)
|
|
32
32
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
33
|
-
activejob (5.
|
|
34
|
-
activesupport (= 5.
|
|
33
|
+
activejob (5.2.0)
|
|
34
|
+
activesupport (= 5.2.0)
|
|
35
35
|
globalid (>= 0.3.6)
|
|
36
|
-
activemodel (5.
|
|
37
|
-
activesupport (= 5.
|
|
38
|
-
activerecord (5.
|
|
39
|
-
activemodel (= 5.
|
|
40
|
-
activesupport (= 5.
|
|
41
|
-
arel (
|
|
42
|
-
|
|
36
|
+
activemodel (5.2.0)
|
|
37
|
+
activesupport (= 5.2.0)
|
|
38
|
+
activerecord (5.2.0)
|
|
39
|
+
activemodel (= 5.2.0)
|
|
40
|
+
activesupport (= 5.2.0)
|
|
41
|
+
arel (>= 9.0)
|
|
42
|
+
activestorage (5.2.0)
|
|
43
|
+
actionpack (= 5.2.0)
|
|
44
|
+
activerecord (= 5.2.0)
|
|
45
|
+
marcel (~> 0.3.1)
|
|
46
|
+
activesupport (5.2.0)
|
|
43
47
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
44
|
-
i18n (
|
|
48
|
+
i18n (>= 0.7, < 2)
|
|
45
49
|
minitest (~> 5.1)
|
|
46
50
|
tzinfo (~> 1.1)
|
|
47
51
|
ansi (1.5.0)
|
|
48
|
-
arel (
|
|
49
|
-
ast (2.
|
|
52
|
+
arel (9.0.0)
|
|
53
|
+
ast (2.4.0)
|
|
50
54
|
builder (3.2.3)
|
|
51
55
|
concurrent-ruby (1.0.5)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
crass (1.0.4)
|
|
57
|
+
docile (1.3.0)
|
|
58
|
+
erubi (1.7.1)
|
|
59
|
+
globalid (0.4.1)
|
|
55
60
|
activesupport (>= 4.2.0)
|
|
56
|
-
i18n (0.
|
|
61
|
+
i18n (1.0.1)
|
|
62
|
+
concurrent-ruby (~> 1.0)
|
|
57
63
|
json (2.1.0)
|
|
58
|
-
loofah (2.
|
|
64
|
+
loofah (2.2.2)
|
|
65
|
+
crass (~> 1.0.2)
|
|
59
66
|
nokogiri (>= 1.5.9)
|
|
60
|
-
mail (2.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
minitest
|
|
67
|
+
mail (2.7.0)
|
|
68
|
+
mini_mime (>= 0.1.1)
|
|
69
|
+
marcel (0.3.2)
|
|
70
|
+
mimemagic (~> 0.3.2)
|
|
71
|
+
method_source (0.9.0)
|
|
72
|
+
mimemagic (0.3.2)
|
|
73
|
+
mini_mime (1.0.0)
|
|
74
|
+
mini_portile2 (2.3.0)
|
|
75
|
+
minitest (5.10.3)
|
|
76
|
+
minitest-reporters (1.2.0)
|
|
69
77
|
ansi
|
|
70
78
|
builder
|
|
71
79
|
minitest (>= 5.0)
|
|
72
80
|
ruby-progressbar
|
|
73
|
-
nio4r (2.1
|
|
74
|
-
nokogiri (1.8.
|
|
75
|
-
mini_portile2 (~> 2.
|
|
76
|
-
parallel (1.
|
|
77
|
-
parser (2.
|
|
78
|
-
ast (~> 2.
|
|
81
|
+
nio4r (2.3.1)
|
|
82
|
+
nokogiri (1.8.4)
|
|
83
|
+
mini_portile2 (~> 2.3.0)
|
|
84
|
+
parallel (1.12.1)
|
|
85
|
+
parser (2.5.1.0)
|
|
86
|
+
ast (~> 2.4.0)
|
|
79
87
|
powerpack (0.1.1)
|
|
80
|
-
rack (2.0.
|
|
81
|
-
rack-test (
|
|
82
|
-
rack (>= 1.0)
|
|
83
|
-
rails (5.
|
|
84
|
-
actioncable (= 5.
|
|
85
|
-
actionmailer (= 5.
|
|
86
|
-
actionpack (= 5.
|
|
87
|
-
actionview (= 5.
|
|
88
|
-
activejob (= 5.
|
|
89
|
-
activemodel (= 5.
|
|
90
|
-
activerecord (= 5.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
rack (2.0.5)
|
|
89
|
+
rack-test (1.1.0)
|
|
90
|
+
rack (>= 1.0, < 3)
|
|
91
|
+
rails (5.2.0)
|
|
92
|
+
actioncable (= 5.2.0)
|
|
93
|
+
actionmailer (= 5.2.0)
|
|
94
|
+
actionpack (= 5.2.0)
|
|
95
|
+
actionview (= 5.2.0)
|
|
96
|
+
activejob (= 5.2.0)
|
|
97
|
+
activemodel (= 5.2.0)
|
|
98
|
+
activerecord (= 5.2.0)
|
|
99
|
+
activestorage (= 5.2.0)
|
|
100
|
+
activesupport (= 5.2.0)
|
|
101
|
+
bundler (>= 1.3.0)
|
|
102
|
+
railties (= 5.2.0)
|
|
94
103
|
sprockets-rails (>= 2.0.0)
|
|
95
104
|
rails-dom-testing (2.0.3)
|
|
96
105
|
activesupport (>= 4.2.0)
|
|
97
106
|
nokogiri (>= 1.6)
|
|
98
|
-
rails-html-sanitizer (1.0.
|
|
99
|
-
loofah (~> 2.
|
|
100
|
-
railties (5.
|
|
101
|
-
actionpack (= 5.
|
|
102
|
-
activesupport (= 5.
|
|
107
|
+
rails-html-sanitizer (1.0.4)
|
|
108
|
+
loofah (~> 2.2, >= 2.2.2)
|
|
109
|
+
railties (5.2.0)
|
|
110
|
+
actionpack (= 5.2.0)
|
|
111
|
+
activesupport (= 5.2.0)
|
|
103
112
|
method_source
|
|
104
113
|
rake (>= 0.8.7)
|
|
105
114
|
thor (>= 0.18.1, < 2.0)
|
|
106
|
-
rainbow (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
rubocop (0.49.1)
|
|
115
|
+
rainbow (3.0.0)
|
|
116
|
+
rake (12.3.1)
|
|
117
|
+
rubocop (0.54.0)
|
|
110
118
|
parallel (~> 1.10)
|
|
111
|
-
parser (>= 2.
|
|
119
|
+
parser (>= 2.5)
|
|
112
120
|
powerpack (~> 0.1)
|
|
113
|
-
rainbow (>=
|
|
121
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
114
122
|
ruby-progressbar (~> 1.7)
|
|
115
123
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
116
|
-
ruby-progressbar (1.
|
|
117
|
-
simplecov (0.
|
|
118
|
-
docile (~> 1.1
|
|
124
|
+
ruby-progressbar (1.9.0)
|
|
125
|
+
simplecov (0.16.1)
|
|
126
|
+
docile (~> 1.1)
|
|
119
127
|
json (>= 1.8, < 3)
|
|
120
128
|
simplecov-html (~> 0.10.0)
|
|
121
|
-
simplecov-html (0.10.
|
|
122
|
-
sprockets (3.7.
|
|
129
|
+
simplecov-html (0.10.2)
|
|
130
|
+
sprockets (3.7.2)
|
|
123
131
|
concurrent-ruby (~> 1.0)
|
|
124
132
|
rack (> 1, < 3)
|
|
125
|
-
sprockets-rails (3.2.
|
|
133
|
+
sprockets-rails (3.2.1)
|
|
126
134
|
actionpack (>= 4.0)
|
|
127
135
|
activesupport (>= 4.0)
|
|
128
136
|
sprockets (>= 3.0.0)
|
|
129
|
-
thor (0.
|
|
137
|
+
thor (0.20.0)
|
|
130
138
|
thread_safe (0.3.6)
|
|
131
|
-
tzinfo (1.2.
|
|
139
|
+
tzinfo (1.2.5)
|
|
132
140
|
thread_safe (~> 0.1)
|
|
133
141
|
unicode-display_width (1.3.0)
|
|
134
|
-
websocket-driver (0.
|
|
142
|
+
websocket-driver (0.7.0)
|
|
135
143
|
websocket-extensions (>= 0.1.0)
|
|
136
|
-
websocket-extensions (0.1.
|
|
144
|
+
websocket-extensions (0.1.3)
|
|
137
145
|
|
|
138
146
|
PLATFORMS
|
|
139
147
|
ruby
|
|
140
148
|
|
|
141
149
|
DEPENDENCIES
|
|
142
150
|
minitest-reporters (~> 1.0)
|
|
143
|
-
rubocop (~> 0.
|
|
151
|
+
rubocop (~> 0.49)
|
|
144
152
|
simple_workflow!
|
|
145
153
|
simplecov (~> 0.9)
|
|
146
154
|
|
|
147
155
|
BUNDLED WITH
|
|
148
|
-
1.
|
|
156
|
+
1.16.3
|
data/Rakefile
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'rake'
|
|
2
4
|
require 'rake/clean'
|
|
3
5
|
require 'rake/testtask'
|
|
4
6
|
require File.dirname(__FILE__) + '/lib/simple_workflow/version'
|
|
5
7
|
|
|
6
|
-
GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
|
|
7
|
-
GEM_SPEC_FILE = 'simple_workflow.gemspec'
|
|
8
|
+
GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
|
|
9
|
+
GEM_SPEC_FILE = 'simple_workflow.gemspec'
|
|
8
10
|
|
|
9
11
|
CLEAN.include('simple_workflow-*.gem', 'tmp')
|
|
10
12
|
|
data/lib/simple_workflow.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simple_workflow/detour'
|
|
2
4
|
|
|
3
5
|
# Mixin to add controller methods for workflow navigation.
|
|
@@ -38,7 +40,7 @@ module SimpleWorkflow::Controller
|
|
|
38
40
|
redirect_to detour, response_status_and_flash
|
|
39
41
|
end
|
|
40
42
|
true
|
|
41
|
-
rescue
|
|
43
|
+
rescue StandardError
|
|
42
44
|
retry
|
|
43
45
|
end
|
|
44
46
|
|
|
@@ -62,13 +64,13 @@ module SimpleWorkflow::Controller
|
|
|
62
64
|
|
|
63
65
|
def redirect_to_post(options)
|
|
64
66
|
url = url_for options
|
|
65
|
-
render text:
|
|
67
|
+
render text: <<~HTML.strip_heredoc, layout: false
|
|
66
68
|
<html>
|
|
67
69
|
<body onload="document.getElementById('form').submit()">
|
|
68
70
|
<form id="form" action="#{url}" method="POST">
|
|
69
71
|
</form>
|
|
70
72
|
</body>
|
|
71
73
|
</html>
|
|
72
|
-
|
|
74
|
+
HTML
|
|
73
75
|
end
|
|
74
76
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Utility methods to manage the breadcrumb history
|
|
2
4
|
module SimpleWorkflow::Detour
|
|
3
5
|
def store_detour_in_session(session, options)
|
|
@@ -7,8 +9,7 @@ module SimpleWorkflow::Detour
|
|
|
7
9
|
end
|
|
8
10
|
session[:detours] ||= []
|
|
9
11
|
session[:detours] << options
|
|
10
|
-
Rails.logger
|
|
11
|
-
.try(:debug, "Added detour (#{session[:detours].try(:size) || 0}): #{options.inspect}")
|
|
12
|
+
Rails.logger.try(:debug, "Added detour (#{session[:detours].try(:size) || 0}): #{options.inspect}")
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def pop_detour(session)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simple_workflow/detour'
|
|
2
4
|
require 'active_support/core_ext/string/strip'
|
|
3
5
|
|
|
@@ -40,8 +42,7 @@ class SimpleWorkflow::Middleware
|
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def remove_old_detours(env)
|
|
43
|
-
return unless session(env).instance_variable_get('@by')
|
|
44
|
-
.is_a?(ActionDispatch::Session::CookieStore)
|
|
45
|
+
return unless session(env).instance_variable_get('@by').is_a?(ActionDispatch::Session::CookieStore)
|
|
45
46
|
session_size = workflow_size = nil
|
|
46
47
|
session = session(env)
|
|
47
48
|
cookie_jar = cookie_jar(env)
|
|
@@ -52,10 +53,8 @@ class SimpleWorkflow::Middleware
|
|
|
52
53
|
wf_ser_val = serialize_session(cookie_jar, session[:detours])
|
|
53
54
|
workflow_size = encryptor.encrypt_and_sign(wf_ser_val).size
|
|
54
55
|
break unless workflow_size >= 2048 ||
|
|
55
|
-
|
|
56
|
-
Rails.logger.warn(
|
|
57
|
-
"Workflow too large (#{workflow_size}/#{session_size}). Dropping oldest detour."
|
|
58
|
-
)
|
|
56
|
+
(session_size >= 3072 && session[:detours] && !session[:detours].empty?)
|
|
57
|
+
Rails.logger.warn("Workflow too large (#{workflow_size}/#{session_size}). Dropping oldest detour.")
|
|
59
58
|
session[:detours].shift
|
|
60
59
|
reset_workflow(session) if session[:detours].empty?
|
|
61
60
|
end
|
|
@@ -94,9 +93,8 @@ class SimpleWorkflow::Middleware
|
|
|
94
93
|
@simple_workflow_encryptor = cookie_jar(env).instance_variable_get(:@encryptor)
|
|
95
94
|
return @simple_workflow_encryptor if @simple_workflow_encryptor
|
|
96
95
|
Rails.logger.warn 'simple_workflow: Could not get encryptor from the cookie jar'
|
|
97
|
-
secret_key_base = Rails.application.config.secret_key_base ||
|
|
98
|
-
|
|
99
|
-
SecureRandom.hex(64)
|
|
96
|
+
secret_key_base = Rails.application.config.secret_key_base || Rails.application.config.secret_token ||
|
|
97
|
+
SecureRandom.hex(64)
|
|
100
98
|
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
|
|
101
99
|
key_generator = ActiveSupport::CachingKeyGenerator.new(key_generator)
|
|
102
100
|
secret = key_generator.generate_key('encrypted cookie')
|
|
@@ -105,9 +103,7 @@ class SimpleWorkflow::Middleware
|
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
def store_detour_from_params(env)
|
|
108
|
-
if params(env)[:detour]
|
|
109
|
-
store_detour_in_session(session(env), params(env)[:detour])
|
|
110
|
-
end
|
|
106
|
+
store_detour_in_session(session(env), params(env)[:detour]) if params(env)[:detour]
|
|
111
107
|
return unless params(env)[:return_from_detour] && session(env)[:detours]
|
|
112
108
|
pop_detour(session(env))
|
|
113
109
|
end
|
data/test/controller_test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative 'test_helper'
|
|
2
4
|
require 'rails'
|
|
3
5
|
|
|
@@ -6,9 +8,11 @@ class ControllerTest < MiniTest::Test
|
|
|
6
8
|
attr_accessor :cookies, :logger, :session
|
|
7
9
|
|
|
8
10
|
def setup
|
|
9
|
-
options = { encrypted_cookie_salt: 'salt1', encrypted_signed_cookie_salt: 'salt2',
|
|
11
|
+
options = { encrypted_cookie_salt: 'salt1', encrypted_signed_cookie_salt: 'salt2',
|
|
12
|
+
secret_key_base: 'secret_key_base' }
|
|
10
13
|
if Rails.gem_version < Gem::Version.new('5')
|
|
11
|
-
@cookies = ActionDispatch::Cookies::CookieJar
|
|
14
|
+
@cookies = ActionDispatch::Cookies::CookieJar
|
|
15
|
+
.new(ActiveSupport::KeyGenerator.new('secret'), nil, false, options)
|
|
12
16
|
end
|
|
13
17
|
@logger = Rails.logger
|
|
14
18
|
@session = {}
|
|
@@ -32,7 +36,7 @@ class ControllerTest < MiniTest::Test
|
|
|
32
36
|
assert_equal({}, session)
|
|
33
37
|
end
|
|
34
38
|
|
|
35
|
-
def test_back_with_invalid_detour
|
|
39
|
+
def test_back_with_invalid_detour
|
|
36
40
|
store_detour(controller: :mycontroller, action: :missing_in_action)
|
|
37
41
|
@bad_route = true
|
|
38
42
|
back({})
|
data/test/helper_test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative 'test_helper'
|
|
2
4
|
require 'action_controller/metal/exceptions'
|
|
3
5
|
require 'test_app'
|
|
@@ -6,7 +8,8 @@ class HelperTest < MiniTest::Test
|
|
|
6
8
|
include SimpleWorkflow::Helper
|
|
7
9
|
|
|
8
10
|
def test_with_detour
|
|
9
|
-
assert_equal '?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42
|
|
11
|
+
assert_equal '?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
|
|
12
|
+
'&detour%5Bquery%5D%5Bnested%5D=criterium',
|
|
10
13
|
with_detour('')
|
|
11
14
|
end
|
|
12
15
|
|
|
@@ -16,7 +19,8 @@ class HelperTest < MiniTest::Test
|
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def test_with_detour_with_only_anchor_as_origin
|
|
19
|
-
assert_equal '?detour%5Baction%5D=myaction&detour%5Banchor%5D=tab_2
|
|
22
|
+
assert_equal '?detour%5Baction%5D=myaction&detour%5Banchor%5D=tab_2' \
|
|
23
|
+
'&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42&detour%5Bquery%5D%5Bnested%5D=criterium',
|
|
20
24
|
with_detour('', anchor: :tab_2)
|
|
21
25
|
end
|
|
22
26
|
|
|
@@ -27,7 +31,8 @@ class HelperTest < MiniTest::Test
|
|
|
27
31
|
get 'dashboard/index' => 'simple_workflow/#index'
|
|
28
32
|
end
|
|
29
33
|
|
|
30
|
-
assert_equal '?detour%5Baction%5D=index&detour%5Banchor%5D=tab_2
|
|
34
|
+
assert_equal '?detour%5Baction%5D=index&detour%5Banchor%5D=tab_2' \
|
|
35
|
+
'&detour%5Bcontroller%5D=simple_workflow%2F&detour%5Bhullo%5D=1',
|
|
31
36
|
with_detour('', '/dashboard/index?hullo=1#tab_2')
|
|
32
37
|
ensure
|
|
33
38
|
Rails.application = nil
|
|
@@ -36,8 +41,9 @@ class HelperTest < MiniTest::Test
|
|
|
36
41
|
def test_detour_to
|
|
37
42
|
assert_equal [
|
|
38
43
|
'Link Text',
|
|
39
|
-
'Link target?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42
|
|
40
|
-
|
|
44
|
+
'Link target?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
|
|
45
|
+
'&detour%5Bquery%5D%5Bnested%5D=criterium',
|
|
46
|
+
{ id: 'link_tag_id', title: 'Link title' },
|
|
41
47
|
],
|
|
42
48
|
detour_to('Link Text', 'Link target', id: 'link_tag_id', title: 'Link title')
|
|
43
49
|
end
|
|
@@ -80,7 +86,7 @@ class HelperTest < MiniTest::Test
|
|
|
80
86
|
|
|
81
87
|
def params
|
|
82
88
|
ActionController::Parameters.new(
|
|
83
|
-
|
|
89
|
+
controller: 'mycontroller', action: 'myaction', id: 42, query: { nested: 'criterium' }
|
|
84
90
|
)
|
|
85
91
|
end
|
|
86
92
|
|
data/test/middleware_test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require_relative 'test_helper'
|
|
2
4
|
require 'simple_workflow/middleware'
|
|
3
5
|
require_relative 'test_app'
|
|
@@ -42,12 +44,12 @@ class MiddlewareTest < MiniTest::Test
|
|
|
42
44
|
def test_detour_cleanup
|
|
43
45
|
_, env, = @stack.call env_for('/?detour[controller]=test_first')
|
|
44
46
|
(50..99).each do |i|
|
|
45
|
-
next_env = env_for("/?detour[controller]=test_#{i}",
|
|
46
|
-
|
|
47
|
+
next_env = env_for("/?detour[controller]=test_#{i}",
|
|
48
|
+
'rack.session' => env['rack.session'], 'rack.session.options' => env['rack.session.options'])
|
|
47
49
|
_, env, = @stack.call next_env
|
|
48
50
|
end
|
|
49
|
-
last_env = env_for('/?detour[controller]=test_last',
|
|
50
|
-
|
|
51
|
+
last_env = env_for('/?detour[controller]=test_last',
|
|
52
|
+
'rack.session' => env['rack.session'], 'rack.session.options' => env['rack.session.options'])
|
|
51
53
|
status, env, response = @stack.call last_env
|
|
52
54
|
|
|
53
55
|
assert_equal 200, status
|
|
@@ -91,10 +93,14 @@ class MiddlewareTest < MiniTest::Test
|
|
|
91
93
|
def env_for(url, opts = {})
|
|
92
94
|
default_opts = {
|
|
93
95
|
ActionDispatch::Cookies::COOKIES_SERIALIZER => :json,
|
|
96
|
+
ActionDispatch::Cookies::ENCRYPTED_COOKIE_SALT => 'salt',
|
|
97
|
+
ActionDispatch::Cookies::ENCRYPTED_SIGNED_COOKIE_SALT => 'signed_salt',
|
|
94
98
|
ActionDispatch::Cookies::GENERATOR_KEY => ActiveSupport::KeyGenerator.new('secret'),
|
|
95
99
|
ActionDispatch::Cookies::SECRET_KEY_BASE => 'secret',
|
|
96
|
-
# ActionDispatch::Cookies::SECRET_TOKEN => 'secret',
|
|
97
100
|
}
|
|
101
|
+
if Rails.version =~ /^5\.2\./
|
|
102
|
+
default_opts[ActionDispatch::Cookies::COOKIES_ROTATIONS] = Struct.new(:encrypted).new([])
|
|
103
|
+
end
|
|
98
104
|
Rack::MockRequest.env_for(url, default_opts.update(opts))
|
|
99
105
|
end
|
|
100
106
|
end
|
data/test/test_app.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_workflow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Uwe Kubosch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -16,63 +16,63 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '4'
|
|
19
|
+
version: '4.2'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '5.
|
|
22
|
+
version: '5.3'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: '4'
|
|
29
|
+
version: '4.2'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '5.
|
|
32
|
+
version: '5.3'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
34
|
+
name: minitest-reporters
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0
|
|
39
|
+
version: '1.0'
|
|
40
40
|
type: :development
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0
|
|
46
|
+
version: '1.0'
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
|
-
name:
|
|
48
|
+
name: rubocop
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
53
|
+
version: '0.49'
|
|
54
54
|
type: :development
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '
|
|
60
|
+
version: '0.49'
|
|
61
61
|
- !ruby/object:Gem::Dependency
|
|
62
|
-
name:
|
|
62
|
+
name: simplecov
|
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0.
|
|
67
|
+
version: '0.9'
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0.
|
|
75
|
-
description: Expands Ruby
|
|
74
|
+
version: '0.9'
|
|
75
|
+
description: Expands Ruby on Rails to allow simple breadcrumb detour workflows.
|
|
76
76
|
email: uwe@kubosch.no
|
|
77
77
|
executables: []
|
|
78
78
|
extensions: []
|
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
108
108
|
requirements:
|
|
109
109
|
- - "~>"
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: '2.
|
|
111
|
+
version: '2.3'
|
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
requirements:
|
|
114
114
|
- - ">="
|
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
116
116
|
version: '0'
|
|
117
117
|
requirements: []
|
|
118
118
|
rubyforge_project: donv/simple_workflow
|
|
119
|
-
rubygems_version: 2.6.
|
|
119
|
+
rubygems_version: 2.6.14.1
|
|
120
120
|
signing_key:
|
|
121
121
|
specification_version: 4
|
|
122
122
|
summary: Add simple breadcrumbs "detour" workflow to Ruby On Rails.
|