simple_workflow 1.6.0 → 2.1.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
- SHA1:
3
- metadata.gz: 347f4e6b9181b3bdb9181f847ec3d42aaf25721f
4
- data.tar.gz: 2343af04ef43d5d4059fbf87b0807aab3d7851a5
2
+ SHA256:
3
+ metadata.gz: f3e6b480412f12b33ab1a43ea40edfd280fcf843e7b48307b79a186ea8dfec18
4
+ data.tar.gz: '094717e238b6c347acdab6f597b65b1139f1a73dc2646c55ffe3bc702f2074c2'
5
5
  SHA512:
6
- metadata.gz: aa32bf4b657422f1809c85cc41edd5d9a216606cc935ae024f366433ad2aaae7bd575b5290d436e317159e146c41a77743c1e92cb8c4c630e09d66c3b9870d93
7
- data.tar.gz: 1e4e13ef6299d58e656b48202f0111df101681c681c457622cb6554f1a510cf5dc2c75ca7ddbfefc315308fd800499e723561297f4a88570712965d64a41c4a3
6
+ metadata.gz: aa6f9b54442208aee5c61201b3277862a055c6d5e7cbf462f0abbf2e8d249909505dd684ca2c786fdafaba445ed55a0b3a0dcee4d6d3afffde7edbe47a3ee92a
7
+ data.tar.gz: 43249992ddb88144cfcc00ced9d9570c2aa722604ae4c2ff6f4d25c23db8f614bf33c0e9b2d197a3d48d92eb06253e35b72e3142d1ec6d090b9e2c380123869b
data/Gemfile.lock CHANGED
@@ -1,147 +1,178 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_workflow (1.6.0)
5
- rails (>= 4.2, < 5.3)
4
+ simple_workflow (2.1.0)
5
+ rails (>= 4.2, < 7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.0)
11
- actionpack (= 5.2.0)
10
+ actioncable (6.1.0)
11
+ actionpack (= 6.1.0)
12
+ activesupport (= 6.1.0)
12
13
  nio4r (~> 2.0)
13
14
  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)
15
+ actionmailbox (6.1.0)
16
+ actionpack (= 6.1.0)
17
+ activejob (= 6.1.0)
18
+ activerecord (= 6.1.0)
19
+ activestorage (= 6.1.0)
20
+ activesupport (= 6.1.0)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.0)
23
+ actionpack (= 6.1.0)
24
+ actionview (= 6.1.0)
25
+ activejob (= 6.1.0)
26
+ activesupport (= 6.1.0)
18
27
  mail (~> 2.5, >= 2.5.4)
19
28
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.0)
21
- actionview (= 5.2.0)
22
- activesupport (= 5.2.0)
23
- rack (~> 2.0)
29
+ actionpack (6.1.0)
30
+ actionview (= 6.1.0)
31
+ activesupport (= 6.1.0)
32
+ rack (~> 2.0, >= 2.0.9)
24
33
  rack-test (>= 0.6.3)
25
34
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.0)
28
- activesupport (= 5.2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.0)
37
+ actionpack (= 6.1.0)
38
+ activerecord (= 6.1.0)
39
+ activestorage (= 6.1.0)
40
+ activesupport (= 6.1.0)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.0)
43
+ activesupport (= 6.1.0)
29
44
  builder (~> 3.1)
30
45
  erubi (~> 1.4)
31
46
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.0)
34
- activesupport (= 5.2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.0)
49
+ activesupport (= 6.1.0)
35
50
  globalid (>= 0.3.6)
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)
51
+ activemodel (6.1.0)
52
+ activesupport (= 6.1.0)
53
+ activerecord (6.1.0)
54
+ activemodel (= 6.1.0)
55
+ activesupport (= 6.1.0)
56
+ activestorage (6.1.0)
57
+ actionpack (= 6.1.0)
58
+ activejob (= 6.1.0)
59
+ activerecord (= 6.1.0)
60
+ activesupport (= 6.1.0)
45
61
  marcel (~> 0.3.1)
46
- activesupport (5.2.0)
62
+ mimemagic (~> 0.3.2)
63
+ activesupport (6.1.0)
47
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
- i18n (>= 0.7, < 2)
49
- minitest (~> 5.1)
50
- tzinfo (~> 1.1)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
51
69
  ansi (1.5.0)
52
- arel (9.0.0)
53
- ast (2.4.0)
54
- builder (3.2.3)
55
- concurrent-ruby (1.0.5)
56
- crass (1.0.4)
57
- docile (1.3.0)
58
- erubi (1.7.1)
59
- globalid (0.4.1)
70
+ ast (2.4.1)
71
+ builder (3.2.4)
72
+ concurrent-ruby (1.1.7)
73
+ crass (1.0.6)
74
+ docile (1.3.3)
75
+ erubi (1.10.0)
76
+ globalid (0.4.2)
60
77
  activesupport (>= 4.2.0)
61
- i18n (1.0.1)
78
+ i18n (1.8.5)
62
79
  concurrent-ruby (~> 1.0)
63
- json (2.1.0)
64
- loofah (2.2.2)
80
+ loofah (2.8.0)
65
81
  crass (~> 1.0.2)
66
82
  nokogiri (>= 1.5.9)
67
- mail (2.7.0)
83
+ mail (2.7.1)
68
84
  mini_mime (>= 0.1.1)
69
- marcel (0.3.2)
85
+ marcel (0.3.3)
70
86
  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)
87
+ method_source (1.0.0)
88
+ mimemagic (0.3.5)
89
+ mini_mime (1.0.2)
90
+ mini_portile2 (2.4.0)
91
+ minitest (5.14.2)
92
+ minitest-reporters (1.4.2)
77
93
  ansi
78
94
  builder
79
95
  minitest (>= 5.0)
80
96
  ruby-progressbar
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)
87
- powerpack (0.1.1)
88
- rack (2.0.5)
97
+ nio4r (2.5.4)
98
+ nokogiri (1.10.10)
99
+ mini_portile2 (~> 2.4.0)
100
+ parallel (1.20.1)
101
+ parser (2.7.2.0)
102
+ ast (~> 2.4.1)
103
+ rack (2.2.3)
89
104
  rack-test (1.1.0)
90
105
  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)
106
+ rails (6.1.0)
107
+ actioncable (= 6.1.0)
108
+ actionmailbox (= 6.1.0)
109
+ actionmailer (= 6.1.0)
110
+ actionpack (= 6.1.0)
111
+ actiontext (= 6.1.0)
112
+ actionview (= 6.1.0)
113
+ activejob (= 6.1.0)
114
+ activemodel (= 6.1.0)
115
+ activerecord (= 6.1.0)
116
+ activestorage (= 6.1.0)
117
+ activesupport (= 6.1.0)
118
+ bundler (>= 1.15.0)
119
+ railties (= 6.1.0)
103
120
  sprockets-rails (>= 2.0.0)
104
121
  rails-dom-testing (2.0.3)
105
122
  activesupport (>= 4.2.0)
106
123
  nokogiri (>= 1.6)
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)
124
+ rails-html-sanitizer (1.3.0)
125
+ loofah (~> 2.3)
126
+ railties (6.1.0)
127
+ actionpack (= 6.1.0)
128
+ activesupport (= 6.1.0)
112
129
  method_source
113
130
  rake (>= 0.8.7)
114
- thor (>= 0.18.1, < 2.0)
131
+ thor (~> 1.0)
115
132
  rainbow (3.0.0)
116
- rake (12.3.1)
117
- rubocop (0.54.0)
133
+ rake (13.0.3)
134
+ regexp_parser (2.0.1)
135
+ rexml (3.2.4)
136
+ rubocop (0.93.1)
118
137
  parallel (~> 1.10)
119
- parser (>= 2.5)
120
- powerpack (~> 0.1)
138
+ parser (>= 2.7.1.5)
121
139
  rainbow (>= 2.2.2, < 4.0)
140
+ regexp_parser (>= 1.8)
141
+ rexml
142
+ rubocop-ast (>= 0.6.0)
122
143
  ruby-progressbar (~> 1.7)
123
- unicode-display_width (~> 1.0, >= 1.0.1)
124
- ruby-progressbar (1.9.0)
125
- simplecov (0.16.1)
144
+ unicode-display_width (>= 1.4.0, < 2.0)
145
+ rubocop-ast (1.3.0)
146
+ parser (>= 2.7.1.5)
147
+ rubocop-performance (1.9.1)
148
+ rubocop (>= 0.90.0, < 2.0)
149
+ rubocop-ast (>= 0.4.0)
150
+ rubocop-rails (2.9.1)
151
+ activesupport (>= 4.2.0)
152
+ rack (>= 1.1)
153
+ rubocop (>= 0.90.0, < 2.0)
154
+ ruby-progressbar (1.10.1)
155
+ simplecov (0.20.0)
126
156
  docile (~> 1.1)
127
- json (>= 1.8, < 3)
128
- simplecov-html (~> 0.10.0)
129
- simplecov-html (0.10.2)
130
- sprockets (3.7.2)
157
+ simplecov-html (~> 0.11)
158
+ simplecov_json_formatter (~> 0.1)
159
+ simplecov-html (0.12.3)
160
+ simplecov_json_formatter (0.1.2)
161
+ sprockets (4.0.2)
131
162
  concurrent-ruby (~> 1.0)
132
163
  rack (> 1, < 3)
133
- sprockets-rails (3.2.1)
164
+ sprockets-rails (3.2.2)
134
165
  actionpack (>= 4.0)
135
166
  activesupport (>= 4.0)
136
167
  sprockets (>= 3.0.0)
137
- thor (0.20.0)
138
- thread_safe (0.3.6)
139
- tzinfo (1.2.5)
140
- thread_safe (~> 0.1)
141
- unicode-display_width (1.3.0)
142
- websocket-driver (0.7.0)
168
+ thor (1.0.1)
169
+ tzinfo (2.0.4)
170
+ concurrent-ruby (~> 1.0)
171
+ unicode-display_width (1.7.0)
172
+ websocket-driver (0.7.3)
143
173
  websocket-extensions (>= 0.1.0)
144
- websocket-extensions (0.1.3)
174
+ websocket-extensions (0.1.5)
175
+ zeitwerk (2.4.2)
145
176
 
146
177
  PLATFORMS
147
178
  ruby
@@ -149,8 +180,7 @@ PLATFORMS
149
180
  DEPENDENCIES
150
181
  minitest-reporters (~> 1.0)
151
182
  rubocop (~> 0.49)
183
+ rubocop-performance (~> 1.5)
184
+ rubocop-rails (~> 2.4)
152
185
  simple_workflow!
153
186
  simplecov (~> 0.9)
154
-
155
- BUNDLED WITH
156
- 1.16.3
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__) + '/lib/simple_workflow/version'
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'
@@ -24,6 +24,7 @@ desc 'Push the gem to RubyGems'
24
24
  task release: :gem do
25
25
  output = `git status --porcelain`
26
26
  raise "Workspace not clean!\n#{output}" unless output.empty?
27
+
27
28
  sh "git tag #{SimpleWorkflow::VERSION}"
28
29
  sh 'git push --tags'
29
30
  sh "gem push #{GEM_FILE}"
@@ -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
- HTML
76
+ HTML
75
77
  end
76
78
  end
@@ -3,19 +3,26 @@
3
3
  # Utility methods to manage the breadcrumb history
4
4
  module SimpleWorkflow::Detour
5
5
  def store_detour_in_session(session, options)
6
- if session[:detours] && session[:detours].last == options
7
- Rails.logger.try(:debug, "Ignored duplicate detour: #{options.inspect}")
8
- return
6
+ if session[:detours]
7
+ if session[:detours].last == options
8
+ Rails.logger.try(:debug, "Ignored duplicate detour: #{options.inspect}")
9
+ return
10
+ end
11
+ if session[:detours].delete(options)
12
+ Rails.logger.try(:debug, "Deleted duplicate detour: #{options.inspect}")
13
+ end
14
+ else
15
+ session[:detours] = []
9
16
  end
10
- session[:detours] ||= []
11
17
  session[:detours] << options
12
18
  Rails.logger.try(:debug, "Added detour (#{session[:detours].try(:size) || 0}): #{options.inspect}")
13
19
  end
14
20
 
15
- def pop_detour(session)
21
+ def pop_detour(session, origin_options = nil)
16
22
  detours = session[:detours]
17
23
  return nil unless detours
18
- detour = detours.pop
24
+
25
+ detour = detours.delete(origin_options) || detours.pop
19
26
  Rails.logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
20
27
  reset_workflow(session) if detours.empty?
21
28
  detour
@@ -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 =~ /\?/ ? '&' : '?') + origin.to_h.to_param('detour')
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
- if link_options == true
61
+ case link_options
62
+ when true
62
63
  link_options = { method: :post }
63
- elsif link_options == false
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
- if html_options == true
74
+ case html_options
75
+ when true
74
76
  html_options = { method: :post }
75
- elsif html_options == false
77
+ when false
76
78
  html_options = {}
77
79
  end
78
80
  image_options ||= { class: 'image-submit' }
@@ -84,7 +86,12 @@ module SimpleWorkflow::Helper
84
86
  !session[:detours].nil?
85
87
  end
86
88
 
87
- def back_or_link_to(title, options = nil, html_options = nil)
89
+ def back_or_link_to(title, options = nil, html_options = nil, &block)
90
+ if block
91
+ html_options = options
92
+ options = title
93
+ title = nil
94
+ end
88
95
  if session[:detours]
89
96
  link_options = { return_from_detour: true }.update(session[:detours].last)
90
97
 
@@ -97,7 +104,13 @@ module SimpleWorkflow::Helper
97
104
  link_options = options
98
105
  end
99
106
 
100
- link_to(title, link_options, html_options) if link_options
107
+ if link_options
108
+ if block
109
+ link_to(link_options, html_options, &block)
110
+ else
111
+ link_to(title, link_options, html_options)
112
+ end
113
+ end
101
114
  rescue ActionController::UrlGenerationError => e
102
115
  if session[:detours]
103
116
  logger.error "Exception linking to origin: #{e.class} #{e}"
@@ -43,6 +43,7 @@ class SimpleWorkflow::Middleware
43
43
 
44
44
  def remove_old_detours(env)
45
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
- (session_size >= 3072 && session[:detours] && !session[:detours].empty?)
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
@@ -78,7 +82,7 @@ class SimpleWorkflow::Middleware
78
82
  Rails.logger.warn "simple_workflow: session: #{session.to_hash}"
79
83
  end
80
84
 
81
- if ActionPack::VERSION::MAJOR == 5
85
+ if ActionPack::VERSION::MAJOR >= 5
82
86
  def serialize_session(cookie_jar, session)
83
87
  cookie_jar.send(:serialize, session)
84
88
  end
@@ -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,8 @@ 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]
108
- pop_detour(session(env))
114
+
115
+ params_hash = params(env).to_h.reject { |k, _v| %i[detour return_from_detour].include? k.to_sym }
116
+ pop_detour(session(env), params_hash)
109
117
  end
110
118
  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.send :include, SimpleWorkflow::Helper
10
+ ActionView::Base.include SimpleWorkflow::Helper
11
11
 
12
12
  # Make workflow test utility methods available in controllers
13
- ActionController::Base.send :include, SimpleWorkflow::Helper
14
- ActionController::Base.send :include, SimpleWorkflow::Controller
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.send :include, SimpleWorkflow::TestHelper
17
+ ActiveSupport::TestCase.include SimpleWorkflow::TestHelper
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleWorkflow
4
- VERSION = '1.6.0'
4
+ VERSION = '2.1.0'
5
5
  end
Binary file
@@ -0,0 +1,27 @@
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.date = Date.today.strftime '%Y-%m-%d' # rubocop:disable Rails/Date
11
+ s.authors = ['Uwe Kubosch']
12
+ s.email = 'uwe@kubosch.no'
13
+ s.summary = 'Add simple breadcrumbs "detour" workflow to Ruby On Rails.'
14
+ s.homepage = 'https://github.com/donv/simple_workflow'
15
+ s.description = 'Expands Ruby on Rails to allow simple breadcrumb detour workflows.'
16
+ s.required_ruby_version = '>= 2.5', '<4'
17
+ s.licenses = %w[MIT]
18
+ s.files = FileList['[A-Z]*', 'lib/**/*', 'test/**/*'].to_a
19
+
20
+ s.add_runtime_dependency('rails', '>=4.2', '<7')
21
+
22
+ s.add_development_dependency('minitest-reporters', '~>1.0')
23
+ s.add_development_dependency('rubocop', '~>1.0')
24
+ s.add_development_dependency('rubocop-performance', '~>1.5')
25
+ s.add_development_dependency('rubocop-rails', '~>2.4')
26
+ s.add_development_dependency('simplecov', '~>0.9')
27
+ end
@@ -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 if Rails.version !~ /^4\.1\./
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
@@ -10,18 +10,24 @@ class HelperTest < MiniTest::Test
10
10
  def test_with_detour
11
11
  assert_equal '?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42' \
12
12
  '&detour%5Bquery%5D%5Bnested%5D=criterium',
13
- with_detour('')
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
- with_detour('', controller: :dashboard, action: :index)
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
23
  '&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42&detour%5Bquery%5D%5Bnested%5D=criterium',
24
- with_detour('', anchor: :tab_2)
24
+ with_detour('', anchor: :tab_2)
25
+ end
26
+
27
+ module SimpleWorkflow::Controller
28
+ def self.binary_params_for?(_action)
29
+ false
30
+ end
25
31
  end
26
32
 
27
33
  def test_with_detour_with_string_origin
@@ -33,7 +39,7 @@ class HelperTest < MiniTest::Test
33
39
 
34
40
  assert_equal '?detour%5Baction%5D=index&detour%5Banchor%5D=tab_2' \
35
41
  '&detour%5Bcontroller%5D=simple_workflow%2F&detour%5Bhullo%5D=1',
36
- with_detour('', '/dashboard/index?hullo=1#tab_2')
42
+ with_detour('', '/dashboard/index?hullo=1#tab_2')
37
43
  ensure
38
44
  Rails.application = nil
39
45
  end
@@ -45,7 +51,7 @@ class HelperTest < MiniTest::Test
45
51
  '&detour%5Bquery%5D%5Bnested%5D=criterium',
46
52
  { id: 'link_tag_id', title: 'Link title' },
47
53
  ],
48
- detour_to('Link Text', 'Link target', id: 'link_tag_id', title: 'Link title')
54
+ detour_to('Link Text', 'Link target', id: 'link_tag_id', title: 'Link title')
49
55
  end
50
56
 
51
57
  def test_image_button_to
@@ -56,26 +62,27 @@ class HelperTest < MiniTest::Test
56
62
  onclick: "form.action='{:id=>\"image_tag_id\"}'"
57
63
  }
58
64
  ],
59
- image_button_to('my_image.png', 'Link Title', { id: 'image_tag_id' }, title: 'Image title')
65
+ image_button_to('my_image.png', 'Link Title', { id: 'image_tag_id' },
66
+ title: 'Image title')
60
67
  end
61
68
 
62
69
  def test_image_link_to
63
70
  assert_equal [
64
71
  ['my_image.png', { title: 'Link Title', alt: 'Link Title' }], { id: 'image_tag_id' }, nil
65
72
  ],
66
- image_link_to('my_image.png', 'Link Title', { id: 'image_tag_id' }, title: 'Image title')
73
+ image_link_to('my_image.png', 'Link Title', { id: 'image_tag_id' }, title: 'Image title')
67
74
  end
68
75
 
69
76
  def test_back_or_link_to
70
77
  assert_equal ['Link title', { controller: :mycontroller, action: :my_action }, nil],
71
- back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
78
+ back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
72
79
  end
73
80
 
74
81
  def test_back_or_link_to_with_routing_error
75
82
  @session = { detours: [{ controller: :does_not_exist }] }
76
83
  @routing_error = ActionController::UrlGenerationError
77
84
  assert_equal ['Link title', { controller: :mycontroller, action: :my_action }, nil],
78
- back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
85
+ back_or_link_to('Link title', controller: :mycontroller, action: :my_action)
79
86
  end
80
87
 
81
88
  private
@@ -87,7 +94,7 @@ class HelperTest < MiniTest::Test
87
94
  def params
88
95
  ActionController::Parameters.new(
89
96
  controller: 'mycontroller', action: 'myaction', id: 42, query: { nested: 'criterium' }
90
- )
97
+ )
91
98
  end
92
99
 
93
100
  def session
@@ -102,7 +109,7 @@ class HelperTest < MiniTest::Test
102
109
  if defined?(@routing_error) && @routing_error
103
110
  e = @routing_error
104
111
  @routing_error = nil
105
- raise e
112
+ raise e, 'Error'
106
113
  end
107
114
  options
108
115
  end
@@ -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
- 'rack.session' => env['rack.session'], 'rack.session.options' => env['rack.session.options'])
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
- 'rack.session' => env['rack.session'], 'rack.session.options' => env['rack.session.options'])
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
- env['rack.session'].to_hash['detours'])
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
- 'rack.session' => headers1['rack.session'],
81
- 'rack.session.options' => headers1['rack.session.options'])
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
@@ -92,13 +94,14 @@ class MiddlewareTest < MiniTest::Test
92
94
 
93
95
  def env_for(url, opts = {})
94
96
  default_opts = {
97
+ ActionDispatch::Cookies::COOKIES_ROTATIONS => ActiveSupport::Messages::RotationConfiguration.new,
95
98
  ActionDispatch::Cookies::COOKIES_SERIALIZER => :json,
96
99
  ActionDispatch::Cookies::ENCRYPTED_COOKIE_SALT => 'salt',
97
100
  ActionDispatch::Cookies::ENCRYPTED_SIGNED_COOKIE_SALT => 'signed_salt',
98
101
  ActionDispatch::Cookies::GENERATOR_KEY => ActiveSupport::KeyGenerator.new('secret'),
99
102
  ActionDispatch::Cookies::SECRET_KEY_BASE => 'secret',
100
103
  }
101
- if Rails.version =~ /^5\.2\./
104
+ if /^5\.2\./.match?(Rails.version)
102
105
  default_opts[ActionDispatch::Cookies::COOKIES_ROTATIONS] = Struct.new(:encrypted).new([])
103
106
  end
104
107
  Rack::MockRequest.env_for(url, default_opts.update(opts))
data/test/test_helper.rb CHANGED
@@ -13,8 +13,10 @@ MiniTest::Reporters.use!
13
13
  require 'rails'
14
14
  require 'simple_workflow'
15
15
 
16
- if Gem::Requirement.new('~>4.2') =~ Gem::Version.new(Rails.version)
17
- ActiveSupport::TestCase.test_order = :random
18
- end
19
-
20
16
  FileUtils.mkdir_p File.expand_path '../log', __dir__
17
+
18
+ module SimpleWorkflow::Controller
19
+ def self.action_encoding_template(action)
20
+ false
21
+ end
22
+ 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: 1.6.0
4
+ version: 2.1.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: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.2'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.3'
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.2'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.3'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: minitest-reporters
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,42 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.49'
53
+ version: '1.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rubocop-performance
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.5'
54
68
  type: :development
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '0.49'
74
+ version: '1.5'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rubocop-rails
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.4'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.4'
61
89
  - !ruby/object:Gem::Dependency
62
90
  name: simplecov
63
91
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +119,8 @@ files:
91
119
  - lib/simple_workflow/railtie.rb
92
120
  - lib/simple_workflow/test_helper.rb
93
121
  - lib/simple_workflow/version.rb
122
+ - simple_workflow-2.0.0.gem
123
+ - simple_workflow.gemspec
94
124
  - test/controller_test.rb
95
125
  - test/helper_test.rb
96
126
  - test/middleware_test.rb
@@ -100,24 +130,26 @@ homepage: https://github.com/donv/simple_workflow
100
130
  licenses:
101
131
  - MIT
102
132
  metadata: {}
103
- post_install_message:
133
+ post_install_message:
104
134
  rdoc_options: []
105
135
  require_paths:
106
136
  - lib
107
137
  required_ruby_version: !ruby/object:Gem::Requirement
108
138
  requirements:
109
- - - "~>"
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '2.5'
142
+ - - "<"
110
143
  - !ruby/object:Gem::Version
111
- version: '2.3'
144
+ version: '4'
112
145
  required_rubygems_version: !ruby/object:Gem::Requirement
113
146
  requirements:
114
147
  - - ">="
115
148
  - !ruby/object:Gem::Version
116
149
  version: '0'
117
150
  requirements: []
118
- rubyforge_project: donv/simple_workflow
119
- rubygems_version: 2.6.14.1
120
- signing_key:
151
+ rubygems_version: 3.2.3
152
+ signing_key:
121
153
  specification_version: 4
122
154
  summary: Add simple breadcrumbs "detour" workflow to Ruby On Rails.
123
155
  test_files: []