simple_workflow 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +145 -126
- data/Rakefile +1 -1
- data/lib/simple_workflow/controller.rb +3 -1
- data/lib/simple_workflow/detour.rb +2 -1
- data/lib/simple_workflow/helper.rb +7 -5
- data/lib/simple_workflow/middleware.rb +9 -2
- data/lib/simple_workflow/railtie.rb +4 -4
- data/lib/simple_workflow/version.rb +1 -1
- data/simple_workflow.gemspec +26 -0
- data/test/controller_test.rb +1 -1
- data/test/helper_test.rb +23 -15
- data/test/middleware_test.rb +8 -6
- data/test/test_helper.rb +6 -2
- metadata +18 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e889d098f3df6a6fb2b8616fe94dd78df26fcb39eefdbef76058f63243ea7009
|
4
|
+
data.tar.gz: aca8036b62d9b076aeb7134957141c61bb31da1bf6e748c95f183dc6006cafb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de279f421829e2aba3a9401ddf26925f9dad573f531753a562d7abd552bf0b2f65a487f8906d1335e5a40dadd6f45a3b72137be06a7378fa2f9bec9d8e1f0e5
|
7
|
+
data.tar.gz: 3801dd96ab9190e4c2f008dc3c75e03a2f90b02459ffbb4517c1de8a92dee6505eebbe216a88434cb530d363114ae3042f6efe0c0f635fc1b5828b15750e65dd
|
data/Gemfile.lock
CHANGED
@@ -1,179 +1,198 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_workflow (2.
|
5
|
-
rails (>=
|
4
|
+
simple_workflow (2.2.0)
|
5
|
+
rails (>= 6.2, < 8)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (
|
11
|
-
actionpack (=
|
10
|
+
actioncable (7.0.2.2)
|
11
|
+
actionpack (= 7.0.2.2)
|
12
|
+
activesupport (= 7.0.2.2)
|
12
13
|
nio4r (~> 2.0)
|
13
14
|
websocket-driver (>= 0.6.1)
|
14
|
-
actionmailbox (
|
15
|
-
actionpack (=
|
16
|
-
activejob (=
|
17
|
-
activerecord (=
|
18
|
-
activestorage (=
|
19
|
-
activesupport (=
|
15
|
+
actionmailbox (7.0.2.2)
|
16
|
+
actionpack (= 7.0.2.2)
|
17
|
+
activejob (= 7.0.2.2)
|
18
|
+
activerecord (= 7.0.2.2)
|
19
|
+
activestorage (= 7.0.2.2)
|
20
|
+
activesupport (= 7.0.2.2)
|
20
21
|
mail (>= 2.7.1)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
net-imap
|
23
|
+
net-pop
|
24
|
+
net-smtp
|
25
|
+
actionmailer (7.0.2.2)
|
26
|
+
actionpack (= 7.0.2.2)
|
27
|
+
actionview (= 7.0.2.2)
|
28
|
+
activejob (= 7.0.2.2)
|
29
|
+
activesupport (= 7.0.2.2)
|
25
30
|
mail (~> 2.5, >= 2.5.4)
|
31
|
+
net-imap
|
32
|
+
net-pop
|
33
|
+
net-smtp
|
26
34
|
rails-dom-testing (~> 2.0)
|
27
|
-
actionpack (
|
28
|
-
actionview (=
|
29
|
-
activesupport (=
|
30
|
-
rack (~> 2.0, >= 2.0
|
35
|
+
actionpack (7.0.2.2)
|
36
|
+
actionview (= 7.0.2.2)
|
37
|
+
activesupport (= 7.0.2.2)
|
38
|
+
rack (~> 2.0, >= 2.2.0)
|
31
39
|
rack-test (>= 0.6.3)
|
32
40
|
rails-dom-testing (~> 2.0)
|
33
41
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
34
|
-
actiontext (
|
35
|
-
actionpack (=
|
36
|
-
activerecord (=
|
37
|
-
activestorage (=
|
38
|
-
activesupport (=
|
42
|
+
actiontext (7.0.2.2)
|
43
|
+
actionpack (= 7.0.2.2)
|
44
|
+
activerecord (= 7.0.2.2)
|
45
|
+
activestorage (= 7.0.2.2)
|
46
|
+
activesupport (= 7.0.2.2)
|
47
|
+
globalid (>= 0.6.0)
|
39
48
|
nokogiri (>= 1.8.5)
|
40
|
-
actionview (
|
41
|
-
activesupport (=
|
49
|
+
actionview (7.0.2.2)
|
50
|
+
activesupport (= 7.0.2.2)
|
42
51
|
builder (~> 3.1)
|
43
52
|
erubi (~> 1.4)
|
44
53
|
rails-dom-testing (~> 2.0)
|
45
54
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
46
|
-
activejob (
|
47
|
-
activesupport (=
|
55
|
+
activejob (7.0.2.2)
|
56
|
+
activesupport (= 7.0.2.2)
|
48
57
|
globalid (>= 0.3.6)
|
49
|
-
activemodel (
|
50
|
-
activesupport (=
|
51
|
-
activerecord (
|
52
|
-
activemodel (=
|
53
|
-
activesupport (=
|
54
|
-
activestorage (
|
55
|
-
actionpack (=
|
56
|
-
activejob (=
|
57
|
-
activerecord (=
|
58
|
-
|
59
|
-
|
58
|
+
activemodel (7.0.2.2)
|
59
|
+
activesupport (= 7.0.2.2)
|
60
|
+
activerecord (7.0.2.2)
|
61
|
+
activemodel (= 7.0.2.2)
|
62
|
+
activesupport (= 7.0.2.2)
|
63
|
+
activestorage (7.0.2.2)
|
64
|
+
actionpack (= 7.0.2.2)
|
65
|
+
activejob (= 7.0.2.2)
|
66
|
+
activerecord (= 7.0.2.2)
|
67
|
+
activesupport (= 7.0.2.2)
|
68
|
+
marcel (~> 1.0)
|
69
|
+
mini_mime (>= 1.1.0)
|
70
|
+
activesupport (7.0.2.2)
|
60
71
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
61
|
-
i18n (>=
|
62
|
-
minitest (
|
63
|
-
tzinfo (~>
|
64
|
-
|
65
|
-
ansi (1.5.0)
|
66
|
-
ast (2.4.0)
|
72
|
+
i18n (>= 1.6, < 2)
|
73
|
+
minitest (>= 5.1)
|
74
|
+
tzinfo (~> 2.0)
|
75
|
+
ast (2.4.2)
|
67
76
|
builder (3.2.4)
|
68
|
-
concurrent-ruby (1.1.
|
69
|
-
crass (1.0.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
concurrent-ruby (1.1.9)
|
78
|
+
crass (1.0.6)
|
79
|
+
digest (3.1.0)
|
80
|
+
docile (1.4.0)
|
81
|
+
erubi (1.10.0)
|
82
|
+
globalid (1.0.0)
|
83
|
+
activesupport (>= 5.0)
|
84
|
+
i18n (1.10.0)
|
75
85
|
concurrent-ruby (~> 1.0)
|
76
|
-
|
77
|
-
|
78
|
-
loofah (2.4.0)
|
86
|
+
io-wait (0.2.1)
|
87
|
+
loofah (2.14.0)
|
79
88
|
crass (~> 1.0.2)
|
80
89
|
nokogiri (>= 1.5.9)
|
81
90
|
mail (2.7.1)
|
82
91
|
mini_mime (>= 0.1.1)
|
83
|
-
marcel (0.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
92
|
+
marcel (1.0.2)
|
93
|
+
method_source (1.0.0)
|
94
|
+
mini_mime (1.1.2)
|
95
|
+
minitest (5.15.0)
|
96
|
+
net-imap (0.2.3)
|
97
|
+
digest
|
98
|
+
net-protocol
|
99
|
+
strscan
|
100
|
+
net-pop (0.1.1)
|
101
|
+
digest
|
102
|
+
net-protocol
|
103
|
+
timeout
|
104
|
+
net-protocol (0.1.2)
|
105
|
+
io-wait
|
106
|
+
timeout
|
107
|
+
net-smtp (0.3.1)
|
108
|
+
digest
|
109
|
+
net-protocol
|
110
|
+
timeout
|
111
|
+
nio4r (2.5.8)
|
112
|
+
nokogiri (1.13.3-x86_64-darwin)
|
113
|
+
racc (~> 1.4)
|
114
|
+
parallel (1.21.0)
|
115
|
+
parser (3.1.1.0)
|
116
|
+
ast (~> 2.4.1)
|
117
|
+
racc (1.6.0)
|
118
|
+
rack (2.2.3)
|
102
119
|
rack-test (1.1.0)
|
103
120
|
rack (>= 1.0, < 3)
|
104
|
-
rails (
|
105
|
-
actioncable (=
|
106
|
-
actionmailbox (=
|
107
|
-
actionmailer (=
|
108
|
-
actionpack (=
|
109
|
-
actiontext (=
|
110
|
-
actionview (=
|
111
|
-
activejob (=
|
112
|
-
activemodel (=
|
113
|
-
activerecord (=
|
114
|
-
activestorage (=
|
115
|
-
activesupport (=
|
116
|
-
bundler (>= 1.
|
117
|
-
railties (=
|
118
|
-
sprockets-rails (>= 2.0.0)
|
121
|
+
rails (7.0.2.2)
|
122
|
+
actioncable (= 7.0.2.2)
|
123
|
+
actionmailbox (= 7.0.2.2)
|
124
|
+
actionmailer (= 7.0.2.2)
|
125
|
+
actionpack (= 7.0.2.2)
|
126
|
+
actiontext (= 7.0.2.2)
|
127
|
+
actionview (= 7.0.2.2)
|
128
|
+
activejob (= 7.0.2.2)
|
129
|
+
activemodel (= 7.0.2.2)
|
130
|
+
activerecord (= 7.0.2.2)
|
131
|
+
activestorage (= 7.0.2.2)
|
132
|
+
activesupport (= 7.0.2.2)
|
133
|
+
bundler (>= 1.15.0)
|
134
|
+
railties (= 7.0.2.2)
|
119
135
|
rails-dom-testing (2.0.3)
|
120
136
|
activesupport (>= 4.2.0)
|
121
137
|
nokogiri (>= 1.6)
|
122
|
-
rails-html-sanitizer (1.
|
138
|
+
rails-html-sanitizer (1.4.2)
|
123
139
|
loofah (~> 2.3)
|
124
|
-
railties (
|
125
|
-
actionpack (=
|
126
|
-
activesupport (=
|
140
|
+
railties (7.0.2.2)
|
141
|
+
actionpack (= 7.0.2.2)
|
142
|
+
activesupport (= 7.0.2.2)
|
127
143
|
method_source
|
128
|
-
rake (>=
|
129
|
-
thor (
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
144
|
+
rake (>= 12.2)
|
145
|
+
thor (~> 1.0)
|
146
|
+
zeitwerk (~> 2.5)
|
147
|
+
rainbow (3.1.1)
|
148
|
+
rake (13.0.6)
|
149
|
+
regexp_parser (2.2.1)
|
150
|
+
rexml (3.2.5)
|
151
|
+
rubocop (1.25.1)
|
134
152
|
parallel (~> 1.10)
|
135
|
-
parser (>=
|
153
|
+
parser (>= 3.1.0.0)
|
136
154
|
rainbow (>= 2.2.2, < 4.0)
|
155
|
+
regexp_parser (>= 1.8, < 3.0)
|
156
|
+
rexml
|
157
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
137
158
|
ruby-progressbar (~> 1.7)
|
138
|
-
unicode-display_width (>= 1.4.0, <
|
139
|
-
rubocop-
|
140
|
-
|
141
|
-
rubocop-
|
159
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
160
|
+
rubocop-ast (1.16.0)
|
161
|
+
parser (>= 3.1.1.0)
|
162
|
+
rubocop-performance (1.13.2)
|
163
|
+
rubocop (>= 1.7.0, < 2.0)
|
164
|
+
rubocop-ast (>= 0.4.0)
|
165
|
+
rubocop-rails (2.13.2)
|
166
|
+
activesupport (>= 4.2.0)
|
142
167
|
rack (>= 1.1)
|
143
|
-
rubocop (>=
|
144
|
-
ruby-progressbar (1.
|
145
|
-
simplecov (0.
|
168
|
+
rubocop (>= 1.7.0, < 2.0)
|
169
|
+
ruby-progressbar (1.11.0)
|
170
|
+
simplecov (0.21.2)
|
146
171
|
docile (~> 1.1)
|
147
|
-
|
148
|
-
|
149
|
-
simplecov-html (0.
|
150
|
-
|
172
|
+
simplecov-html (~> 0.11)
|
173
|
+
simplecov_json_formatter (~> 0.1)
|
174
|
+
simplecov-html (0.12.3)
|
175
|
+
simplecov_json_formatter (0.1.4)
|
176
|
+
strscan (3.0.1)
|
177
|
+
thor (1.2.1)
|
178
|
+
timeout (0.2.0)
|
179
|
+
tzinfo (2.0.4)
|
151
180
|
concurrent-ruby (~> 1.0)
|
152
|
-
|
153
|
-
|
154
|
-
actionpack (>= 4.0)
|
155
|
-
activesupport (>= 4.0)
|
156
|
-
sprockets (>= 3.0.0)
|
157
|
-
thor (1.0.1)
|
158
|
-
thread_safe (0.3.6)
|
159
|
-
tzinfo (1.2.6)
|
160
|
-
thread_safe (~> 0.1)
|
161
|
-
unicode-display_width (1.6.0)
|
162
|
-
websocket-driver (0.7.1)
|
181
|
+
unicode-display_width (2.1.0)
|
182
|
+
websocket-driver (0.7.5)
|
163
183
|
websocket-extensions (>= 0.1.0)
|
164
|
-
websocket-extensions (0.1.
|
165
|
-
zeitwerk (2.
|
184
|
+
websocket-extensions (0.1.5)
|
185
|
+
zeitwerk (2.5.4)
|
166
186
|
|
167
187
|
PLATFORMS
|
168
188
|
ruby
|
169
189
|
|
170
190
|
DEPENDENCIES
|
171
|
-
|
172
|
-
rubocop (~> 0.49)
|
191
|
+
rubocop (~> 1.0)
|
173
192
|
rubocop-performance (~> 1.5)
|
174
193
|
rubocop-rails (~> 2.4)
|
175
194
|
simple_workflow!
|
176
195
|
simplecov (~> 0.9)
|
177
196
|
|
178
197
|
BUNDLED WITH
|
179
|
-
|
198
|
+
2.3.5
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'rake'
|
4
4
|
require 'rake/clean'
|
5
5
|
require 'rake/testtask'
|
6
|
-
require File.dirname(__FILE__)
|
6
|
+
require "#{File.dirname(__FILE__)}/lib/simple_workflow/version"
|
7
7
|
|
8
8
|
GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
|
9
9
|
GEM_SPEC_FILE = 'simple_workflow.gemspec'
|
@@ -31,6 +31,7 @@ module SimpleWorkflow::Controller
|
|
31
31
|
|
32
32
|
def back(response_status_and_flash)
|
33
33
|
return false if session[:detours].nil?
|
34
|
+
|
34
35
|
detour = pop_detour(session)
|
35
36
|
post = detour.delete(:request_method) == :post
|
36
37
|
if post
|
@@ -58,6 +59,7 @@ module SimpleWorkflow::Controller
|
|
58
59
|
end
|
59
60
|
|
60
61
|
return unless (other_flashes = response_status_and_flash.delete(:flash))
|
62
|
+
|
61
63
|
flash.update(other_flashes)
|
62
64
|
end
|
63
65
|
private :save_flash
|
@@ -71,6 +73,6 @@ module SimpleWorkflow::Controller
|
|
71
73
|
</form>
|
72
74
|
</body>
|
73
75
|
</html>
|
74
|
-
|
76
|
+
HTML
|
75
77
|
end
|
76
78
|
end
|
@@ -21,8 +21,9 @@ module SimpleWorkflow::Detour
|
|
21
21
|
def pop_detour(session, origin_options = nil)
|
22
22
|
detours = session[:detours]
|
23
23
|
return nil unless detours
|
24
|
+
|
24
25
|
detour = detours.delete(origin_options) || detours.pop
|
25
|
-
Rails.logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
|
26
|
+
Rails.logger.debug { "popped detour: #{detour.inspect} #{session[:detours].size} more" }
|
26
27
|
reset_workflow(session) if detours.empty?
|
27
28
|
detour
|
28
29
|
end
|
@@ -44,7 +44,7 @@ module SimpleWorkflow::Helper
|
|
44
44
|
end
|
45
45
|
origin.update(origin_options) if origin.keys == [:anchor]
|
46
46
|
url = url_for(options)
|
47
|
-
url + (url
|
47
|
+
url + (/\?/.match?(url) ? '&' : '?') + origin.to_h.to_param('detour')
|
48
48
|
end
|
49
49
|
|
50
50
|
def origin_options
|
@@ -58,9 +58,10 @@ module SimpleWorkflow::Helper
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def image_link_to(image_source, title, url_options, image_options = nil, link_options = nil)
|
61
|
-
|
61
|
+
case link_options
|
62
|
+
when true
|
62
63
|
link_options = { method: :post }
|
63
|
-
|
64
|
+
when false
|
64
65
|
link_options = nil
|
65
66
|
end
|
66
67
|
image_options ||= { class: 'image-submit' }
|
@@ -70,9 +71,10 @@ module SimpleWorkflow::Helper
|
|
70
71
|
|
71
72
|
def image_link_to_remote(image_source, title, link_options, image_options = nil,
|
72
73
|
html_options = {})
|
73
|
-
|
74
|
+
case html_options
|
75
|
+
when true
|
74
76
|
html_options = { method: :post }
|
75
|
-
|
77
|
+
when false
|
76
78
|
html_options = {}
|
77
79
|
end
|
78
80
|
image_options ||= { class: 'image-submit' }
|
@@ -42,7 +42,8 @@ class SimpleWorkflow::Middleware
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def remove_old_detours(env)
|
45
|
-
return unless session(env).instance_variable_get(
|
45
|
+
return unless session(env).instance_variable_get(:@by).is_a?(ActionDispatch::Session::CookieStore)
|
46
|
+
|
46
47
|
session_size = workflow_size = nil
|
47
48
|
session = session(env)
|
48
49
|
cookie_jar = cookie_jar(env)
|
@@ -53,7 +54,8 @@ class SimpleWorkflow::Middleware
|
|
53
54
|
wf_ser_val = serialize_session(cookie_jar, session[:detours])
|
54
55
|
workflow_size = encryptor.encrypt_and_sign(wf_ser_val).size
|
55
56
|
break unless workflow_size >= 2048 ||
|
56
|
-
|
57
|
+
(session_size >= 3072 && session[:detours] && !session[:detours].empty?)
|
58
|
+
|
57
59
|
Rails.logger.warn("Workflow too large (#{workflow_size}/#{session_size}). Dropping oldest detour.")
|
58
60
|
session[:detours].shift
|
59
61
|
reset_workflow(session) if session[:detours].empty?
|
@@ -62,6 +64,7 @@ class SimpleWorkflow::Middleware
|
|
62
64
|
session: #{session_size} bytes, workflow(#{session[:detours].try(:size) || 0}): #{workflow_size} bytes
|
63
65
|
MSG
|
64
66
|
return unless session_size > 4096
|
67
|
+
|
65
68
|
Rails.logger.warn <<-MSG.strip_heredoc
|
66
69
|
simple_workflow: session exceeds cookie size limit: #{session_size} bytes. Workflow empty! Not My Fault!
|
67
70
|
MSG
|
@@ -71,6 +74,7 @@ class SimpleWorkflow::Middleware
|
|
71
74
|
|
72
75
|
def remove_discarded_flashes(session)
|
73
76
|
return unless (old_flashes = session[:flash] && session[:flash]['discard'])
|
77
|
+
|
74
78
|
Rails.logger.warn <<-MSG.strip_heredoc
|
75
79
|
simple_workflow: found discarded flash entries: #{old_flashes}. Deleting them.
|
76
80
|
MSG
|
@@ -90,8 +94,10 @@ class SimpleWorkflow::Middleware
|
|
90
94
|
|
91
95
|
def encryptor(env)
|
92
96
|
return @simple_workflow_encryptor if @simple_workflow_encryptor
|
97
|
+
|
93
98
|
@simple_workflow_encryptor = cookie_jar(env).instance_variable_get(:@encryptor)
|
94
99
|
return @simple_workflow_encryptor if @simple_workflow_encryptor
|
100
|
+
|
95
101
|
Rails.logger.warn 'simple_workflow: Could not get encryptor from the cookie jar'
|
96
102
|
secret_key_base = Rails.application.config.secret_key_base || Rails.application.config.secret_token ||
|
97
103
|
SecureRandom.hex(64)
|
@@ -105,6 +111,7 @@ class SimpleWorkflow::Middleware
|
|
105
111
|
def store_detour_from_params(env)
|
106
112
|
store_detour_in_session(session(env), params(env)[:detour]) if params(env)[:detour]
|
107
113
|
return unless params(env)[:return_from_detour] && session(env)[:detours]
|
114
|
+
|
108
115
|
params_hash = params(env).to_h.reject { |k, _v| %i[detour return_from_detour].include? k.to_sym }
|
109
116
|
pop_detour(session(env), params_hash)
|
110
117
|
end
|
@@ -7,14 +7,14 @@ module SimpleWorkflow
|
|
7
7
|
app.middleware.insert_before ActionDispatch::Flash, SimpleWorkflow::Middleware
|
8
8
|
|
9
9
|
# Make workflow test utility methods available in views
|
10
|
-
ActionView::Base.
|
10
|
+
ActionView::Base.include SimpleWorkflow::Helper
|
11
11
|
|
12
12
|
# Make workflow test utility methods available in controllers
|
13
|
-
ActionController::Base.
|
14
|
-
ActionController::Base.
|
13
|
+
ActionController::Base.include SimpleWorkflow::Helper
|
14
|
+
ActionController::Base.include SimpleWorkflow::Controller
|
15
15
|
|
16
16
|
# Make workflow test utility methods available in ActiveSupport test cases
|
17
|
-
ActiveSupport::TestCase.
|
17
|
+
ActiveSupport::TestCase.include SimpleWorkflow::TestHelper
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require './lib/simple_workflow/version'
|
5
|
+
require 'date'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'simple_workflow'
|
9
|
+
s.version = SimpleWorkflow::VERSION
|
10
|
+
s.authors = ['Uwe Kubosch']
|
11
|
+
s.email = 'uwe@kubosch.no'
|
12
|
+
s.summary = 'Add simple breadcrumbs "detour" workflow to Ruby On Rails.'
|
13
|
+
s.homepage = 'https://github.com/donv/simple_workflow'
|
14
|
+
s.description = 'Expands Ruby on Rails to allow simple breadcrumb detour workflows.'
|
15
|
+
s.required_ruby_version = '>= 2.5', '<4'
|
16
|
+
s.licenses = %w[MIT]
|
17
|
+
s.files = FileList['[A-Z]*', 'lib/**/*', 'test/**/*'].to_a
|
18
|
+
|
19
|
+
s.add_runtime_dependency('rails', '>=6.2', '<8')
|
20
|
+
|
21
|
+
s.add_development_dependency('rubocop', '~>1.0')
|
22
|
+
s.add_development_dependency('rubocop-performance', '~>1.5')
|
23
|
+
s.add_development_dependency('rubocop-rails', '~>2.4')
|
24
|
+
s.add_development_dependency('simplecov', '~>0.9')
|
25
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
26
|
+
end
|
data/test/controller_test.rb
CHANGED
@@ -18,7 +18,7 @@ class ControllerTest < MiniTest::Test
|
|
18
18
|
@session = {}
|
19
19
|
@bad_route = false
|
20
20
|
# TODO(uwe): Remove when we stop testing Rails 4.1
|
21
|
-
Rails.app_class = TestApp
|
21
|
+
Rails.app_class = TestApp unless /^4\.1\./.match?(Rails.version)
|
22
22
|
# ODOT
|
23
23
|
end
|
24
24
|
|
data/test/helper_test.rb
CHANGED
@@ -9,19 +9,26 @@ class HelperTest < MiniTest::Test
|
|
9
9
|
|
10
10
|
def test_with_detour
|
11
11
|
assert_equal '?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
|
12
|
-
|
13
|
-
|
12
|
+
'&detour%5Bquery%5D%5Bnested%5D=criterium',
|
13
|
+
with_detour('')
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_with_detour_with_origin
|
17
17
|
assert_equal '?detour%5Baction%5D=index&detour%5Bcontroller%5D=dashboard',
|
18
|
-
|
18
|
+
with_detour('', controller: :dashboard, action: :index)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_with_detour_with_only_anchor_as_origin
|
22
22
|
assert_equal '?detour%5Baction%5D=myaction&detour%5Banchor%5D=tab_2' \
|
23
|
-
|
24
|
-
|
23
|
+
'&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
|
24
|
+
'&detour%5Bquery%5D%5Bnested%5D=criterium',
|
25
|
+
with_detour('', anchor: :tab_2)
|
26
|
+
end
|
27
|
+
|
28
|
+
module SimpleWorkflow::Controller
|
29
|
+
def self.binary_params_for?(_action)
|
30
|
+
false
|
31
|
+
end
|
25
32
|
end
|
26
33
|
|
27
34
|
def test_with_detour_with_string_origin
|
@@ -32,8 +39,8 @@ class HelperTest < MiniTest::Test
|
|
32
39
|
end
|
33
40
|
|
34
41
|
assert_equal '?detour%5Baction%5D=index&detour%5Banchor%5D=tab_2' \
|
35
|
-
|
36
|
-
|
42
|
+
'&detour%5Bcontroller%5D=simple_workflow%2F&detour%5Bhullo%5D=1',
|
43
|
+
with_detour('', '/dashboard/index?hullo=1#tab_2')
|
37
44
|
ensure
|
38
45
|
Rails.application = nil
|
39
46
|
end
|
@@ -42,10 +49,10 @@ class HelperTest < MiniTest::Test
|
|
42
49
|
assert_equal [
|
43
50
|
'Link Text',
|
44
51
|
'Link target?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
|
45
|
-
|
52
|
+
'&detour%5Bquery%5D%5Bnested%5D=criterium',
|
46
53
|
{ id: 'link_tag_id', title: 'Link title' },
|
47
54
|
],
|
48
|
-
|
55
|
+
detour_to('Link Text', 'Link target', id: 'link_tag_id', title: 'Link title')
|
49
56
|
end
|
50
57
|
|
51
58
|
def test_image_button_to
|
@@ -56,26 +63,27 @@ class HelperTest < MiniTest::Test
|
|
56
63
|
onclick: "form.action='{:id=>\"image_tag_id\"}'"
|
57
64
|
}
|
58
65
|
],
|
59
|
-
|
66
|
+
image_button_to('my_image.png', 'Link Title', { id: 'image_tag_id' },
|
67
|
+
title: 'Image title')
|
60
68
|
end
|
61
69
|
|
62
70
|
def test_image_link_to
|
63
71
|
assert_equal [
|
64
72
|
['my_image.png', { title: 'Link Title', alt: 'Link Title' }], { id: 'image_tag_id' }, nil
|
65
73
|
],
|
66
|
-
|
74
|
+
image_link_to('my_image.png', 'Link Title', { id: 'image_tag_id' }, title: 'Image title')
|
67
75
|
end
|
68
76
|
|
69
77
|
def test_back_or_link_to
|
70
78
|
assert_equal ['Link title', { controller: :mycontroller, action: :my_action }, nil],
|
71
|
-
|
79
|
+
back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
|
72
80
|
end
|
73
81
|
|
74
82
|
def test_back_or_link_to_with_routing_error
|
75
83
|
@session = { detours: [{ controller: :does_not_exist }] }
|
76
84
|
@routing_error = ActionController::UrlGenerationError
|
77
85
|
assert_equal ['Link title', { controller: :mycontroller, action: :my_action }, nil],
|
78
|
-
|
86
|
+
back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
|
79
87
|
end
|
80
88
|
|
81
89
|
private
|
@@ -87,7 +95,7 @@ class HelperTest < MiniTest::Test
|
|
87
95
|
def params
|
88
96
|
ActionController::Parameters.new(
|
89
97
|
controller: 'mycontroller', action: 'myaction', id: 42, query: { nested: 'criterium' }
|
90
|
-
|
98
|
+
)
|
91
99
|
end
|
92
100
|
|
93
101
|
def session
|
@@ -102,7 +110,7 @@ class HelperTest < MiniTest::Test
|
|
102
110
|
if defined?(@routing_error) && @routing_error
|
103
111
|
e = @routing_error
|
104
112
|
@routing_error = nil
|
105
|
-
raise e
|
113
|
+
raise e, 'Error'
|
106
114
|
end
|
107
115
|
options
|
108
116
|
end
|
data/test/middleware_test.rb
CHANGED
@@ -45,11 +45,13 @@ class MiddlewareTest < MiniTest::Test
|
|
45
45
|
_, env, = @stack.call env_for('/?detour[controller]=test_first')
|
46
46
|
(50..99).each do |i|
|
47
47
|
next_env = env_for("/?detour[controller]=test_#{i}",
|
48
|
-
|
48
|
+
'rack.session' => env['rack.session'],
|
49
|
+
'rack.session.options' => env['rack.session.options'])
|
49
50
|
_, env, = @stack.call next_env
|
50
51
|
end
|
51
52
|
last_env = env_for('/?detour[controller]=test_last',
|
52
|
-
|
53
|
+
'rack.session' => env['rack.session'],
|
54
|
+
'rack.session.options' => env['rack.session.options'])
|
53
55
|
status, env, response = @stack.call last_env
|
54
56
|
|
55
57
|
assert_equal 200, status
|
@@ -57,7 +59,7 @@ class MiddlewareTest < MiniTest::Test
|
|
57
59
|
assert_equal(%w[session_id detours], env['rack.session'].to_hash.keys)
|
58
60
|
|
59
61
|
assert_equal(((57..99).to_a + [:last]).map { |i| { 'controller' => "test_#{i}" } },
|
60
|
-
|
62
|
+
env['rack.session'].to_hash['detours'])
|
61
63
|
end
|
62
64
|
|
63
65
|
def test_huge_detour_over_4k
|
@@ -77,8 +79,8 @@ class MiddlewareTest < MiniTest::Test
|
|
77
79
|
def test_return_from_detour
|
78
80
|
_, headers1, = @stack.call env_for('/?detour[controller]=test_first')
|
79
81
|
env = env_for('/?return_from_detour=true',
|
80
|
-
|
81
|
-
|
82
|
+
'rack.session' => headers1['rack.session'],
|
83
|
+
'rack.session.options' => headers1['rack.session.options'])
|
82
84
|
status, headers, response = @stack.call env
|
83
85
|
|
84
86
|
assert_equal 200, status
|
@@ -99,7 +101,7 @@ class MiddlewareTest < MiniTest::Test
|
|
99
101
|
ActionDispatch::Cookies::GENERATOR_KEY => ActiveSupport::KeyGenerator.new('secret'),
|
100
102
|
ActionDispatch::Cookies::SECRET_KEY_BASE => 'secret',
|
101
103
|
}
|
102
|
-
if
|
104
|
+
if /^5\.2\./.match?(Rails.version)
|
103
105
|
default_opts[ActionDispatch::Cookies::COOKIES_ROTATIONS] = Struct.new(:encrypted).new([])
|
104
106
|
end
|
105
107
|
Rack::MockRequest.env_for(url, default_opts.update(opts))
|
data/test/test_helper.rb
CHANGED
@@ -8,9 +8,13 @@ SimpleCov.start do
|
|
8
8
|
minimum_coverage 76
|
9
9
|
end
|
10
10
|
require 'minitest/autorun'
|
11
|
-
require 'minitest/reporters'
|
12
|
-
MiniTest::Reporters.use!
|
13
11
|
require 'rails'
|
14
12
|
require 'simple_workflow'
|
15
13
|
|
16
14
|
FileUtils.mkdir_p File.expand_path '../log', __dir__
|
15
|
+
|
16
|
+
module SimpleWorkflow::Controller
|
17
|
+
def self.action_encoding_template(_action)
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,22 +16,22 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8'
|
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: '
|
29
|
+
version: '6.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: rubocop
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
@@ -44,20 +44,6 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rubocop
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.49'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0.49'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: rubocop-performance
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +105,7 @@ files:
|
|
119
105
|
- lib/simple_workflow/railtie.rb
|
120
106
|
- lib/simple_workflow/test_helper.rb
|
121
107
|
- lib/simple_workflow/version.rb
|
108
|
+
- simple_workflow.gemspec
|
122
109
|
- test/controller_test.rb
|
123
110
|
- test/helper_test.rb
|
124
111
|
- test/middleware_test.rb
|
@@ -127,24 +114,28 @@ files:
|
|
127
114
|
homepage: https://github.com/donv/simple_workflow
|
128
115
|
licenses:
|
129
116
|
- MIT
|
130
|
-
metadata:
|
131
|
-
|
117
|
+
metadata:
|
118
|
+
rubygems_mfa_required: 'true'
|
119
|
+
post_install_message:
|
132
120
|
rdoc_options: []
|
133
121
|
require_paths:
|
134
122
|
- lib
|
135
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
124
|
requirements:
|
137
|
-
- - "
|
125
|
+
- - ">="
|
138
126
|
- !ruby/object:Gem::Version
|
139
127
|
version: '2.5'
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '4'
|
140
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
132
|
requirements:
|
142
133
|
- - ">="
|
143
134
|
- !ruby/object:Gem::Version
|
144
135
|
version: '0'
|
145
136
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
-
signing_key:
|
137
|
+
rubygems_version: 3.3.7
|
138
|
+
signing_key:
|
148
139
|
specification_version: 4
|
149
140
|
summary: Add simple breadcrumbs "detour" workflow to Ruby On Rails.
|
150
141
|
test_files: []
|