wicked 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/check_changelog.yml +13 -0
  3. data/.github/workflows/ci.yml +53 -0
  4. data/.gitignore +15 -0
  5. data/Appraisals +11 -0
  6. data/CHANGELOG.md +45 -0
  7. data/CONTRIBUTING.md +19 -0
  8. data/Gemfile +3 -20
  9. data/README.md +150 -35
  10. data/Rakefile +2 -15
  11. data/gemfiles/rails_5.2.gemfile +12 -0
  12. data/gemfiles/rails_6.0.gemfile +12 -0
  13. data/gemfiles/rails_7.0.gemfile +12 -0
  14. data/lib/wicked/controller/concerns/action.rb +13 -0
  15. data/lib/wicked/controller/concerns/path.rb +13 -3
  16. data/lib/wicked/controller/concerns/render_redirect.rb +35 -23
  17. data/lib/wicked/controller/concerns/steps.rb +12 -17
  18. data/lib/wicked/version.rb +3 -0
  19. data/lib/wicked/wizard/translated.rb +3 -6
  20. data/lib/wicked/wizard.rb +28 -23
  21. data/{app/controllers → lib}/wicked/wizard_controller.rb +1 -2
  22. data/lib/wicked.rb +2 -1
  23. data/test/controllers/bar_controller_test.rb +3 -2
  24. data/test/controllers/status_codes_controller_test.rb +18 -0
  25. data/test/controllers/updates_controller_test.rb +27 -0
  26. data/test/dummy/app/controllers/application_controller.rb +5 -2
  27. data/test/dummy/app/controllers/dynamic_different_steps_controller.rb +18 -0
  28. data/test/dummy/app/controllers/dynamic_steps_controller.rb +1 -1
  29. data/test/dummy/app/controllers/jump_controller.rb +9 -2
  30. data/test/dummy/app/controllers/redirect_to_next_controller.rb +1 -1
  31. data/test/dummy/app/controllers/status_codes_controller.rb +39 -0
  32. data/test/dummy/app/controllers/update_params_controller.rb +30 -0
  33. data/test/dummy/app/controllers/updates_controller.rb +30 -0
  34. data/test/dummy/app/views/bar/first.html.erb +3 -1
  35. data/test/dummy/app/views/bar/second.html.erb +2 -1
  36. data/test/dummy/app/views/dynamic_different_steps/first.html.erb +3 -0
  37. data/test/dummy/app/views/jump/last_step.html.erb +3 -1
  38. data/test/dummy/app/views/jump/second.html.erb +3 -1
  39. data/test/dummy/app/views/status_codes/bad.html.erb +1 -0
  40. data/test/dummy/app/views/status_codes/good.html.erb +1 -0
  41. data/test/dummy/app/views/update_params/_step_position.html.erb +16 -0
  42. data/test/dummy/app/views/update_params/first.html.erb +1 -0
  43. data/test/dummy/app/views/update_params/index.html.erb +1 -0
  44. data/test/dummy/app/views/update_params/last_step.html.erb +1 -0
  45. data/test/dummy/app/views/update_params/second.html.erb +1 -0
  46. data/test/dummy/app/views/updates/_step_position.html.erb +16 -0
  47. data/test/dummy/app/views/updates/first.html.erb +1 -0
  48. data/test/dummy/app/views/updates/index.html.erb +1 -0
  49. data/test/dummy/app/views/updates/last_step.html.erb +1 -0
  50. data/test/dummy/app/views/updates/second.html.erb +1 -0
  51. data/test/dummy/config/application.rb +3 -0
  52. data/test/dummy/config/environments/development.rb +0 -1
  53. data/test/dummy/config/environments/test.rb +3 -1
  54. data/test/dummy/config/routes.rb +4 -0
  55. data/test/integration/dynamic_steps_test.rb +8 -1
  56. data/test/integration/helpers_test.rb +27 -0
  57. data/test/integration/jump_test.rb +16 -0
  58. data/test/integration/redirect_to_next_test.rb +1 -1
  59. data/test/integration/security_test.rb +0 -2
  60. data/test/integration/update_params_test.rb +20 -0
  61. data/test/integration/updates_test.rb +20 -0
  62. data/test/support/wicked_controller_test_case.rb +9 -0
  63. data/test/test_helper.rb +9 -9
  64. data/wicked.gemspec +22 -150
  65. data/wicked.png +0 -0
  66. metadata +156 -51
  67. data/.rvmrc +0 -19
  68. data/.travis.yml +0 -22
  69. data/VERSION +0 -1
  70. /data/test/dummy/app/controllers/{steps_controller.rb → step_positions_controller.rb} +0 -0
@@ -41,5 +41,8 @@ module Dummy
41
41
 
42
42
  # Configure sensitive parameters which will be filtered from the log file.
43
43
  config.filter_parameters += [:password]
44
+
45
+ config.eager_load = false
46
+ config.secret_key_base = 'foo'
44
47
  end
45
48
  end
@@ -11,7 +11,6 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
14
  config.action_controller.perform_caching = false
16
15
 
17
16
  # Don't care if the mailer can't send
@@ -8,7 +8,7 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
11
+ config.whiny_nils = true if Rails::VERSION::MAJOR == 3
12
12
 
13
13
  # Show full error reports and disable caching
14
14
  config.consider_all_requests_local = true
@@ -32,4 +32,6 @@ Dummy::Application.configure do
32
32
 
33
33
  # Print deprecation notices to the stderr
34
34
  config.active_support.deprecation = :stderr
35
+
36
+ config.active_support.test_order = :sorted
35
37
  end
@@ -4,9 +4,13 @@ Dummy::Application.routes.draw do
4
4
  resources :jump
5
5
  resources :step_positions
6
6
  resources :dynamic_steps
7
+ resources :dynamic_different_steps
7
8
  resources :string_steps
8
9
  resources :redirect_to_next
9
10
  resources :redirect_to_finish_flash
11
+ resources :status_codes
12
+ resources :updates
13
+ resources :update_params
10
14
 
11
15
  resources :nested do
12
16
  resources :builder, :controller => 'nested/builder'
@@ -1,10 +1,17 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class DynamicStepsTest < ActiveSupport::IntegrationCase
4
- test 'set dynamic steps from params' do
4
+ test 'set dynamic steps from params using prepend' do
5
5
  steps = ['first', 'second']
6
6
  visit dynamic_steps_path(:steps => steps)
7
7
  assert_has_content?(steps.first.inspect)
8
8
  assert_has_content?(steps.inspect)
9
9
  end
10
+
11
+ test 'set dynamic steps from params without using' do
12
+ steps = ['first', 'second']
13
+ visit dynamic_different_steps_path(:steps => steps)
14
+ assert_has_content?(steps.first.inspect)
15
+ assert_has_content?(steps.inspect)
16
+ end
10
17
  end
@@ -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
@@ -26,4 +26,4 @@ class RedirectToNextTest < ActiveSupport::IntegrationCase
26
26
  assert_has_content?('home')
27
27
  assert_has_content?('notice:jump notice')
28
28
  end
29
- end
29
+ 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
@@ -0,0 +1,9 @@
1
+ class WickedControllerTestCase < ActionController::TestCase
2
+ if ActionPack::VERSION::MAJOR < 5
3
+ %w{get post put update}.each do |meth|
4
+ define_method meth do |action, args={}|
5
+ super(action, args[:params], args[:session], args[:flash])
6
+ end
7
+ end
8
+ end
9
+ 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
- # Run any available migration
27
- ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
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 ActiveRecord.version < Gem::Version.create("5.2.0")
22
+ ActiveRecord::Migrator.migrate(migrate_path)
23
+ elsif ActiveRecord.version < Gem::Version.create("6.0.0")
24
+ ActiveRecord::MigrationContext.new(migrate_path).migrate
25
+ else
26
+ ActiveRecord::MigrationContext.new(migrate_path, ActiveRecord::SchemaMigration).migrate
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
- # stub: wicked 1.0.3 ruby lib
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 |s|
8
- s.name = "wicked"
9
- s.version = "1.0.3"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["schneems"]
14
- s.date = "2014-04-25"
15
- s.description = "Wicked is a Rails engine for producing easy wizard controllers"
16
- s.email = "richard.schneeman@gmail.com"
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
- s.files = [
21
- ".rvmrc",
22
- ".travis.yml",
23
- "CHANGELOG.md",
24
- "Gemfile",
25
- "MIT-LICENSE",
26
- "README.md",
27
- "Rakefile",
28
- "VERSION",
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
-
data/wicked.png ADDED
Binary file