simple_workflow 1.4.0 → 1.5.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 +44 -41
- data/README.md +8 -8
- data/lib/simple_workflow/helper.rb +6 -0
- data/lib/simple_workflow/version.rb +1 -1
- data/test/helper_test.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b842c9675bb7b68cb8415ae75db517aa22187d54
|
4
|
+
data.tar.gz: d088c56f1927476705b98bdda5fd70f65d74c8d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9204b6ea88ceb77a16b6620416b75f8aeecd400a5d7443291141dfbf3cb3d0eb745a4b51ae74ad4666730f593e4ec6e4099a980bbd138fccde24a6f30a0362e2
|
7
|
+
data.tar.gz: 2ab8c7a22b6d98481bbb964255bb6eb3a17b6cb49f784b4b0e265c3a5d1850206eb26e3c2d762280c3b9f2605aba283360cd854c9b56d1c8e59a77e220b0e749
|
data/Gemfile.lock
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_workflow (1.
|
4
|
+
simple_workflow (1.5.0)
|
5
5
|
rails (>= 4, < 5.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actioncable (5.1.
|
11
|
-
actionpack (= 5.1.
|
10
|
+
actioncable (5.1.2)
|
11
|
+
actionpack (= 5.1.2)
|
12
12
|
nio4r (~> 2.0)
|
13
13
|
websocket-driver (~> 0.6.1)
|
14
|
-
actionmailer (5.1.
|
15
|
-
actionpack (= 5.1.
|
16
|
-
actionview (= 5.1.
|
17
|
-
activejob (= 5.1.
|
14
|
+
actionmailer (5.1.2)
|
15
|
+
actionpack (= 5.1.2)
|
16
|
+
actionview (= 5.1.2)
|
17
|
+
activejob (= 5.1.2)
|
18
18
|
mail (~> 2.5, >= 2.5.4)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
|
-
actionpack (5.1.
|
21
|
-
actionview (= 5.1.
|
22
|
-
activesupport (= 5.1.
|
20
|
+
actionpack (5.1.2)
|
21
|
+
actionview (= 5.1.2)
|
22
|
+
activesupport (= 5.1.2)
|
23
23
|
rack (~> 2.0)
|
24
24
|
rack-test (~> 0.6.3)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
-
actionview (5.1.
|
28
|
-
activesupport (= 5.1.
|
27
|
+
actionview (5.1.2)
|
28
|
+
activesupport (= 5.1.2)
|
29
29
|
builder (~> 3.1)
|
30
30
|
erubi (~> 1.4)
|
31
31
|
rails-dom-testing (~> 2.0)
|
32
32
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
33
|
-
activejob (5.1.
|
34
|
-
activesupport (= 5.1.
|
33
|
+
activejob (5.1.2)
|
34
|
+
activesupport (= 5.1.2)
|
35
35
|
globalid (>= 0.3.6)
|
36
|
-
activemodel (5.1.
|
37
|
-
activesupport (= 5.1.
|
38
|
-
activerecord (5.1.
|
39
|
-
activemodel (= 5.1.
|
40
|
-
activesupport (= 5.1.
|
36
|
+
activemodel (5.1.2)
|
37
|
+
activesupport (= 5.1.2)
|
38
|
+
activerecord (5.1.2)
|
39
|
+
activemodel (= 5.1.2)
|
40
|
+
activesupport (= 5.1.2)
|
41
41
|
arel (~> 8.0)
|
42
|
-
activesupport (5.1.
|
42
|
+
activesupport (5.1.2)
|
43
43
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
44
|
i18n (~> 0.7)
|
45
45
|
minitest (~> 5.1)
|
@@ -50,11 +50,11 @@ GEM
|
|
50
50
|
builder (3.2.3)
|
51
51
|
concurrent-ruby (1.0.5)
|
52
52
|
docile (1.1.5)
|
53
|
-
erubi (1.6.
|
53
|
+
erubi (1.6.1)
|
54
54
|
globalid (0.4.0)
|
55
55
|
activesupport (>= 4.2.0)
|
56
|
-
i18n (0.8.
|
57
|
-
json (2.0
|
56
|
+
i18n (0.8.6)
|
57
|
+
json (2.1.0)
|
58
58
|
loofah (2.0.3)
|
59
59
|
nokogiri (>= 1.5.9)
|
60
60
|
mail (2.6.6)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
mime-types-data (~> 3.2015)
|
65
65
|
mime-types-data (3.2016.0521)
|
66
66
|
mini_portile2 (2.2.0)
|
67
|
-
minitest (5.10.
|
67
|
+
minitest (5.10.2)
|
68
68
|
minitest-reporters (1.1.14)
|
69
69
|
ansi
|
70
70
|
builder
|
@@ -73,38 +73,41 @@ GEM
|
|
73
73
|
nio4r (2.1.0)
|
74
74
|
nokogiri (1.8.0)
|
75
75
|
mini_portile2 (~> 2.2.0)
|
76
|
+
parallel (1.11.2)
|
76
77
|
parser (2.4.0.0)
|
77
78
|
ast (~> 2.2)
|
78
79
|
powerpack (0.1.1)
|
79
80
|
rack (2.0.3)
|
80
81
|
rack-test (0.6.3)
|
81
82
|
rack (>= 1.0)
|
82
|
-
rails (5.1.
|
83
|
-
actioncable (= 5.1.
|
84
|
-
actionmailer (= 5.1.
|
85
|
-
actionpack (= 5.1.
|
86
|
-
actionview (= 5.1.
|
87
|
-
activejob (= 5.1.
|
88
|
-
activemodel (= 5.1.
|
89
|
-
activerecord (= 5.1.
|
90
|
-
activesupport (= 5.1.
|
83
|
+
rails (5.1.2)
|
84
|
+
actioncable (= 5.1.2)
|
85
|
+
actionmailer (= 5.1.2)
|
86
|
+
actionpack (= 5.1.2)
|
87
|
+
actionview (= 5.1.2)
|
88
|
+
activejob (= 5.1.2)
|
89
|
+
activemodel (= 5.1.2)
|
90
|
+
activerecord (= 5.1.2)
|
91
|
+
activesupport (= 5.1.2)
|
91
92
|
bundler (>= 1.3.0, < 2.0)
|
92
|
-
railties (= 5.1.
|
93
|
+
railties (= 5.1.2)
|
93
94
|
sprockets-rails (>= 2.0.0)
|
94
95
|
rails-dom-testing (2.0.3)
|
95
96
|
activesupport (>= 4.2.0)
|
96
97
|
nokogiri (>= 1.6)
|
97
98
|
rails-html-sanitizer (1.0.3)
|
98
99
|
loofah (~> 2.0)
|
99
|
-
railties (5.1.
|
100
|
-
actionpack (= 5.1.
|
101
|
-
activesupport (= 5.1.
|
100
|
+
railties (5.1.2)
|
101
|
+
actionpack (= 5.1.2)
|
102
|
+
activesupport (= 5.1.2)
|
102
103
|
method_source
|
103
104
|
rake (>= 0.8.7)
|
104
105
|
thor (>= 0.18.1, < 2.0)
|
105
|
-
rainbow (2.2.
|
106
|
+
rainbow (2.2.2)
|
107
|
+
rake
|
106
108
|
rake (12.0.0)
|
107
|
-
rubocop (0.
|
109
|
+
rubocop (0.49.1)
|
110
|
+
parallel (~> 1.10)
|
108
111
|
parser (>= 2.3.3.1, < 3.0)
|
109
112
|
powerpack (~> 0.1)
|
110
113
|
rainbow (>= 1.99.1, < 3.0)
|
@@ -115,7 +118,7 @@ GEM
|
|
115
118
|
docile (~> 1.1.0)
|
116
119
|
json (>= 1.8, < 3)
|
117
120
|
simplecov-html (~> 0.10.0)
|
118
|
-
simplecov-html (0.10.
|
121
|
+
simplecov-html (0.10.1)
|
119
122
|
sprockets (3.7.1)
|
120
123
|
concurrent-ruby (~> 1.0)
|
121
124
|
rack (> 1, < 3)
|
@@ -127,7 +130,7 @@ GEM
|
|
127
130
|
thread_safe (0.3.6)
|
128
131
|
tzinfo (1.2.3)
|
129
132
|
thread_safe (~> 0.1)
|
130
|
-
unicode-display_width (1.
|
133
|
+
unicode-display_width (1.3.0)
|
131
134
|
websocket-driver (0.6.5)
|
132
135
|
websocket-extensions (>= 0.1.0)
|
133
136
|
websocket-extensions (0.1.2)
|
data/README.md
CHANGED
@@ -22,21 +22,21 @@ with returns.
|
|
22
22
|
|
23
23
|
In views:
|
24
24
|
|
25
|
-
detour_to :
|
26
|
-
back_or_link_to :
|
27
|
-
image_button_to :
|
25
|
+
detour_to controller: :my_models, action: :create
|
26
|
+
back_or_link_to controller: :welcome, action: :index
|
27
|
+
image_button_to controller: :my_models, action: :create
|
28
28
|
|
29
|
-
link_to 'Link with custom origin', with_detour(
|
29
|
+
link_to 'Link with custom origin', with_detour(destination, origin)
|
30
30
|
|
31
31
|
In controllers:
|
32
32
|
|
33
|
-
back_or_redirect_to :
|
33
|
+
back_or_redirect_to controller: :my_models, action: :index
|
34
34
|
|
35
35
|
In your tests:
|
36
36
|
|
37
37
|
def test_valid_login_redirects_as_specified
|
38
38
|
add_stored_detour "/bogus/location"
|
39
|
-
post :login, :
|
39
|
+
post :login, user: { login: "tesla", password: "atest" }
|
40
40
|
assert_logged_in users(:tesla)
|
41
41
|
assert_response :redirect
|
42
42
|
assert_redirected_to "http://#{request.host}/bogus/location"
|
@@ -44,8 +44,8 @@ In your tests:
|
|
44
44
|
|
45
45
|
## REQUIREMENTS
|
46
46
|
|
47
|
-
* Ruby 2.
|
48
|
-
* Rails 4.
|
47
|
+
* Ruby 2.2 or newer. **JRuby** supported!
|
48
|
+
* Rails 4.2 or newer.
|
49
49
|
|
50
50
|
## INSTALL
|
51
51
|
|
@@ -34,6 +34,12 @@ module SimpleWorkflow::Helper
|
|
34
34
|
# If the optional second argument is given, it is used as the origin.
|
35
35
|
# If the given origin is only an anchor, it is added to the current page.
|
36
36
|
def with_detour(options, origin = origin_options)
|
37
|
+
if origin.is_a?(String)
|
38
|
+
uri = URI(origin)
|
39
|
+
origin = Rails.application.routes.recognize_path uri.path
|
40
|
+
origin.update anchor: uri.fragment if uri.fragment.present?
|
41
|
+
origin.update Rack::Utils.parse_nested_query(uri.query) if uri.query.present?
|
42
|
+
end
|
37
43
|
origin.update(origin_options) if origin.keys == [:anchor]
|
38
44
|
url = url_for(options)
|
39
45
|
url + (url =~ /\?/ ? '&' : '?') + origin.to_h.to_param('detour')
|
data/test/helper_test.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
require 'action_controller/metal/exceptions'
|
3
|
+
require 'test_app'
|
3
4
|
|
4
5
|
class HelperTest < MiniTest::Test
|
5
6
|
include SimpleWorkflow::Helper
|
@@ -9,6 +10,29 @@ class HelperTest < MiniTest::Test
|
|
9
10
|
with_detour('')
|
10
11
|
end
|
11
12
|
|
13
|
+
def test_with_detour_with_origin
|
14
|
+
assert_equal '?detour%5Baction%5D=index&detour%5Bcontroller%5D=dashboard',
|
15
|
+
with_detour('', controller: :dashboard, action: :index)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_with_detour_with_only_anchor_as_origin
|
19
|
+
assert_equal '?detour%5Baction%5D=myaction&detour%5Banchor%5D=tab_2&detour%5Bcontroller%5D=mycontroller&detour%5Bid%5D=42&detour%5Bquery%5D%5Bnested%5D=criterium',
|
20
|
+
with_detour('', anchor: :tab_2)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_with_detour_with_string_origin
|
24
|
+
Rails.application = TestApp.new
|
25
|
+
|
26
|
+
Rails.application.routes.draw do
|
27
|
+
get 'dashboard/index' => 'simple_workflow/#index'
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal '?detour%5Baction%5D=index&detour%5Banchor%5D=tab_2&detour%5Bcontroller%5D=simple_workflow%2F&detour%5Bhullo%5D=1',
|
31
|
+
with_detour('', '/dashboard/index?hullo=1#tab_2')
|
32
|
+
ensure
|
33
|
+
Rails.application = nil
|
34
|
+
end
|
35
|
+
|
12
36
|
def test_detour_to
|
13
37
|
assert_equal [
|
14
38
|
'Link Text',
|
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.5.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: 2017-07-
|
11
|
+
date: 2017-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '2.
|
111
|
+
version: '2.2'
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|