wicked 1.0.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/check_changelog.yml +13 -0
- data/.gitignore +15 -0
- data/.travis.yml +12 -17
- data/Appraisals +11 -0
- data/CHANGELOG.md +40 -0
- data/CONTRIBUTING.md +19 -0
- data/Gemfile +3 -20
- data/README.md +148 -34
- data/Rakefile +2 -15
- data/gemfiles/rails_5.1.gemfile +12 -0
- data/gemfiles/rails_5.2.gemfile +12 -0
- data/gemfiles/rails_6.0.1.gemfile +12 -0
- data/lib/wicked/controller/concerns/action.rb +13 -0
- data/lib/wicked/controller/concerns/path.rb +13 -3
- data/lib/wicked/controller/concerns/render_redirect.rb +33 -23
- data/lib/wicked/controller/concerns/steps.rb +12 -17
- data/lib/wicked/version.rb +3 -0
- data/lib/wicked/wizard/translated.rb +3 -6
- data/lib/wicked/wizard.rb +19 -18
- data/{app/controllers → lib}/wicked/wizard_controller.rb +1 -2
- data/lib/wicked.rb +2 -1
- data/test/controllers/bar_controller_test.rb +3 -2
- data/test/controllers/updates_controller_test.rb +27 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -2
- data/test/dummy/app/controllers/dynamic_different_steps_controller.rb +18 -0
- data/test/dummy/app/controllers/dynamic_steps_controller.rb +1 -1
- data/test/dummy/app/controllers/jump_controller.rb +9 -2
- data/test/dummy/app/controllers/redirect_to_next_controller.rb +1 -1
- data/test/dummy/app/controllers/update_params_controller.rb +30 -0
- data/test/dummy/app/controllers/updates_controller.rb +30 -0
- data/test/dummy/app/views/bar/first.html.erb +3 -1
- data/test/dummy/app/views/bar/second.html.erb +2 -1
- data/test/dummy/app/views/dynamic_different_steps/first.html.erb +3 -0
- data/test/dummy/app/views/jump/last_step.html.erb +3 -1
- data/test/dummy/app/views/jump/second.html.erb +3 -1
- data/test/dummy/app/views/update_params/_step_position.html.erb +16 -0
- data/test/dummy/app/views/update_params/first.html.erb +1 -0
- data/test/dummy/app/views/update_params/index.html.erb +1 -0
- data/test/dummy/app/views/update_params/last_step.html.erb +1 -0
- data/test/dummy/app/views/update_params/second.html.erb +1 -0
- data/test/dummy/app/views/updates/_step_position.html.erb +16 -0
- data/test/dummy/app/views/updates/first.html.erb +1 -0
- data/test/dummy/app/views/updates/index.html.erb +1 -0
- data/test/dummy/app/views/updates/last_step.html.erb +1 -0
- data/test/dummy/app/views/updates/second.html.erb +1 -0
- data/test/dummy/config/application.rb +3 -0
- data/test/dummy/config/environments/development.rb +0 -1
- data/test/dummy/config/environments/test.rb +3 -1
- data/test/dummy/config/routes.rb +3 -0
- data/test/integration/dynamic_steps_test.rb +8 -1
- data/test/integration/helpers_test.rb +27 -0
- data/test/integration/jump_test.rb +16 -0
- data/test/integration/redirect_to_next_test.rb +1 -1
- data/test/integration/security_test.rb +0 -2
- data/test/integration/update_params_test.rb +20 -0
- data/test/integration/updates_test.rb +20 -0
- data/test/support/wicked_controller_test_case.rb +9 -0
- data/test/test_helper.rb +9 -9
- data/wicked.gemspec +22 -150
- metadata +146 -50
- data/.rvmrc +0 -19
- data/VERSION +0 -1
- /data/test/dummy/app/controllers/{steps_controller.rb → step_positions_controller.rb} +0 -0
@@ -5,13 +5,23 @@ class HelpersTest < ActiveSupport::IntegrationCase
|
|
5
5
|
test 'next_wizard_path' do
|
6
6
|
step = :first
|
7
7
|
visit(bar_path(step))
|
8
|
+
assert has_link?('skip', href: '/bar/second')
|
8
9
|
click_link 'skip'
|
9
10
|
assert_has_content?('second')
|
10
11
|
end
|
11
12
|
|
13
|
+
test 'next_wizard_url' do
|
14
|
+
step = :first
|
15
|
+
visit(bar_path(step))
|
16
|
+
assert has_link?('next url', href: 'http://www.example.com/bar/second')
|
17
|
+
click_link 'next url'
|
18
|
+
assert_has_content?('second')
|
19
|
+
end
|
20
|
+
|
12
21
|
test 'wizard_path' do
|
13
22
|
step = :first
|
14
23
|
visit(bar_path(step))
|
24
|
+
assert has_link?('current', href: '/bar/first')
|
15
25
|
click_link 'current'
|
16
26
|
assert_has_content?(step.to_s)
|
17
27
|
end
|
@@ -23,9 +33,26 @@ class HelpersTest < ActiveSupport::IntegrationCase
|
|
23
33
|
assert_has_content?('last_step')
|
24
34
|
end
|
25
35
|
|
36
|
+
test 'wizard_url' do
|
37
|
+
step = :first
|
38
|
+
visit(bar_path(step))
|
39
|
+
assert has_link?('current url', href: 'http://www.example.com/bar/first')
|
40
|
+
click_link 'current'
|
41
|
+
assert_has_content?(step.to_s)
|
42
|
+
end
|
43
|
+
|
26
44
|
test 'previous_wizard_path' do
|
27
45
|
step = :second
|
28
46
|
visit(bar_path(step))
|
47
|
+
assert has_link?('previous', href: '/bar/first')
|
48
|
+
click_link 'previous'
|
49
|
+
assert_has_content?("first")
|
50
|
+
end
|
51
|
+
|
52
|
+
test 'previous_wizard_url' do
|
53
|
+
step = :second
|
54
|
+
visit(bar_path(step))
|
55
|
+
assert has_link?('previous url', href: 'http://www.example.com/bar/first')
|
29
56
|
click_link 'previous'
|
30
57
|
assert_has_content?("first")
|
31
58
|
end
|
@@ -13,4 +13,20 @@ class JumpNavigationTest < ActiveSupport::IntegrationCase
|
|
13
13
|
assert_has_content?('first')
|
14
14
|
assert !has_content?('last_step')
|
15
15
|
end
|
16
|
+
|
17
|
+
|
18
|
+
test 'skip_step takes :skip_step_options and passes them' do
|
19
|
+
step = :first
|
20
|
+
visit(jump_path(step, :skip_step => true, :skip_step_options => {:foo => :bar}))
|
21
|
+
assert_has_content?('second')
|
22
|
+
assert !has_content?('last_step')
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'jump_to takes :skip_step_options and passes them' do
|
26
|
+
step = :first
|
27
|
+
visit(jump_path(step, :resource => {:save => true}, :jump_to => :last_step, :skip_step_options => {:foo => :bar}))
|
28
|
+
assert_has_content?("foo")
|
29
|
+
assert_has_content?("bar")
|
30
|
+
assert_has_content?('last_step')
|
31
|
+
end
|
16
32
|
end
|
@@ -7,7 +7,6 @@ class SecurityTest < ActiveSupport::IntegrationCase
|
|
7
7
|
assert_raise(Wicked::Wizard::InvalidStepError) do
|
8
8
|
visit(bar_path(step))
|
9
9
|
end
|
10
|
-
refute has_content?('sqlite3')
|
11
10
|
end
|
12
11
|
|
13
12
|
# only works on *nix systems
|
@@ -18,6 +17,5 @@ class SecurityTest < ActiveSupport::IntegrationCase
|
|
18
17
|
assert_raise(Wicked::Wizard::InvalidStepError) do
|
19
18
|
visit(bar_path(step))
|
20
19
|
end
|
21
|
-
refute has_content?('aardvark')
|
22
20
|
end
|
23
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdateParamsTest < ActiveSupport::IntegrationCase
|
4
|
+
test 'on first' do
|
5
|
+
step = :first
|
6
|
+
visit(update_param_path(step))
|
7
|
+
|
8
|
+
click_button("Next")
|
9
|
+
assert_equal page.current_path, update_param_path(:second)
|
10
|
+
assert_has_content?("notice:Thing was updated from step first.")
|
11
|
+
|
12
|
+
click_button("Next")
|
13
|
+
assert_equal page.current_path, update_param_path(:last_step)
|
14
|
+
assert_has_content?("notice:Thing was updated from step second.")
|
15
|
+
|
16
|
+
click_button("Next")
|
17
|
+
assert_equal page.current_url, update_params_url({host: 'www.example.com', one: 'two' })
|
18
|
+
assert_has_content?("notice:Thing was updated from step last_step.")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UpdatesTest < ActiveSupport::IntegrationCase
|
4
|
+
test 'on first' do
|
5
|
+
step = :first
|
6
|
+
visit(update_path(step))
|
7
|
+
|
8
|
+
click_button("Next")
|
9
|
+
assert_equal page.current_path, update_path(:second)
|
10
|
+
assert_has_content?("notice:Thing was updated from step first.")
|
11
|
+
|
12
|
+
click_button("Next")
|
13
|
+
assert_equal page.current_path, update_path(:last_step)
|
14
|
+
assert_has_content?("notice:Thing was updated from step second.")
|
15
|
+
|
16
|
+
click_button("Next")
|
17
|
+
assert_equal page.current_path, updates_path
|
18
|
+
assert_has_content?("notice:Thing was updated from step last_step.")
|
19
|
+
end
|
20
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
# Configure Rails Envinronment
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
4
|
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
7
5
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
8
6
|
require "rails/test_help"
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
8
|
ActionMailer::Base.delivery_method = :test
|
14
9
|
ActionMailer::Base.perform_deliveries = true
|
15
10
|
ActionMailer::Base.default_url_options[:host] = "test.com"
|
@@ -21,10 +16,15 @@ require "capybara/rails"
|
|
21
16
|
Capybara.default_driver = :rack_test
|
22
17
|
Capybara.default_selector = :css
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
ActiveRecord::
|
19
|
+
# https://github.com/plataformatec/devise/blob/master/test/orm/active_record.rb
|
20
|
+
migrate_path = File.expand_path("../rails_app/db/migrate", __FILE__)
|
21
|
+
if Rails.version.start_with? '6'
|
22
|
+
ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
|
23
|
+
elsif Rails.version.start_with? '5.2'
|
24
|
+
ActiveRecord::MigrationContext.new(migrate_path).migrate
|
25
|
+
else
|
26
|
+
ActiveRecord::Migrator.migrate(migrate_path)
|
27
|
+
end
|
28
28
|
|
29
29
|
# Load support files
|
30
30
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
data/wicked.gemspec
CHANGED
@@ -1,155 +1,27 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wicked/version'
|
6
5
|
|
7
|
-
Gem::Specification.new do |
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
s.extra_rdoc_files = [
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "wicked"
|
8
|
+
gem.version = Wicked::VERSION
|
9
|
+
gem.authors = ["Richard Schneeman"]
|
10
|
+
gem.email = ["richard.schneeman+rubygems@gmail.com"]
|
11
|
+
gem.description = "Wicked is a Rails engine for producing easy wizard controllers"
|
12
|
+
gem.summary = "Use Wicked to turn your controller into a wizard"
|
13
|
+
gem.homepage = "https://github.com/schneems/wicked"
|
14
|
+
gem.license = "MIT"
|
15
|
+
gem.extra_rdoc_files = [
|
18
16
|
"README.md"
|
19
17
|
]
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"app/controllers/wicked/wizard_controller.rb",
|
30
|
-
"lib/wicked.rb",
|
31
|
-
"lib/wicked/controller/concerns/path.rb",
|
32
|
-
"lib/wicked/controller/concerns/render_redirect.rb",
|
33
|
-
"lib/wicked/controller/concerns/steps.rb",
|
34
|
-
"lib/wicked/engine.rb",
|
35
|
-
"lib/wicked/wizard.rb",
|
36
|
-
"lib/wicked/wizard/translated.rb",
|
37
|
-
"test/controllers/bar_controller_test.rb",
|
38
|
-
"test/dummy/Rakefile",
|
39
|
-
"test/dummy/app/controllers/application_controller.rb",
|
40
|
-
"test/dummy/app/controllers/bar_controller.rb",
|
41
|
-
"test/dummy/app/controllers/dynamic_steps_controller.rb",
|
42
|
-
"test/dummy/app/controllers/i18n_controller.rb",
|
43
|
-
"test/dummy/app/controllers/jump_controller.rb",
|
44
|
-
"test/dummy/app/controllers/nested/builder_controller.rb",
|
45
|
-
"test/dummy/app/controllers/pages_controller.rb",
|
46
|
-
"test/dummy/app/controllers/redirect_to_finish_flash_controller.rb",
|
47
|
-
"test/dummy/app/controllers/redirect_to_next_controller.rb",
|
48
|
-
"test/dummy/app/controllers/steps_controller.rb",
|
49
|
-
"test/dummy/app/controllers/string_steps_controller.rb",
|
50
|
-
"test/dummy/app/helpers/application_helper.rb",
|
51
|
-
"test/dummy/app/models/bar.rb",
|
52
|
-
"test/dummy/app/views/bar/first.html.erb",
|
53
|
-
"test/dummy/app/views/bar/last_step.html.erb",
|
54
|
-
"test/dummy/app/views/bar/second.html.erb",
|
55
|
-
"test/dummy/app/views/dynamic_steps/first.html.erb",
|
56
|
-
"test/dummy/app/views/i18n/first.html.erb",
|
57
|
-
"test/dummy/app/views/i18n/last_step.html.erb",
|
58
|
-
"test/dummy/app/views/i18n/second.html.erb",
|
59
|
-
"test/dummy/app/views/jump/first.html.erb",
|
60
|
-
"test/dummy/app/views/jump/last_step.html.erb",
|
61
|
-
"test/dummy/app/views/jump/second.html.erb",
|
62
|
-
"test/dummy/app/views/layouts/application.html.erb",
|
63
|
-
"test/dummy/app/views/nested/builder/first.html.erb",
|
64
|
-
"test/dummy/app/views/nested/builder/last_step.html.erb",
|
65
|
-
"test/dummy/app/views/nested/builder/second.html.erb",
|
66
|
-
"test/dummy/app/views/pages/index.html.erb",
|
67
|
-
"test/dummy/app/views/redirect_to_finish_flash/index.html.erb",
|
68
|
-
"test/dummy/app/views/redirect_to_finish_flash/last_step.html.erb",
|
69
|
-
"test/dummy/app/views/redirect_to_next/first.html.erb",
|
70
|
-
"test/dummy/app/views/redirect_to_next/last_step.html.erb",
|
71
|
-
"test/dummy/app/views/redirect_to_next/second.html.erb",
|
72
|
-
"test/dummy/app/views/step_positions/_step_position.html.erb",
|
73
|
-
"test/dummy/app/views/step_positions/first.html.erb",
|
74
|
-
"test/dummy/app/views/step_positions/last_step.html.erb",
|
75
|
-
"test/dummy/app/views/step_positions/second.html.erb",
|
76
|
-
"test/dummy/app/views/string_steps/second.html.erb",
|
77
|
-
"test/dummy/config.ru",
|
78
|
-
"test/dummy/config/application.rb",
|
79
|
-
"test/dummy/config/boot.rb",
|
80
|
-
"test/dummy/config/database.yml",
|
81
|
-
"test/dummy/config/environment.rb",
|
82
|
-
"test/dummy/config/environments/development.rb",
|
83
|
-
"test/dummy/config/environments/production.rb",
|
84
|
-
"test/dummy/config/environments/test.rb",
|
85
|
-
"test/dummy/config/initializers/backtrace_silencers.rb",
|
86
|
-
"test/dummy/config/initializers/inflections.rb",
|
87
|
-
"test/dummy/config/initializers/mime_types.rb",
|
88
|
-
"test/dummy/config/initializers/secret_token.rb",
|
89
|
-
"test/dummy/config/initializers/session_store.rb",
|
90
|
-
"test/dummy/config/locales/en.yml",
|
91
|
-
"test/dummy/config/locales/es.yml",
|
92
|
-
"test/dummy/config/routes.rb",
|
93
|
-
"test/dummy/public/404.html",
|
94
|
-
"test/dummy/public/422.html",
|
95
|
-
"test/dummy/public/500.html",
|
96
|
-
"test/dummy/public/favicon.ico",
|
97
|
-
"test/dummy/public/javascripts/application.js",
|
98
|
-
"test/dummy/public/javascripts/controls.js",
|
99
|
-
"test/dummy/public/javascripts/dragdrop.js",
|
100
|
-
"test/dummy/public/javascripts/effects.js",
|
101
|
-
"test/dummy/public/javascripts/prototype.js",
|
102
|
-
"test/dummy/public/javascripts/rails.js",
|
103
|
-
"test/dummy/public/stylesheets/.gitkeep",
|
104
|
-
"test/dummy/script/rails",
|
105
|
-
"test/integration/dynamic_steps_test.rb",
|
106
|
-
"test/integration/helpers_test.rb",
|
107
|
-
"test/integration/i18n_test.rb",
|
108
|
-
"test/integration/jump_test.rb",
|
109
|
-
"test/integration/navigation_test.rb",
|
110
|
-
"test/integration/nested_builder_test.rb",
|
111
|
-
"test/integration/redirect_to_finish_flash_test.rb",
|
112
|
-
"test/integration/redirect_to_next_test.rb",
|
113
|
-
"test/integration/security_test.rb",
|
114
|
-
"test/integration/steps_test.rb",
|
115
|
-
"test/support/integration_case.rb",
|
116
|
-
"test/test_helper.rb",
|
117
|
-
"test/wicked_test.rb",
|
118
|
-
"wicked.gemspec"
|
119
|
-
]
|
120
|
-
s.homepage = "http://github.com/schneems/wicked"
|
121
|
-
s.licenses = ["MIT"]
|
122
|
-
s.rubygems_version = "2.2.2"
|
123
|
-
s.summary = "Use Wicked to turn your controller into a wizard"
|
124
|
-
|
125
|
-
if s.respond_to? :specification_version then
|
126
|
-
s.specification_version = 4
|
127
|
-
|
128
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
129
|
-
s.add_runtime_dependency(%q<rails>, [">= 3.0.7"])
|
130
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
131
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
132
|
-
s.add_development_dependency(%q<capybara>, ["~> 1.1.2"])
|
133
|
-
s.add_development_dependency(%q<launchy>, [">= 0"])
|
134
|
-
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
135
|
-
s.add_development_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 1.3.0.beta"])
|
136
|
-
else
|
137
|
-
s.add_dependency(%q<rails>, [">= 3.0.7"])
|
138
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
139
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
140
|
-
s.add_dependency(%q<capybara>, ["~> 1.1.2"])
|
141
|
-
s.add_dependency(%q<launchy>, [">= 0"])
|
142
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
143
|
-
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 1.3.0.beta"])
|
144
|
-
end
|
145
|
-
else
|
146
|
-
s.add_dependency(%q<rails>, [">= 3.0.7"])
|
147
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
148
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
149
|
-
s.add_dependency(%q<capybara>, ["~> 1.1.2"])
|
150
|
-
s.add_dependency(%q<launchy>, [">= 0"])
|
151
|
-
s.add_dependency(%q<sqlite3>, [">= 0"])
|
152
|
-
s.add_dependency(%q<activerecord-jdbcsqlite3-adapter>, [">= 1.3.0.beta"])
|
153
|
-
end
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
gem.add_dependency "railties", [">= 3.0.7"]
|
23
|
+
gem.add_development_dependency "rails", [">= 3.0.7"]
|
24
|
+
gem.add_development_dependency "capybara", [">= 0"]
|
25
|
+
gem.add_development_dependency "appraisal"
|
26
|
+
gem.add_development_dependency "test-unit"
|
154
27
|
end
|
155
|
-
|