simple_workflow 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -4
- data/lib/simple_workflow/controller.rb +1 -10
- data/lib/simple_workflow/detour.rb +9 -0
- data/lib/simple_workflow/middleware.rb +2 -2
- data/lib/simple_workflow/version.rb +1 -1
- data/test/controller_test.rb +12 -0
- data/test/middleware_test.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56cb50f2ada0bdf7026441bbe353f10d44c98ec2
|
4
|
+
data.tar.gz: 67633241bf4e65964492d486181c5a179e58db38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3259d655fac64885813683a285c2ae5662caa11f41d60e89a2adc0cc295098ad88b38d6214ec5e599f27e4fa405278b5619c5661db3b9788e0ac830c47d436
|
7
|
+
data.tar.gz: eb5dd5097bbf6daa8befbb91e8245ec166158fd9bf64865f477476a3365dce3faaa6ab19fec0d673a5f0e3d6588c5edb5efe619e1332ce0697311b6411282d0b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_workflow (1.1.
|
4
|
+
simple_workflow (1.1.2)
|
5
5
|
rails (~> 4.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -46,7 +46,6 @@ GEM
|
|
46
46
|
arel (6.0.3)
|
47
47
|
builder (3.2.2)
|
48
48
|
concurrent-ruby (1.0.1)
|
49
|
-
concurrent-ruby (1.0.1-java)
|
50
49
|
docile (1.1.5)
|
51
50
|
erubis (2.7.0)
|
52
51
|
globalid (0.3.6)
|
@@ -70,7 +69,6 @@ GEM
|
|
70
69
|
ruby-progressbar
|
71
70
|
nokogiri (1.6.7.2)
|
72
71
|
mini_portile2 (~> 2.0.0.rc2)
|
73
|
-
nokogiri (1.6.7.2-java)
|
74
72
|
rack (1.6.4)
|
75
73
|
rack-test (0.6.3)
|
76
74
|
rack (>= 1.0)
|
@@ -114,7 +112,6 @@ GEM
|
|
114
112
|
sprockets (>= 3.0.0)
|
115
113
|
thor (0.19.1)
|
116
114
|
thread_safe (0.3.5)
|
117
|
-
thread_safe (0.3.5-java)
|
118
115
|
tzinfo (1.2.2)
|
119
116
|
thread_safe (~> 0.1)
|
120
117
|
|
@@ -32,7 +32,7 @@ module SimpleWorkflow::Controller
|
|
32
32
|
|
33
33
|
def back(response_status_and_flash)
|
34
34
|
return false if session[:detours].nil?
|
35
|
-
detour = pop_detour
|
35
|
+
detour = pop_detour(session)
|
36
36
|
post = detour.delete(:request_method) == :post
|
37
37
|
if post
|
38
38
|
set_flash(response_status_and_flash)
|
@@ -62,15 +62,6 @@ module SimpleWorkflow::Controller
|
|
62
62
|
end
|
63
63
|
private :set_flash
|
64
64
|
|
65
|
-
def pop_detour
|
66
|
-
detours = session[:detours]
|
67
|
-
return nil unless detours
|
68
|
-
detour = detours.pop
|
69
|
-
logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
|
70
|
-
reset_workflow(session) if detours.empty?
|
71
|
-
detour
|
72
|
-
end
|
73
|
-
|
74
65
|
def redirect_to_post(options)
|
75
66
|
url = url_for options
|
76
67
|
render :text => <<EOF, :layout => false
|
@@ -9,6 +9,15 @@ module SimpleWorkflow::Detour
|
|
9
9
|
Rails.logger.try(:debug, "Added detour (#{session[:detours].try(:size) || 0}): #{options.inspect}")
|
10
10
|
end
|
11
11
|
|
12
|
+
def pop_detour(session)
|
13
|
+
detours = session[:detours]
|
14
|
+
return nil unless detours
|
15
|
+
detour = detours.pop
|
16
|
+
Rails.logger.debug "popped detour: #{detour.inspect} #{session[:detours].size} more"
|
17
|
+
reset_workflow(session) if detours.empty?
|
18
|
+
detour
|
19
|
+
end
|
20
|
+
|
12
21
|
def reset_workflow(session)
|
13
22
|
session.delete(:detours)
|
14
23
|
end
|
@@ -75,8 +75,8 @@ class SimpleWorkflow::Middleware
|
|
75
75
|
if params(env)[:detour]
|
76
76
|
store_detour_in_session(session(env), params(env)[:detour])
|
77
77
|
end
|
78
|
-
if params(env)[:return_from_detour] && session[:detours]
|
79
|
-
pop_detour
|
78
|
+
if params(env)[:return_from_detour] && session(env)[:detours]
|
79
|
+
pop_detour(session(env))
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
data/test/controller_test.rb
CHANGED
@@ -31,6 +31,18 @@ class ControllerTest < MiniTest::Test
|
|
31
31
|
assert_equal({}, session)
|
32
32
|
end
|
33
33
|
# ODOT
|
34
|
+
|
35
|
+
def test_back
|
36
|
+
store_detour({controller: :mycontroller, action: :myaction})
|
37
|
+
back({})
|
38
|
+
assert_equal({}, session)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def redirect_to(path, response_status_and_flash)
|
44
|
+
# NOOP
|
45
|
+
end
|
34
46
|
end
|
35
47
|
|
36
48
|
class TestApp < Rails::Application
|
data/test/middleware_test.rb
CHANGED
@@ -72,6 +72,21 @@ class MiddlewareTest < MiniTest::Test
|
|
72
72
|
assert_equal(%w(session_id), headers['rack.session'].to_hash.keys)
|
73
73
|
end
|
74
74
|
|
75
|
+
def test_return_from_detour
|
76
|
+
_, headers1, _ = @stack.call env_for('/?detour[controller]=test_first')
|
77
|
+
env = env_for('/?return_from_detour=true',
|
78
|
+
'rack.session' => headers1['rack.session'],
|
79
|
+
'rack.session.options' => headers1['rack.session.options']
|
80
|
+
)
|
81
|
+
status, headers, response = @stack.call env
|
82
|
+
|
83
|
+
assert_equal 200, status
|
84
|
+
assert_equal(env, headers)
|
85
|
+
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'])
|
88
|
+
end
|
89
|
+
|
75
90
|
private
|
76
91
|
|
77
92
|
def env_for(url, opts={})
|
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.1.
|
4
|
+
version: 1.1.2
|
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-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|