wicked 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22f6f41073e2bea73b0a1310eb93b7cca68d9787
4
- data.tar.gz: aceb9c69831a4ebe134fb61fe3968a909c404491
3
+ metadata.gz: ca29f07129a3bd5421302dcb0874781a7b24fb54
4
+ data.tar.gz: f028ee27c846686197b0123e9499009b32333b51
5
5
  SHA512:
6
- metadata.gz: 8101763f8b5ff60c28a458e61d4270fdcf1a9ce70a8c10dcaaad52263918fd30f6ae7a619b9a75d967fb44e5ea539623c037ae9b8ac0920744162389cb7d9964
7
- data.tar.gz: 66fffeef5ea6e6847bfafc6f5ed809525ca97f342f22c0588ac86b53a9162fb2cb541c8dc7bb3bceef95f61bf957cbfafd27609b7ad01a61fb4069e92a103736
6
+ metadata.gz: 7e476dda9b21b6ea7f5656c2c7066862efce98324a1b10992af06354f87bd24bb6e1e9b346939ce315dcc2939cc79b18dc7dda62564d001762296766441ccb84
7
+ data.tar.gz: 6f0a215e5a112cdcbd0fbced343382bf58f5dabbc9b011ba0a26e4cf17457aca4bf56cec5fe2ef6f209bbe9900b85a58d61ea92f52cafd7e2f8b9d0b1aae332c
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - 2.1.1
6
+ - 2.2.2
6
7
  - ruby-head
7
8
  - jruby-19mode
8
9
 
@@ -14,8 +15,10 @@ gemfile:
14
15
  - gemfiles/4.0.gemfile
15
16
  - gemfiles/4.1.gemfile
16
17
  - gemfiles/4.2.gemfile
17
-
18
18
  matrix:
19
+ include:
20
+ - gemfile: gemfiles/5.0.beta2.gemfile
21
+ rvm: 2.2.2
19
22
  allow_failures:
20
23
  - gemfile: gemfiles/3.0.gemfile
21
24
  rvm: 2.0.0
data/Appraisals CHANGED
@@ -23,3 +23,8 @@ appraise "4.2" do
23
23
  gem "rails", "~> 4.2"
24
24
  gemspec
25
25
  end
26
+
27
+ appraise "5.0.beta2" do
28
+ gem "rails", "~> 5.0.0.beta2"
29
+ gemspec
30
+ end
@@ -1,10 +1,13 @@
1
1
  ## Master
2
2
 
3
+ ## 1.3.0
4
+
5
+ * [#201] Avoid Rails 5 deprecations.
6
+
3
7
  ## 1.2.1 (8/28/2015)
4
8
 
5
9
  * [#186] Do not require use of ApplicationController with wicked.
6
10
 
7
-
8
11
  ## 1.1.1 (2/23/2015)
9
12
 
10
13
  * [#159] Default wizard index actions now work when using `default_url_options`
data/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  # Step-By-Step Wizard Controllers
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/schneems/wicked.png)](http://travis-ci.org/schneems/wicked)
6
- [![Code Climate](https://codeclimate.com/github/schneems/wicked.png)](https://codeclimate.com/github/schneems/wicked)
5
+ [![Build Status](https://travis-ci.org/schneems/wicked.svg?branch=master)](https://travis-ci.org/schneems/wicked)
6
+ [![Code Climate](https://codeclimate.com/github/schneems/wicked/badges/gpa.svg)](https://codeclimate.com/github/schneems/wicked)
7
+
7
8
 
8
9
  Use wicked to make your Rails controllers into step-by-step wizards. To see Wicked in action check out the example [Rails app](https://github.com/schneems/wicked_example) or [watch the screencast](http://schneems.com/post/18437886598/wizard-ify-your-rails-controllers-with-wicked).
9
10
 
@@ -277,7 +278,7 @@ es:
277
278
  It would also be a good idea to create a english version under `config/locales/en.yml` or your english speaking friends will get errors. If your app already uses I18n you don't need to do anything else, if not you will need to make sure that you set the `I18n.locale` on each request you could do this somewhere like a before filter in your application_controller.rb
278
279
 
279
280
  ```ruby
280
- before_filter :set_locale
281
+ before_action :set_locale
281
282
 
282
283
  private
283
284
 
@@ -363,7 +364,7 @@ config.i18n.default_locale = :de
363
364
  ```
364
365
 
365
366
  **Important:** Don't forget to use `wizard_value()` method to make
366
- sure you are using the right cannonical values of `step`,
367
+ sure you are using the right canonical values of `step`,
367
368
  `previous_step`, `next_step`, etc. If you are comparing them to non
368
369
  wicked generate values.
369
370
 
@@ -0,0 +1,12 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.0.0.beta2"
6
+
7
+ group :development, :test do
8
+ gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
9
+ gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.13", :platform => :jruby
10
+ end
11
+
12
+ gemspec :path => "../"
@@ -22,6 +22,7 @@ class WickedProtectedStepError < WickedError; end
22
22
  require 'wicked/controller/concerns/render_redirect'
23
23
  require 'wicked/controller/concerns/steps'
24
24
  require 'wicked/controller/concerns/path'
25
+ require 'wicked/controller/concerns/action'
25
26
  require 'wicked/wizard'
26
27
  require 'wicked/wizard/translated'
27
28
  require 'wicked/engine'
@@ -0,0 +1,13 @@
1
+ module Wicked::Controller::Concerns::Action
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ def self.extended(base)
6
+ %w{before skip_before prepend_before}.each do |action|
7
+ define_method "#{action}_action" do |*names, &blk|
8
+ send("#{action}_filter", *names, &blk)
9
+ end unless base.respond_to? "#{action}_action"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -20,6 +20,7 @@ module Wicked::Controller::Concerns::Path
20
20
 
21
21
 
22
22
  def wizard_path(goto_step = nil, options = {})
23
+ options = options.to_h if options.respond_to?(:permitted?) && options.respond_to?(:to_h)
23
24
  options = { :controller => wicked_controller,
24
25
  :action => 'show',
25
26
  :id => goto_step || params[:id],
@@ -52,7 +52,7 @@ module Wicked::Controller::Concerns::Steps
52
52
  options = args.extract_options!
53
53
  steps = args
54
54
  check_protected!(steps)
55
- prepend_before_filter(options) do
55
+ prepend_before_action(options) do
56
56
  self.steps = steps.dup
57
57
  end
58
58
  end
@@ -1,3 +1,3 @@
1
1
  module Wicked
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -10,23 +10,25 @@ module Wicked
10
10
 
11
11
  class UndefinedStepsError < RuntimeError
12
12
  def initialize
13
- super "No step definitions have been supplied; if setting via `before_filter`, use `prepend_before_filter`"
13
+ super "No step definitions have been supplied; if setting via `before_action`, use `prepend_before_action`"
14
14
  end
15
15
  end
16
16
 
17
17
  # Include the modules!!
18
+
18
19
  include Wicked::Controller::Concerns::Path
19
20
  include Wicked::Controller::Concerns::RenderRedirect
20
21
  include Wicked::Controller::Concerns::Steps
21
22
 
22
23
  included do
24
+ include Wicked::Controller::Concerns::Action
23
25
  # Give our Views helper methods!
24
26
  helper_method :wizard_path, :next_wizard_path, :previous_wizard_path,
25
27
  :step, :wizard_steps, :current_step?,
26
28
  :past_step?, :future_step?, :previous_step?,
27
29
  :next_step?
28
30
  # Set @step and @next_step variables
29
- before_filter :setup_wizard
31
+ before_action :setup_wizard
30
32
  end
31
33
 
32
34
  # forward to first step with whatever params are provided
@@ -5,8 +5,8 @@ module Wicked
5
5
  include Wicked::Wizard
6
6
 
7
7
  included do
8
- skip_before_filter :setup_wizard
9
- before_filter :setup_wizard_translated
8
+ skip_before_action :setup_wizard
9
+ before_action :setup_wizard_translated
10
10
 
11
11
  helper_method :wizard_translate, :wizard_value
12
12
  end
@@ -1,13 +1,14 @@
1
1
  require 'test_helper'
2
2
 
3
- class BarControllerTest < ActionController::TestCase
3
+ class BarControllerTest < WickedControllerTestCase
4
+
4
5
  test 'index redirects to the first step' do
5
6
  get :index
6
7
  assert_redirected_to bar_path(:first)
7
8
  end
8
9
 
9
10
  test 'index redirects to the first step, preserving query args' do
10
- get :index, :some => 'arguments', :were => 'passed'
11
+ get :index, params: { :some => 'arguments', :were => 'passed' }
11
12
  assert_redirected_to bar_path(:first, :some => 'arguments', :were => 'passed')
12
13
  end
13
14
  end
@@ -1,26 +1,26 @@
1
1
  require 'test_helper'
2
2
 
3
- class UpdatesControllerTest < ActionController::TestCase
3
+ class UpdatesControllerTest < WickedControllerTestCase
4
4
  test 'redirect from first step to second step' do
5
- put :update, :id => 'first'
5
+ put :update, params: {:id => 'first'}
6
6
  assert_redirected_to update_path(:second)
7
7
  assert_equal 'Thing was updated from step first.', flash[:notice]
8
8
  end
9
9
 
10
10
  test 'redirect from second step to final step' do
11
- put :update, :id => 'second'
11
+ put :update, params: {:id => 'second'}
12
12
  assert_redirected_to update_path(:last_step)
13
13
  assert_equal 'Thing was updated from step second.', flash[:notice]
14
14
  end
15
15
 
16
16
  test 'redirect from last_step to root path' do
17
- put :update, :id => 'last_step'
17
+ put :update, params: {:id => 'last_step'}
18
18
  assert_redirected_to update_path(:wicked_finish)
19
19
  assert_equal 'Thing was updated from step last_step.', flash[:notice]
20
20
  end
21
21
 
22
22
  test 'redirect from wicked_finish to root path' do
23
- get :show, {:id => Wicked::FINISH_STEP}, {}, {:notice => "flash from last_step"}
23
+ get :show, params: {:id => Wicked::FINISH_STEP}, flash: {:notice => "flash from last_step"}
24
24
  assert_redirected_to updates_path
25
25
  assert_equal 'flash from last_step', flash[:notice]
26
26
  end
@@ -1,7 +1,10 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
- before_filter :pull_out_locale
4
-
3
+ if respond_to? :before_action
4
+ before_action :pull_out_locale
5
+ else
6
+ before_filter :pull_out_locale
7
+ end
5
8
 
6
9
  def pull_out_locale
7
10
  I18n.locale = params[:locale] if params[:locale].present?
@@ -1,8 +1,8 @@
1
1
  class DynamicDifferentStepsController < ApplicationController
2
2
  include Wicked::Wizard
3
3
 
4
- before_filter :set_steps
5
- before_filter :setup_wizard
4
+ before_action :set_steps
5
+ before_action :setup_wizard
6
6
 
7
7
  def show
8
8
  render_wizard
@@ -1,6 +1,6 @@
1
1
  class DynamicStepsController < ApplicationController
2
2
  include Wicked::Wizard
3
- prepend_before_filter :set_steps
3
+ prepend_before_action :set_steps
4
4
 
5
5
  def show
6
6
  render_wizard
@@ -5,8 +5,8 @@ class JumpController < ApplicationController
5
5
  steps :first, :second, :last_step
6
6
 
7
7
  def show
8
- skip_step(params[:skip_step_options]) if params[:skip_step]
9
- jump_to :last_step, params[:skip_step_options] if params[:jump_to]
8
+ skip_step(skip_step_options) if params[:skip_step]
9
+ jump_to :last_step, skip_step_options if params[:jump_to]
10
10
  if params[:resource]
11
11
  value = params[:resource][:save] == 'true'
12
12
  @bar = Bar.new(value)
@@ -19,4 +19,11 @@ class JumpController < ApplicationController
19
19
  def update
20
20
  end
21
21
 
22
+ private
23
+
24
+ def skip_step_options
25
+ options = params[:skip_step_options]
26
+ options.permit! if options.respond_to? :permitted?
27
+ options
28
+ end
22
29
  end
@@ -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
@@ -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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wicked
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2016-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -102,7 +102,9 @@ files:
102
102
  - gemfiles/4.0.gemfile
103
103
  - gemfiles/4.1.gemfile
104
104
  - gemfiles/4.2.gemfile
105
+ - gemfiles/5.0.beta2.gemfile
105
106
  - lib/wicked.rb
107
+ - lib/wicked/controller/concerns/action.rb
106
108
  - lib/wicked/controller/concerns/path.rb
107
109
  - lib/wicked/controller/concerns/render_redirect.rb
108
110
  - lib/wicked/controller/concerns/steps.rb
@@ -200,6 +202,7 @@ files:
200
202
  - test/integration/steps_test.rb
201
203
  - test/integration/updates_test.rb
202
204
  - test/support/integration_case.rb
205
+ - test/support/wicked_controller_test_case.rb
203
206
  - test/test_helper.rb
204
207
  - test/wicked_test.rb
205
208
  - wicked.gemspec
@@ -223,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
226
  version: '0'
224
227
  requirements: []
225
228
  rubyforge_project:
226
- rubygems_version: 2.4.5.1
229
+ rubygems_version: 2.5.1
227
230
  signing_key:
228
231
  specification_version: 4
229
232
  summary: Use Wicked to turn your controller into a wizard
@@ -317,5 +320,6 @@ test_files:
317
320
  - test/integration/steps_test.rb
318
321
  - test/integration/updates_test.rb
319
322
  - test/support/integration_case.rb
323
+ - test/support/wicked_controller_test_case.rb
320
324
  - test/test_helper.rb
321
325
  - test/wicked_test.rb