simple_workflow 1.1.2 → 1.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 +62 -46
- data/History.rdoc +7 -0
- data/Rakefile +38 -35
- data/lib/simple_workflow/controller.rb +2 -0
- data/lib/simple_workflow/helper.rb +5 -5
- data/lib/simple_workflow/middleware.rb +22 -11
- data/lib/simple_workflow/version.rb +1 -1
- data/test/controller_test.rb +10 -2
- data/test/helper_test.rb +15 -0
- data/test/test_helper.rb +4 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc2eb7f7486fae6bba42f7acadb84fb2798b82a
|
4
|
+
data.tar.gz: 8fba0bdfe4cb7d7c1ac4a184dc52b66b2f085609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5deb94819599f83ddfe674816cff0eff8930165c4a04e8a58f0f09d88b430eecf14a7ef9c596af764b9ff143ab12a39d115367974703f9ef7f6539e9b83f016
|
7
|
+
data.tar.gz: 513196edb3332f82756d838311db12d22bef5886c890c3d93fdcd173ef2d48389b88dde9adbebe1e2adb6dbf428e3e3e6058771a3cc52d3d3262845f9a7ef0cb
|
data/Gemfile.lock
CHANGED
@@ -1,42 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_workflow (1.
|
4
|
+
simple_workflow (1.2.0)
|
5
5
|
rails (~> 4.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (4.2.
|
11
|
-
actionpack (= 4.2.
|
12
|
-
actionview (= 4.2.
|
13
|
-
activejob (= 4.2.
|
10
|
+
actionmailer (4.2.7.1)
|
11
|
+
actionpack (= 4.2.7.1)
|
12
|
+
actionview (= 4.2.7.1)
|
13
|
+
activejob (= 4.2.7.1)
|
14
14
|
mail (~> 2.5, >= 2.5.4)
|
15
15
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
-
actionpack (4.2.
|
17
|
-
actionview (= 4.2.
|
18
|
-
activesupport (= 4.2.
|
16
|
+
actionpack (4.2.7.1)
|
17
|
+
actionview (= 4.2.7.1)
|
18
|
+
activesupport (= 4.2.7.1)
|
19
19
|
rack (~> 1.6)
|
20
20
|
rack-test (~> 0.6.2)
|
21
21
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
22
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
23
|
-
actionview (4.2.
|
24
|
-
activesupport (= 4.2.
|
23
|
+
actionview (4.2.7.1)
|
24
|
+
activesupport (= 4.2.7.1)
|
25
25
|
builder (~> 3.1)
|
26
26
|
erubis (~> 2.7.0)
|
27
27
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
28
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
29
|
-
activejob (4.2.
|
30
|
-
activesupport (= 4.2.
|
29
|
+
activejob (4.2.7.1)
|
30
|
+
activesupport (= 4.2.7.1)
|
31
31
|
globalid (>= 0.3.0)
|
32
|
-
activemodel (4.2.
|
33
|
-
activesupport (= 4.2.
|
32
|
+
activemodel (4.2.7.1)
|
33
|
+
activesupport (= 4.2.7.1)
|
34
34
|
builder (~> 3.1)
|
35
|
-
activerecord (4.2.
|
36
|
-
activemodel (= 4.2.
|
37
|
-
activesupport (= 4.2.
|
35
|
+
activerecord (4.2.7.1)
|
36
|
+
activemodel (= 4.2.7.1)
|
37
|
+
activesupport (= 4.2.7.1)
|
38
38
|
arel (~> 6.0)
|
39
|
-
activesupport (4.2.
|
39
|
+
activesupport (4.2.7.1)
|
40
40
|
i18n (~> 0.7)
|
41
41
|
json (~> 1.7, >= 1.7.7)
|
42
42
|
minitest (~> 5.1)
|
@@ -44,11 +44,13 @@ GEM
|
|
44
44
|
tzinfo (~> 1.1)
|
45
45
|
ansi (1.5.0)
|
46
46
|
arel (6.0.3)
|
47
|
+
ast (2.3.0)
|
47
48
|
builder (3.2.2)
|
48
|
-
concurrent-ruby (1.0.
|
49
|
+
concurrent-ruby (1.0.2)
|
50
|
+
concurrent-ruby (1.0.2-java)
|
49
51
|
docile (1.1.5)
|
50
52
|
erubis (2.7.0)
|
51
|
-
globalid (0.3.
|
53
|
+
globalid (0.3.7)
|
52
54
|
activesupport (>= 4.1.0)
|
53
55
|
i18n (0.7.0)
|
54
56
|
json (1.8.3)
|
@@ -57,31 +59,35 @@ GEM
|
|
57
59
|
nokogiri (>= 1.5.9)
|
58
60
|
mail (2.6.4)
|
59
61
|
mime-types (>= 1.16, < 4)
|
60
|
-
mime-types (3.
|
62
|
+
mime-types (3.1)
|
61
63
|
mime-types-data (~> 3.2015)
|
62
|
-
mime-types-data (3.2016.
|
63
|
-
mini_portile2 (2.
|
64
|
-
minitest (5.
|
65
|
-
minitest-reporters (1.1.
|
64
|
+
mime-types-data (3.2016.0521)
|
65
|
+
mini_portile2 (2.1.0)
|
66
|
+
minitest (5.9.1)
|
67
|
+
minitest-reporters (1.1.12)
|
66
68
|
ansi
|
67
69
|
builder
|
68
70
|
minitest (>= 5.0)
|
69
71
|
ruby-progressbar
|
70
|
-
nokogiri (1.6.
|
71
|
-
mini_portile2 (~> 2.
|
72
|
+
nokogiri (1.6.8.1)
|
73
|
+
mini_portile2 (~> 2.1.0)
|
74
|
+
nokogiri (1.6.8.1-java)
|
75
|
+
parser (2.3.1.4)
|
76
|
+
ast (~> 2.2)
|
77
|
+
powerpack (0.1.1)
|
72
78
|
rack (1.6.4)
|
73
79
|
rack-test (0.6.3)
|
74
80
|
rack (>= 1.0)
|
75
|
-
rails (4.2.
|
76
|
-
actionmailer (= 4.2.
|
77
|
-
actionpack (= 4.2.
|
78
|
-
actionview (= 4.2.
|
79
|
-
activejob (= 4.2.
|
80
|
-
activemodel (= 4.2.
|
81
|
-
activerecord (= 4.2.
|
82
|
-
activesupport (= 4.2.
|
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
89
|
bundler (>= 1.3.0, < 2.0)
|
84
|
-
railties (= 4.2.
|
90
|
+
railties (= 4.2.7.1)
|
85
91
|
sprockets-rails
|
86
92
|
rails-deprecated_sanitizer (1.0.3)
|
87
93
|
activesupport (>= 4.2.0.alpha)
|
@@ -91,29 +97,38 @@ GEM
|
|
91
97
|
rails-deprecated_sanitizer (>= 1.0.1)
|
92
98
|
rails-html-sanitizer (1.0.3)
|
93
99
|
loofah (~> 2.0)
|
94
|
-
railties (4.2.
|
95
|
-
actionpack (= 4.2.
|
96
|
-
activesupport (= 4.2.
|
100
|
+
railties (4.2.7.1)
|
101
|
+
actionpack (= 4.2.7.1)
|
102
|
+
activesupport (= 4.2.7.1)
|
97
103
|
rake (>= 0.8.7)
|
98
104
|
thor (>= 0.18.1, < 2.0)
|
99
|
-
|
100
|
-
|
101
|
-
|
105
|
+
rainbow (2.1.0)
|
106
|
+
rake (11.3.0)
|
107
|
+
rubocop (0.45.0)
|
108
|
+
parser (>= 2.3.1.1, < 3.0)
|
109
|
+
powerpack (~> 0.1)
|
110
|
+
rainbow (>= 1.99.1, < 3.0)
|
111
|
+
ruby-progressbar (~> 1.7)
|
112
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
113
|
+
ruby-progressbar (1.8.1)
|
114
|
+
simplecov (0.12.0)
|
102
115
|
docile (~> 1.1.0)
|
103
|
-
json (
|
116
|
+
json (>= 1.8, < 3)
|
104
117
|
simplecov-html (~> 0.10.0)
|
105
118
|
simplecov-html (0.10.0)
|
106
|
-
sprockets (3.
|
119
|
+
sprockets (3.7.0)
|
107
120
|
concurrent-ruby (~> 1.0)
|
108
121
|
rack (> 1, < 3)
|
109
|
-
sprockets-rails (3.0
|
122
|
+
sprockets-rails (3.2.0)
|
110
123
|
actionpack (>= 4.0)
|
111
124
|
activesupport (>= 4.0)
|
112
125
|
sprockets (>= 3.0.0)
|
113
126
|
thor (0.19.1)
|
114
127
|
thread_safe (0.3.5)
|
128
|
+
thread_safe (0.3.5-java)
|
115
129
|
tzinfo (1.2.2)
|
116
130
|
thread_safe (~> 0.1)
|
131
|
+
unicode-display_width (1.1.1)
|
117
132
|
|
118
133
|
PLATFORMS
|
119
134
|
java
|
@@ -121,8 +136,9 @@ PLATFORMS
|
|
121
136
|
|
122
137
|
DEPENDENCIES
|
123
138
|
minitest-reporters (~> 1.0)
|
139
|
+
rubocop (~> 0.45)
|
124
140
|
simple_workflow!
|
125
141
|
simplecov (~> 0.9)
|
126
142
|
|
127
143
|
BUNDLED WITH
|
128
|
-
1.
|
144
|
+
1.13.6
|
data/History.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -1,35 +1,38 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require File.dirname(__FILE__) + '/lib/simple_workflow/version'
|
5
|
-
|
6
|
-
GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
|
7
|
-
GEM_SPEC_FILE = 'simple_workflow.gemspec'
|
8
|
-
|
9
|
-
CLEAN.include('simple_workflow-*.gem', 'tmp')
|
10
|
-
|
11
|
-
task default: :test
|
12
|
-
|
13
|
-
desc 'Generate a gem'
|
14
|
-
task gem: GEM_FILE
|
15
|
-
|
16
|
-
file(GEM_FILE => GEM_SPEC_FILE) {
|
17
|
-
puts "Generating #{GEM_FILE}"
|
18
|
-
`gem build #{GEM_SPEC_FILE}`
|
19
|
-
}
|
20
|
-
|
21
|
-
desc 'Push the gem to RubyGems'
|
22
|
-
task release: :gem do
|
23
|
-
output = `git status --porcelain`
|
24
|
-
raise "Workspace not clean!\n#{output}" unless output.empty?
|
25
|
-
sh "git tag #{SimpleWorkflow::VERSION}"
|
26
|
-
sh 'git push --tags'
|
27
|
-
sh "gem push #{GEM_FILE}"
|
28
|
-
end
|
29
|
-
|
30
|
-
Rake::TestTask.new do |t|
|
31
|
-
t.libs << 'test'
|
32
|
-
t.test_files = FileList['test/*_test.rb']
|
33
|
-
t.verbose = true
|
34
|
-
end
|
35
|
-
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require File.dirname(__FILE__) + '/lib/simple_workflow/version'
|
5
|
+
|
6
|
+
GEM_FILE = "simple_workflow-#{SimpleWorkflow::VERSION}.gem"
|
7
|
+
GEM_SPEC_FILE = 'simple_workflow.gemspec'
|
8
|
+
|
9
|
+
CLEAN.include('simple_workflow-*.gem', 'tmp')
|
10
|
+
|
11
|
+
task default: :test
|
12
|
+
|
13
|
+
desc 'Generate a gem'
|
14
|
+
task gem: GEM_FILE
|
15
|
+
|
16
|
+
file(GEM_FILE => GEM_SPEC_FILE) {
|
17
|
+
puts "Generating #{GEM_FILE}"
|
18
|
+
`gem build #{GEM_SPEC_FILE}`
|
19
|
+
}
|
20
|
+
|
21
|
+
desc 'Push the gem to RubyGems'
|
22
|
+
task release: :gem do
|
23
|
+
output = `git status --porcelain`
|
24
|
+
raise "Workspace not clean!\n#{output}" unless output.empty?
|
25
|
+
sh "git tag #{SimpleWorkflow::VERSION}"
|
26
|
+
sh 'git push --tags'
|
27
|
+
sh "gem push #{GEM_FILE}"
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::TestTask.new do |t|
|
31
|
+
t.libs << 'test'
|
32
|
+
t.test_files = FileList['test/*_test.rb']
|
33
|
+
t.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rubocop/rake_task'
|
37
|
+
RuboCop::RakeTask.new
|
38
|
+
Rake::Task[:test].enhance ['rubocop:auto_correct']
|
@@ -14,11 +14,11 @@ module SimpleWorkflow::Helper
|
|
14
14
|
link_with_detour = link_to(title, with_detour(options), html_options)
|
15
15
|
end
|
16
16
|
if link_with_detour.size > 4096 # URL maximum size overflow
|
17
|
-
if block
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
link_with_detour = if block
|
18
|
+
link_to(options, html_options, &block)
|
19
|
+
else
|
20
|
+
link_to(title, options, html_options)
|
21
|
+
end
|
22
22
|
end
|
23
23
|
link_with_detour
|
24
24
|
end
|
@@ -38,22 +38,32 @@ class SimpleWorkflow::Middleware
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def remove_old_detours(env)
|
41
|
-
if
|
42
|
-
|
43
|
-
ss = ws = nil
|
41
|
+
if session(env).instance_variable_get('@by').is_a?(ActionDispatch::Session::CookieStore)
|
42
|
+
session_size = workflow_size = nil
|
44
43
|
session = session(env)
|
44
|
+
# env[ActionDispatch::Cookies::COOKIES_SERIALIZER]
|
45
|
+
cookie_jar = cookie_jar(env)
|
46
|
+
encryptor = encryptor(env)
|
45
47
|
loop do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
Rails.logger.warn "Workflow too large (#{ws}/#{ss}). Dropping oldest detour."
|
48
|
+
ser_val = cookie_jar.send(:serialize, nil, session.to_hash)
|
49
|
+
session_size = encryptor.encrypt_and_sign(ser_val).size
|
50
|
+
wf_ser_val = cookie_jar.send(:serialize, nil, session[:detours])
|
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)
|
53
|
+
Rails.logger.warn "Workflow too large (#{workflow_size}/#{session_size}). Dropping oldest detour."
|
53
54
|
session[:detours].shift
|
54
55
|
reset_workflow(session) if session[:detours].empty?
|
55
56
|
end
|
56
|
-
Rails.logger.debug "session: #{
|
57
|
+
Rails.logger.debug "session: #{session_size} bytes, workflow(#{session[:detours].try(:size) || 0}): #{workflow_size} bytes"
|
58
|
+
if session_size > 4096
|
59
|
+
Rails.logger.warn "simple_workflow: session exceeds cookie size limit: #{session_size} bytes. Workflow empty! Not My Fault!"
|
60
|
+
Rails.logger.warn "simple_workflow: session: #{session.to_hash}"
|
61
|
+
if (old_flashes = session[:flash] && session[:flash]['discard'])
|
62
|
+
Rails.logger.warn "simple_workflow: found discarded flash entries: #{old_flashes}. Deleting them."
|
63
|
+
session[:flash]['flashes'] = session[:flash]['flashes'].except(*old_flashes)
|
64
|
+
Rails.logger.warn "simple_workflow: session: #{session.to_hash}"
|
65
|
+
end
|
66
|
+
end
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
@@ -61,6 +71,7 @@ class SimpleWorkflow::Middleware
|
|
61
71
|
return @simple_workflow_encryptor if @simple_workflow_encryptor
|
62
72
|
@simple_workflow_encryptor = cookie_jar(env).instance_variable_get(:@encryptor)
|
63
73
|
return @simple_workflow_encryptor if @simple_workflow_encryptor
|
74
|
+
Rails.logger.warn 'simple_workflow: Could not get encryptor from the cookie jar'
|
64
75
|
secret_key_base = Rails.application.config.secret_key_base ||
|
65
76
|
Rails.application.config.secret_token ||
|
66
77
|
SecureRandom.hex(64)
|
data/test/controller_test.rb
CHANGED
@@ -10,6 +10,7 @@ class ControllerTest < MiniTest::Test
|
|
10
10
|
@cookies = ActionDispatch::Cookies::CookieJar.new(ActiveSupport::KeyGenerator.new('secret'), nil, false, options)
|
11
11
|
@logger = Rails.logger
|
12
12
|
@session = {}
|
13
|
+
@bad_route = false
|
13
14
|
# TODO(uwe): Remove when we stop testing Rails 4.1
|
14
15
|
if Rails.version !~ /^4\.1\./
|
15
16
|
Rails.app_class = TestApp
|
@@ -38,10 +39,17 @@ class ControllerTest < MiniTest::Test
|
|
38
39
|
assert_equal({}, session)
|
39
40
|
end
|
40
41
|
|
42
|
+
def test_back_with_invalid_detour # not route
|
43
|
+
store_detour({controller: :mycontroller, action: :missing_in_action})
|
44
|
+
@bad_route = true
|
45
|
+
back({})
|
46
|
+
assert_equal({}, session)
|
47
|
+
end
|
48
|
+
|
41
49
|
private
|
42
50
|
|
43
|
-
def redirect_to(
|
44
|
-
|
51
|
+
def redirect_to(_path, _response_status_and_flash)
|
52
|
+
raise 'Bad route' if @bad_route
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
data/test/helper_test.rb
CHANGED
@@ -8,6 +8,17 @@ class HelperTest < MiniTest::Test
|
|
8
8
|
with_detour('')
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_image_button_to
|
12
|
+
assert_equal [
|
13
|
+
'my_image.png', {
|
14
|
+
class: 'image-submit', alt: 'Link Title',
|
15
|
+
title: 'Image title', id: 'Link Title_image_tag_id', name: 'Link Title',
|
16
|
+
onclick: "form.action='{:id=>\"image_tag_id\"}'"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
image_button_to('my_image.png', 'Link Title', {id: 'image_tag_id'}, title: 'Image title')
|
20
|
+
end
|
21
|
+
|
11
22
|
private
|
12
23
|
|
13
24
|
def params
|
@@ -17,4 +28,8 @@ class HelperTest < MiniTest::Test
|
|
17
28
|
def url_for(options)
|
18
29
|
options.to_s
|
19
30
|
end
|
31
|
+
|
32
|
+
def image_submit_tag(*args)
|
33
|
+
args
|
34
|
+
end
|
20
35
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'simplecov'
|
4
|
-
SimpleCov.start
|
4
|
+
SimpleCov.start do
|
5
|
+
coverage_dir File.expand_path('../coverage', File.dirname(__FILE__))
|
6
|
+
minimum_coverage 75
|
7
|
+
end
|
5
8
|
require 'minitest/autorun'
|
6
9
|
require 'minitest/reporters'
|
7
10
|
MiniTest::Reporters.use!
|
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.2.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
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.45'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.45'
|
55
69
|
description: Expands Ruby On Rails to allow simple breadcrumb detour workflows.
|
56
70
|
email: uwe@kubosch.no
|
57
71
|
executables: []
|