simple_workflow 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dc2eb7f7486fae6bba42f7acadb84fb2798b82a
4
- data.tar.gz: 8fba0bdfe4cb7d7c1ac4a184dc52b66b2f085609
3
+ metadata.gz: 8d83a47aa996c464e96be5e71195bbb00ec40047
4
+ data.tar.gz: 2b55806fd6574b7994e8b5ecf3d050f64177aba1
5
5
  SHA512:
6
- metadata.gz: c5deb94819599f83ddfe674816cff0eff8930165c4a04e8a58f0f09d88b430eecf14a7ef9c596af764b9ff143ab12a39d115367974703f9ef7f6539e9b83f016
7
- data.tar.gz: 513196edb3332f82756d838311db12d22bef5886c890c3d93fdcd173ef2d48389b88dde9adbebe1e2adb6dbf428e3e3e6058771a3cc52d3d3262845f9a7ef0cb
6
+ metadata.gz: 9d84f201c4fa11d82737ad2c30d10ab074955e509337cc3477a6dd2de34621b781e36f6f00f3840d5b327669a20c65e64d265ce8f9a0457ebd2f158cb0f14426
7
+ data.tar.gz: 76dc75ecd93c8ccc7efebcc64dca28b27ec939c3b469bb223dc51cecf1fd499268a30ed587b8f2e290f62a814076c4993c068700c9ac6668a6b3d8766931a04e
data/Gemfile.lock CHANGED
@@ -1,110 +1,111 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_workflow (1.2.0)
5
- rails (~> 4.0)
4
+ simple_workflow (1.3.0)
5
+ rails (>= 4, < 5.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionmailer (4.2.7.1)
11
- actionpack (= 4.2.7.1)
12
- actionview (= 4.2.7.1)
13
- activejob (= 4.2.7.1)
10
+ actioncable (5.0.1)
11
+ actionpack (= 5.0.1)
12
+ nio4r (~> 1.2)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.1)
15
+ actionpack (= 5.0.1)
16
+ actionview (= 5.0.1)
17
+ activejob (= 5.0.1)
14
18
  mail (~> 2.5, >= 2.5.4)
15
- rails-dom-testing (~> 1.0, >= 1.0.5)
16
- actionpack (4.2.7.1)
17
- actionview (= 4.2.7.1)
18
- activesupport (= 4.2.7.1)
19
- rack (~> 1.6)
20
- rack-test (~> 0.6.2)
21
- rails-dom-testing (~> 1.0, >= 1.0.5)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.1)
21
+ actionview (= 5.0.1)
22
+ activesupport (= 5.0.1)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
22
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
- actionview (4.2.7.1)
24
- activesupport (= 4.2.7.1)
27
+ actionview (5.0.1)
28
+ activesupport (= 5.0.1)
25
29
  builder (~> 3.1)
26
30
  erubis (~> 2.7.0)
27
- rails-dom-testing (~> 1.0, >= 1.0.5)
31
+ rails-dom-testing (~> 2.0)
28
32
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
- activejob (4.2.7.1)
30
- activesupport (= 4.2.7.1)
31
- globalid (>= 0.3.0)
32
- activemodel (4.2.7.1)
33
- activesupport (= 4.2.7.1)
34
- builder (~> 3.1)
35
- activerecord (4.2.7.1)
36
- activemodel (= 4.2.7.1)
37
- activesupport (= 4.2.7.1)
38
- arel (~> 6.0)
39
- activesupport (4.2.7.1)
33
+ activejob (5.0.1)
34
+ activesupport (= 5.0.1)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.1)
37
+ activesupport (= 5.0.1)
38
+ activerecord (5.0.1)
39
+ activemodel (= 5.0.1)
40
+ activesupport (= 5.0.1)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.1)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
40
44
  i18n (~> 0.7)
41
- json (~> 1.7, >= 1.7.7)
42
45
  minitest (~> 5.1)
43
- thread_safe (~> 0.3, >= 0.3.4)
44
46
  tzinfo (~> 1.1)
45
47
  ansi (1.5.0)
46
- arel (6.0.3)
48
+ arel (7.1.4)
47
49
  ast (2.3.0)
48
50
  builder (3.2.2)
49
- concurrent-ruby (1.0.2)
50
- concurrent-ruby (1.0.2-java)
51
+ concurrent-ruby (1.0.3)
51
52
  docile (1.1.5)
52
53
  erubis (2.7.0)
53
54
  globalid (0.3.7)
54
55
  activesupport (>= 4.1.0)
55
56
  i18n (0.7.0)
56
- json (1.8.3)
57
- json (1.8.3-java)
57
+ json (2.0.2)
58
+ json (2.0.2-java)
58
59
  loofah (2.0.3)
59
60
  nokogiri (>= 1.5.9)
60
61
  mail (2.6.4)
61
62
  mime-types (>= 1.16, < 4)
63
+ method_source (0.8.2)
62
64
  mime-types (3.1)
63
65
  mime-types-data (~> 3.2015)
64
66
  mime-types-data (3.2016.0521)
65
67
  mini_portile2 (2.1.0)
66
- minitest (5.9.1)
67
- minitest-reporters (1.1.12)
68
+ minitest (5.10.1)
69
+ minitest-reporters (1.1.13)
68
70
  ansi
69
71
  builder
70
72
  minitest (>= 5.0)
71
73
  ruby-progressbar
74
+ nio4r (1.2.1)
72
75
  nokogiri (1.6.8.1)
73
76
  mini_portile2 (~> 2.1.0)
74
- nokogiri (1.6.8.1-java)
75
- parser (2.3.1.4)
77
+ parser (2.3.3.1)
76
78
  ast (~> 2.2)
77
79
  powerpack (0.1.1)
78
- rack (1.6.4)
80
+ rack (2.0.1)
79
81
  rack-test (0.6.3)
80
82
  rack (>= 1.0)
81
- rails (4.2.7.1)
82
- actionmailer (= 4.2.7.1)
83
- actionpack (= 4.2.7.1)
84
- actionview (= 4.2.7.1)
85
- activejob (= 4.2.7.1)
86
- activemodel (= 4.2.7.1)
87
- activerecord (= 4.2.7.1)
88
- activesupport (= 4.2.7.1)
83
+ rails (5.0.1)
84
+ actioncable (= 5.0.1)
85
+ actionmailer (= 5.0.1)
86
+ actionpack (= 5.0.1)
87
+ actionview (= 5.0.1)
88
+ activejob (= 5.0.1)
89
+ activemodel (= 5.0.1)
90
+ activerecord (= 5.0.1)
91
+ activesupport (= 5.0.1)
89
92
  bundler (>= 1.3.0, < 2.0)
90
- railties (= 4.2.7.1)
91
- sprockets-rails
92
- rails-deprecated_sanitizer (1.0.3)
93
- activesupport (>= 4.2.0.alpha)
94
- rails-dom-testing (1.0.7)
95
- activesupport (>= 4.2.0.beta, < 5.0)
93
+ railties (= 5.0.1)
94
+ sprockets-rails (>= 2.0.0)
95
+ rails-dom-testing (2.0.1)
96
+ activesupport (>= 4.2.0, < 6.0)
96
97
  nokogiri (~> 1.6.0)
97
- rails-deprecated_sanitizer (>= 1.0.1)
98
98
  rails-html-sanitizer (1.0.3)
99
99
  loofah (~> 2.0)
100
- railties (4.2.7.1)
101
- actionpack (= 4.2.7.1)
102
- activesupport (= 4.2.7.1)
100
+ railties (5.0.1)
101
+ actionpack (= 5.0.1)
102
+ activesupport (= 5.0.1)
103
+ method_source
103
104
  rake (>= 0.8.7)
104
105
  thor (>= 0.18.1, < 2.0)
105
106
  rainbow (2.1.0)
106
- rake (11.3.0)
107
- rubocop (0.45.0)
107
+ rake (12.0.0)
108
+ rubocop (0.46.0)
108
109
  parser (>= 2.3.1.1, < 3.0)
109
110
  powerpack (~> 0.1)
110
111
  rainbow (>= 1.99.1, < 3.0)
@@ -116,19 +117,21 @@ GEM
116
117
  json (>= 1.8, < 3)
117
118
  simplecov-html (~> 0.10.0)
118
119
  simplecov-html (0.10.0)
119
- sprockets (3.7.0)
120
+ sprockets (3.7.1)
120
121
  concurrent-ruby (~> 1.0)
121
122
  rack (> 1, < 3)
122
123
  sprockets-rails (3.2.0)
123
124
  actionpack (>= 4.0)
124
125
  activesupport (>= 4.0)
125
126
  sprockets (>= 3.0.0)
126
- thor (0.19.1)
127
+ thor (0.19.4)
127
128
  thread_safe (0.3.5)
128
- thread_safe (0.3.5-java)
129
129
  tzinfo (1.2.2)
130
130
  thread_safe (~> 0.1)
131
- unicode-display_width (1.1.1)
131
+ unicode-display_width (1.1.2)
132
+ websocket-driver (0.6.4)
133
+ websocket-extensions (>= 0.1.0)
134
+ websocket-extensions (0.1.2)
132
135
 
133
136
  PLATFORMS
134
137
  java
data/Rakefile CHANGED
@@ -3,8 +3,8 @@ require 'rake/clean'
3
3
  require 'rake/testtask'
4
4
  require File.dirname(__FILE__) + '/lib/simple_workflow/version'
5
5
 
6
- GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
7
- GEM_SPEC_FILE = 'simple_workflow.gemspec'
6
+ GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem".freeze
7
+ GEM_SPEC_FILE = 'simple_workflow.gemspec'.freeze
8
8
 
9
9
  CLEAN.include('simple_workflow-*.gem', 'tmp')
10
10
 
@@ -13,10 +13,10 @@ task default: :test
13
13
  desc 'Generate a gem'
14
14
  task gem: GEM_FILE
15
15
 
16
- file(GEM_FILE => GEM_SPEC_FILE) {
16
+ file(GEM_FILE => GEM_SPEC_FILE) do
17
17
  puts "Generating #{GEM_FILE}"
18
18
  `gem build #{GEM_SPEC_FILE}`
19
- }
19
+ end
20
20
 
21
21
  desc 'Push the gem to RubyGems'
22
22
  task release: :gem do
@@ -16,7 +16,7 @@ module SimpleWorkflow::Controller
16
16
 
17
17
  def rjs_redirect_to(options)
18
18
  @options = options
19
- render :template => 'redirect', :layout => false, :formats => :js
19
+ render template: 'redirect', layout: false, formats: :js
20
20
  end
21
21
 
22
22
  def store_detour(options, post = false)
@@ -25,17 +25,12 @@ module SimpleWorkflow::Controller
25
25
  store_detour_in_session(session, options)
26
26
  end
27
27
 
28
- def store_detour_from_params
29
- end
30
- deprecate :store_detour_from_params,
31
- deprecator: ActiveSupport::Deprecation.new('1.2', 'SimpleWorkflow') # TODO(uwe)
32
-
33
28
  def back(response_status_and_flash)
34
29
  return false if session[:detours].nil?
35
30
  detour = pop_detour(session)
36
31
  post = detour.delete(:request_method) == :post
37
32
  if post
38
- set_flash(response_status_and_flash)
33
+ save_flash(response_status_and_flash)
39
34
  redirect_to_post(detour)
40
35
  else
41
36
  redirect_to detour, response_status_and_flash
@@ -46,10 +41,10 @@ module SimpleWorkflow::Controller
46
41
  end
47
42
 
48
43
  def back_or_redirect_to(options = {}, response_status_and_flash = {})
49
- back(response_status_and_flash) or redirect_to(options, response_status_and_flash)
44
+ back(response_status_and_flash) || redirect_to(options, response_status_and_flash)
50
45
  end
51
46
 
52
- def set_flash(response_status_and_flash)
47
+ def save_flash(response_status_and_flash)
53
48
  if (alert = response_status_and_flash.delete(:alert))
54
49
  flash[:alert] = alert
55
50
  end
@@ -62,11 +57,11 @@ module SimpleWorkflow::Controller
62
57
  flash.update(other_flashes)
63
58
  end
64
59
  end
65
- private :set_flash
60
+ private :save_flash
66
61
 
67
62
  def redirect_to_post(options)
68
63
  url = url_for options
69
- render :text => <<EOF, :layout => false
64
+ render text: <<EOF, layout: false
70
65
  <html>
71
66
  <body onload="document.getElementById('form').submit()">
72
67
  <form id="form" action="#{url}" method="POST">
@@ -75,5 +70,4 @@ module SimpleWorkflow::Controller
75
70
  </html>
76
71
  EOF
77
72
  end
78
-
79
73
  end
@@ -1,8 +1,8 @@
1
1
  module SimpleWorkflow::Helper
2
2
  def image_button_to(image_source, title, options, html_options = {})
3
- image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title,
4
- :id => "#{title}_#{options[:id]}", :name => title,
5
- :onclick => "form.action='#{url_for(options)}'"}.update(html_options)
3
+ image_submit_tag image_source, { class: 'image-submit', alt: title, title: title,
4
+ id: "#{title}_#{options[:id]}", name: title,
5
+ onclick: "form.action='#{url_for(options)}'" }.update(html_options)
6
6
  end
7
7
 
8
8
  def detour_to(title, options = nil, html_options = nil, &block)
@@ -33,44 +33,44 @@ module SimpleWorkflow::Helper
33
33
  end
34
34
 
35
35
  def origin_options
36
- params.reject { |k, v| [:detour, :return_from_detour].include? k.to_sym }
36
+ params.reject { |k, _v| [:detour, :return_from_detour].include? k.to_sym }
37
37
  end
38
38
 
39
39
  def image_detour_to(image_source, title, url_options, image_options = nil, link_options = nil)
40
- image_options ||= {:class => 'image-submit'}
41
- image_options.update :alt => title, :title => title
40
+ image_options ||= { class: 'image-submit' }
41
+ image_options.update alt: title, title: title
42
42
  detour_to image_tag(image_source, image_options), url_options, link_options
43
43
  end
44
44
 
45
45
  def image_link_to(image_source, title, url_options, image_options = nil, link_options = nil)
46
46
  if link_options == true
47
- link_options = {:method => :post}
47
+ link_options = { method: :post }
48
48
  elsif link_options == false
49
49
  link_options = nil
50
50
  end
51
- image_options ||= {:class => 'image-submit'}
52
- image_options.update :alt => title, :title => title
51
+ image_options ||= { class: 'image-submit' }
52
+ image_options.update alt: title, title: title
53
53
  link_to image_tag(image_source, image_options), url_options, link_options
54
54
  end
55
55
 
56
56
  def image_link_to_remote(image_source, title, link_options, image_options = nil, html_options = {})
57
57
  if html_options == true
58
- html_options = {:method => :post}
58
+ html_options = { method: :post }
59
59
  elsif html_options == false
60
60
  html_options = {}
61
61
  end
62
- image_options ||= {:class => 'image-submit'}
63
- image_options.update :alt => title, :title => title
64
- link_to image_tag(image_source, image_options), link_options, html_options.merge(:remote => true)
62
+ image_options ||= { class: 'image-submit' }
63
+ image_options.update alt: title, title: title
64
+ link_to image_tag(image_source, image_options), link_options, html_options.merge(remote: true)
65
65
  end
66
66
 
67
67
  def detour?
68
- not session[:detours].nil?
68
+ !session[:detours].nil?
69
69
  end
70
70
 
71
71
  def back_or_link_to(title, options = nil, html_options = nil)
72
72
  if session[:detours]
73
- options = {:return_from_detour => true}.update(session[:detours].last)
73
+ options = { return_from_detour: true }.update(session[:detours].last)
74
74
 
75
75
  # FIXME(uwe): Write a test to prove this line is needed.
76
76
  options['id'] ||= nil
@@ -80,5 +80,4 @@ module SimpleWorkflow::Helper
80
80
  end
81
81
  link_to(title, options, html_options) if options
82
82
  end
83
-
84
83
  end
@@ -45,11 +45,11 @@ class SimpleWorkflow::Middleware
45
45
  cookie_jar = cookie_jar(env)
46
46
  encryptor = encryptor(env)
47
47
  loop do
48
- ser_val = cookie_jar.send(:serialize, nil, session.to_hash)
48
+ ser_val = serialize_session(cookie_jar, session.to_hash)
49
49
  session_size = encryptor.encrypt_and_sign(ser_val).size
50
- wf_ser_val = cookie_jar.send(:serialize, nil, session[:detours])
50
+ wf_ser_val = serialize_session(cookie_jar, session[:detours])
51
51
  workflow_size = encryptor.encrypt_and_sign(wf_ser_val).size
52
- break unless workflow_size >= 2048 || (session_size >= 3072 && session[:detours] && session[:detours].size > 0)
52
+ break unless workflow_size >= 2048 || (session_size >= 3072 && session[:detours] && !session[:detours].empty?)
53
53
  Rails.logger.warn "Workflow too large (#{workflow_size}/#{session_size}). Dropping oldest detour."
54
54
  session[:detours].shift
55
55
  reset_workflow(session) if session[:detours].empty?
@@ -67,14 +67,24 @@ class SimpleWorkflow::Middleware
67
67
  end
68
68
  end
69
69
 
70
+ if ActionPack::VERSION::MAJOR == 5
71
+ def serialize_session(cookie_jar, session)
72
+ cookie_jar.send(:serialize, session)
73
+ end
74
+ else # Rails 4.x
75
+ def serialize_session(cookie_jar, session)
76
+ cookie_jar.send(:serialize, nil, session)
77
+ end
78
+ end
79
+
70
80
  def encryptor(env)
71
81
  return @simple_workflow_encryptor if @simple_workflow_encryptor
72
82
  @simple_workflow_encryptor = cookie_jar(env).instance_variable_get(:@encryptor)
73
83
  return @simple_workflow_encryptor if @simple_workflow_encryptor
74
84
  Rails.logger.warn 'simple_workflow: Could not get encryptor from the cookie jar'
75
85
  secret_key_base = Rails.application.config.secret_key_base ||
76
- Rails.application.config.secret_token ||
77
- SecureRandom.hex(64)
86
+ Rails.application.config.secret_token ||
87
+ SecureRandom.hex(64)
78
88
  key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
79
89
  key_generator = ActiveSupport::CachingKeyGenerator.new(key_generator)
80
90
  secret = key_generator.generate_key('encrypted cookie')
@@ -90,5 +100,4 @@ class SimpleWorkflow::Middleware
90
100
  pop_detour(session(env))
91
101
  end
92
102
  end
93
-
94
103
  end
@@ -1,5 +1,5 @@
1
1
  module SimpleWorkflow::TestHelper
2
- def add_stored_detour(location = {:controller => :bogus, :action => :location})
2
+ def add_stored_detour(location = { controller: :bogus, action: :location })
3
3
  @request.session[:detours] = [location]
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleWorkflow
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -1,4 +1,6 @@
1
- $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ unless $LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ end
2
4
 
3
5
  require 'action_controller'
4
6
 
@@ -6,41 +6,34 @@ class ControllerTest < MiniTest::Test
6
6
  attr_accessor :cookies, :logger, :session
7
7
 
8
8
  def setup
9
- options = {encrypted_cookie_salt: 'salt1', encrypted_signed_cookie_salt: 'salt2', secret_key_base: 'secret_key_base'}
10
- @cookies = ActionDispatch::Cookies::CookieJar.new(ActiveSupport::KeyGenerator.new('secret'), nil, false, options)
9
+ options = { encrypted_cookie_salt: 'salt1', encrypted_signed_cookie_salt: 'salt2', secret_key_base: 'secret_key_base' }
10
+ if Rails.gem_version < Gem::Version.new('5')
11
+ @cookies = ActionDispatch::Cookies::CookieJar.new(ActiveSupport::KeyGenerator.new('secret'), nil, false, options)
12
+ end
11
13
  @logger = Rails.logger
12
14
  @session = {}
13
15
  @bad_route = false
14
16
  # TODO(uwe): Remove when we stop testing Rails 4.1
15
- if Rails.version !~ /^4\.1\./
16
- Rails.app_class = TestApp
17
- end
17
+ Rails.app_class = TestApp if Rails.version !~ /^4\.1\./
18
18
  # ODOT
19
19
  end
20
20
 
21
21
  def test_store_detour
22
- location = {controller: :mycontroller, action: :myaction}
22
+ location = { controller: :mycontroller, action: :myaction }
23
23
 
24
24
  store_detour(location)
25
25
 
26
- assert_equal({detours: [location]}, session)
27
- end
28
-
29
- # TODO(uwe): Remove. The method does nothing. Just a stub for compatability.
30
- def test_deprecated_store_detour_from_params
31
- store_detour_from_params
32
- assert_equal({}, session)
26
+ assert_equal({ detours: [location] }, session)
33
27
  end
34
- # ODOT
35
28
 
36
29
  def test_back
37
- store_detour({controller: :mycontroller, action: :myaction})
30
+ store_detour(controller: :mycontroller, action: :myaction)
38
31
  back({})
39
32
  assert_equal({}, session)
40
33
  end
41
34
 
42
35
  def test_back_with_invalid_detour # not route
43
- store_detour({controller: :mycontroller, action: :missing_in_action})
36
+ store_detour(controller: :mycontroller, action: :missing_in_action)
44
37
  @bad_route = true
45
38
  back({})
46
39
  assert_equal({}, session)
data/test/helper_test.rb CHANGED
@@ -8,6 +8,15 @@ class HelperTest < MiniTest::Test
8
8
  with_detour('')
9
9
  end
10
10
 
11
+ def test_detour_to
12
+ assert_equal [
13
+ 'Link Text',
14
+ 'Link target?detour%5Baction%5D=myaction&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42&detour%5Bquery%5D%5Bnested%5D=criterium',
15
+ { id: 'link_tag_id', title: 'Link title' }
16
+ ],
17
+ detour_to('Link Text', 'Link target', id: 'link_tag_id', title: 'Link title')
18
+ end
19
+
11
20
  def test_image_button_to
12
21
  assert_equal [
13
22
  'my_image.png', {
@@ -16,19 +25,23 @@ class HelperTest < MiniTest::Test
16
25
  onclick: "form.action='{:id=>\"image_tag_id\"}'"
17
26
  }
18
27
  ],
19
- image_button_to('my_image.png', 'Link Title', {id: 'image_tag_id'}, title: 'Image title')
28
+ image_button_to('my_image.png', 'Link Title', { id: 'image_tag_id' }, title: 'Image title')
20
29
  end
21
30
 
22
31
  private
23
32
 
24
33
  def params
25
- {controller: 'mycontroller', action: 'myaction', id: 42, query: {nested: 'criterium'}}
34
+ { controller: 'mycontroller', action: 'myaction', id: 42, query: { nested: 'criterium' } }
26
35
  end
27
36
 
28
37
  def url_for(options)
29
38
  options.to_s
30
39
  end
31
40
 
41
+ def link_to(*options)
42
+ options
43
+ end
44
+
32
45
  def image_submit_tag(*args)
33
46
  args
34
47
  end
@@ -21,10 +21,10 @@ class MiddlewareTest < MiniTest::Test
21
21
  status, headers, response = @stack.call env
22
22
 
23
23
  assert_equal 200, status
24
- assert_equal(env, headers)
24
+ assert_equal env, headers
25
25
  assert_equal 'app response', response
26
- assert_equal([], headers['rack.session'].to_hash.keys)
27
- assert_equal(nil, headers['rack.session'].to_hash['detours'])
26
+ assert_equal [], headers['rack.session'].to_hash.keys
27
+ assert_nil headers['rack.session'].to_hash['detours']
28
28
  end
29
29
 
30
30
  def test_detour
@@ -36,27 +36,25 @@ class MiddlewareTest < MiniTest::Test
36
36
  assert_equal(env, headers)
37
37
  assert_equal 'app response', response
38
38
  assert_equal(%w(session_id detours), headers['rack.session'].to_hash.keys)
39
- assert_equal([{'controller' => 'test'}], headers['rack.session'].to_hash['detours'])
39
+ assert_equal([{ 'controller' => 'test' }], headers['rack.session'].to_hash['detours'])
40
40
  end
41
41
 
42
42
  def test_detour_cleanup
43
- _, env, _ = @stack.call env_for('/?detour[controller]=test_first')
43
+ _, env, = @stack.call env_for('/?detour[controller]=test_first')
44
44
  (50..99).each do |i|
45
- _, env, _ = @stack.call env_for("/?detour[controller]=test_#{i}",
45
+ _, env, = @stack.call env_for("/?detour[controller]=test_#{i}",
46
46
  'rack.session' => env['rack.session'],
47
- 'rack.session.options' => env['rack.session.options']
48
- )
47
+ 'rack.session.options' => env['rack.session.options'])
49
48
  end
50
49
  status, env, response = @stack.call env_for('/?detour[controller]=test_last',
51
50
  'rack.session' => env['rack.session'],
52
- 'rack.session.options' => env['rack.session.options']
53
- )
51
+ 'rack.session.options' => env['rack.session.options'])
54
52
 
55
53
  assert_equal 200, status
56
54
  assert_equal 'app response', response
57
55
  assert_equal(%w(session_id detours), env['rack.session'].to_hash.keys)
58
56
 
59
- assert_equal([{'controller' => 'test_57'}, {'controller' => 'test_58'}, {'controller' => 'test_59'}, {'controller' => 'test_60'}, {'controller' => 'test_61'}, {'controller' => 'test_62'}, {'controller' => 'test_63'}, {'controller' => 'test_64'}, {'controller' => 'test_65'}, {'controller' => 'test_66'}, {'controller' => 'test_67'}, {'controller' => 'test_68'}, {'controller' => 'test_69'}, {'controller' => 'test_70'}, {'controller' => 'test_71'}, {'controller' => 'test_72'}, {'controller' => 'test_73'}, {'controller' => 'test_74'}, {'controller' => 'test_75'}, {'controller' => 'test_76'}, {'controller' => 'test_77'}, {'controller' => 'test_78'}, {'controller' => 'test_79'}, {'controller' => 'test_80'}, {'controller' => 'test_81'}, {'controller' => 'test_82'}, {'controller' => 'test_83'}, {'controller' => 'test_84'}, {'controller' => 'test_85'}, {'controller' => 'test_86'}, {'controller' => 'test_87'}, {'controller' => 'test_88'}, {'controller' => 'test_89'}, {'controller' => "test_90"}, {"controller" => "test_91"}, {"controller" => "test_92"}, {"controller" => "test_93"}, {"controller" => "test_94"}, {"controller" => "test_95"}, {"controller" => "test_96"}, {"controller" => "test_97"}, {"controller" => "test_98"}, {"controller" => "test_99"}, {"controller" => "test_last"}],
57
+ assert_equal([{ 'controller' => 'test_57' }, { 'controller' => 'test_58' }, { 'controller' => 'test_59' }, { 'controller' => 'test_60' }, { 'controller' => 'test_61' }, { 'controller' => 'test_62' }, { 'controller' => 'test_63' }, { 'controller' => 'test_64' }, { 'controller' => 'test_65' }, { 'controller' => 'test_66' }, { 'controller' => 'test_67' }, { 'controller' => 'test_68' }, { 'controller' => 'test_69' }, { 'controller' => 'test_70' }, { 'controller' => 'test_71' }, { 'controller' => 'test_72' }, { 'controller' => 'test_73' }, { 'controller' => 'test_74' }, { 'controller' => 'test_75' }, { 'controller' => 'test_76' }, { 'controller' => 'test_77' }, { 'controller' => 'test_78' }, { 'controller' => 'test_79' }, { 'controller' => 'test_80' }, { 'controller' => 'test_81' }, { 'controller' => 'test_82' }, { 'controller' => 'test_83' }, { 'controller' => 'test_84' }, { 'controller' => 'test_85' }, { 'controller' => 'test_86' }, { 'controller' => 'test_87' }, { 'controller' => 'test_88' }, { 'controller' => 'test_89' }, { 'controller' => 'test_90' }, { 'controller' => 'test_91' }, { 'controller' => 'test_92' }, { 'controller' => 'test_93' }, { 'controller' => 'test_94' }, { 'controller' => 'test_95' }, { 'controller' => 'test_96' }, { 'controller' => 'test_97' }, { 'controller' => 'test_98' }, { 'controller' => 'test_99' }, { 'controller' => 'test_last' }],
60
58
  env['rack.session'].to_hash['detours'])
61
59
  end
62
60
 
@@ -73,30 +71,28 @@ class MiddlewareTest < MiniTest::Test
73
71
  end
74
72
 
75
73
  def test_return_from_detour
76
- _, headers1, _ = @stack.call env_for('/?detour[controller]=test_first')
74
+ _, headers1, = @stack.call env_for('/?detour[controller]=test_first')
77
75
  env = env_for('/?return_from_detour=true',
78
76
  'rack.session' => headers1['rack.session'],
79
- 'rack.session.options' => headers1['rack.session.options']
80
- )
77
+ 'rack.session.options' => headers1['rack.session.options'])
81
78
  status, headers, response = @stack.call env
82
79
 
83
80
  assert_equal 200, status
84
- assert_equal(env, headers)
81
+ assert_equal env, headers
85
82
  assert_equal 'app response', response
86
- assert_equal(['session_id'], headers['rack.session'].to_hash.keys)
87
- assert_equal(nil, headers['rack.session'].to_hash['detours'])
83
+ assert_equal ['session_id'], headers['rack.session'].to_hash.keys
84
+ assert_nil headers['rack.session'].to_hash['detours']
88
85
  end
89
86
 
90
87
  private
91
88
 
92
- def env_for(url, opts={})
89
+ def env_for(url, opts = {})
93
90
  default_opts = {
94
- ActionDispatch::Cookies::COOKIES_SERIALIZER => :json,
95
- ActionDispatch::Cookies::GENERATOR_KEY => ActiveSupport::KeyGenerator.new('secret'),
96
- ActionDispatch::Cookies::SECRET_KEY_BASE => 'secret',
97
- # ActionDispatch::Cookies::SECRET_TOKEN => 'secret',
91
+ ActionDispatch::Cookies::COOKIES_SERIALIZER => :json,
92
+ ActionDispatch::Cookies::GENERATOR_KEY => ActiveSupport::KeyGenerator.new('secret'),
93
+ ActionDispatch::Cookies::SECRET_KEY_BASE => 'secret',
94
+ # ActionDispatch::Cookies::SECRET_TOKEN => 'secret',
98
95
  }
99
96
  Rack::MockRequest.env_for(url, default_opts.update(opts))
100
97
  end
101
-
102
98
  end
data/test/test_helper.rb CHANGED
@@ -3,7 +3,7 @@ require 'bundler/setup'
3
3
  require 'simplecov'
4
4
  SimpleCov.start do
5
5
  coverage_dir File.expand_path('../coverage', File.dirname(__FILE__))
6
- minimum_coverage 75
6
+ minimum_coverage 76
7
7
  end
8
8
  require 'minitest/autorun'
9
9
  require 'minitest/reporters'
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '4.0'
22
+ version: '5.1'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '4.0'
32
+ version: '5.1'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: simplecov
29
35
  requirement: !ruby/object:Gem::Requirement