incredible 0.0.5.pre → 0.0.6.pre

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: c727a08ecae2c8d018eedc46412dd2a33683934e
4
- data.tar.gz: 7c67688d5e74441324755e1a36b4537441d2da0b
3
+ metadata.gz: 651906a4431f50ed809b13868afa9f65dbc6609e
4
+ data.tar.gz: 53d4d1473af2dc890781611bd8edb47edaaed2dc
5
5
  SHA512:
6
- metadata.gz: d5f9a7b06294ef8423b5b0d91f7e42dbc5476e4bf5d3fe5bafa169be6acc10b334149a2359f07244ba3cc4de0b4df73c29b53c851f93afd30852f46e4e07d7ef
7
- data.tar.gz: e1c4455c102bdd91d83aaa8b6322cb92957e8cbddb475d9826e2e19f79f1b63c5e1098ddf6e3e44e22f6308a0db9ab064199b9645aa5e5f8570d6d917087518d
6
+ metadata.gz: 6384e7e695087f10e06fc6d20e810d525fdd9b4ca84f61f2976f2c767973af82a5142bc35b7019fa423a46460e047766a45bde7fde8e04f6a48a18be3ce5afc6
7
+ data.tar.gz: abf45ec7c79d2f7ec77ba1bbdff0f4723ab5f701ead0d1ae075fa6755671c5b10714d18038ccaf48d1284fd3f5c25a2fd2cfcd7d1f183e069f8d4c66250d3ef9
@@ -1,6 +1,7 @@
1
1
  module Incredible
2
2
  class Rule
3
3
  attr_accessor :next_params
4
+ attr_accessor :redirect
4
5
  attr_accessor :next_step
5
6
  attr_reader :params
6
7
 
@@ -1,3 +1,3 @@
1
1
  module Incredible
2
- VERSION = '0.0.5.pre'.freeze
2
+ VERSION = '0.0.6.pre'.freeze
3
3
  end
@@ -23,12 +23,20 @@ module Incredible
23
23
  def load_next_step
24
24
  if step_data.rule
25
25
  @rule = step_data.rule.send(:new, params)
26
- jump_to @rule.next_step
26
+ process_rule
27
27
  elsif step_data.next_step
28
28
  jump_to step_data.next_step
29
29
  end
30
30
  end
31
31
 
32
+ def process_rule
33
+ if @rule.next_step
34
+ jump_to @rule.next_step
35
+ elsif @rule.redirect
36
+ redirect_to @rule.redirect
37
+ end
38
+ end
39
+
32
40
  module ClassMethods
33
41
  def form(form_name)
34
42
  wizard_form = Incredible::Form.new(form_name)
@@ -28,6 +28,12 @@ describe FormsController, type: :controller do
28
28
  (put :update, params: { id: :step1, model: { name: 'Ian' } })
29
29
  ).to redirect_to('http://test.host/forms/step2')
30
30
  end
31
+
32
+ it 'redirects to another url' do
33
+ expect(
34
+ (put :update, params: { id: :step3 })
35
+ ).to redirect_to('http://test.host/things')
36
+ end
31
37
  end
32
38
 
33
39
  context 'next step is specified' do
@@ -0,0 +1,3 @@
1
+ class ThingsController < ActionController::Base
2
+ def index; end
3
+ end
@@ -0,0 +1,8 @@
1
+ class Step3Rule < Incredible::Rule
2
+ include Rails.application.routes.url_helpers
3
+
4
+ def process
5
+ @redirect = things_path
6
+ end
7
+
8
+ end
@@ -1,3 +1,4 @@
1
1
  Rails.application.routes.draw do
2
2
  resources :forms
3
+ resources :things
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incredible
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5.pre
4
+ version: 0.0.6.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - pezholio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -159,9 +159,11 @@ files:
159
159
  - spec/dummy/Rakefile
160
160
  - spec/dummy/app/controllers/application_controller.rb
161
161
  - spec/dummy/app/controllers/forms_controller.rb
162
+ - spec/dummy/app/controllers/things_controller.rb
162
163
  - spec/dummy/app/models/application_record.rb
163
164
  - spec/dummy/app/models/stub_model.rb
164
165
  - spec/dummy/app/rules/step1_rule.rb
166
+ - spec/dummy/app/rules/step3_rule.rb
165
167
  - spec/dummy/app/views/forms/bar.html.erb
166
168
  - spec/dummy/app/views/forms/foo.html.erb
167
169
  - spec/dummy/app/views/layouts/application.html.erb
@@ -226,49 +228,51 @@ signing_key:
226
228
  specification_version: 4
227
229
  summary: Build multi-page forms like a General
228
230
  test_files:
229
- - spec/dummy/package.json
230
- - spec/dummy/app/models/application_record.rb
231
- - spec/dummy/app/models/stub_model.rb
232
- - spec/dummy/app/views/layouts/mailer.html.erb
233
- - spec/dummy/app/views/layouts/application.html.erb
234
- - spec/dummy/app/views/layouts/mailer.text.erb
235
- - spec/dummy/app/views/forms/foo.html.erb
236
- - spec/dummy/app/views/forms/bar.html.erb
237
- - spec/dummy/app/rules/step1_rule.rb
238
- - spec/dummy/app/controllers/application_controller.rb
239
- - spec/dummy/app/controllers/forms_controller.rb
231
+ - spec/loader_spec.rb
232
+ - spec/step_spec.rb
233
+ - spec/controllers/forms_controller_spec.rb
234
+ - spec/form_spec.rb
235
+ - spec/spec_helper.rb
240
236
  - spec/dummy/config.ru
241
237
  - spec/dummy/bin/rake
242
- - spec/dummy/bin/update
243
- - spec/dummy/bin/bundle
244
- - spec/dummy/bin/yarn
245
238
  - spec/dummy/bin/rails
239
+ - spec/dummy/bin/update
246
240
  - spec/dummy/bin/setup
241
+ - spec/dummy/bin/yarn
242
+ - spec/dummy/bin/bundle
247
243
  - spec/dummy/Rakefile
244
+ - spec/dummy/app/rules/step3_rule.rb
245
+ - spec/dummy/app/rules/step1_rule.rb
246
+ - spec/dummy/app/controllers/forms_controller.rb
247
+ - spec/dummy/app/controllers/application_controller.rb
248
+ - spec/dummy/app/controllers/things_controller.rb
249
+ - spec/dummy/app/views/forms/foo.html.erb
250
+ - spec/dummy/app/views/forms/bar.html.erb
251
+ - spec/dummy/app/views/layouts/application.html.erb
252
+ - spec/dummy/app/views/layouts/mailer.html.erb
253
+ - spec/dummy/app/views/layouts/mailer.text.erb
254
+ - spec/dummy/app/models/stub_model.rb
255
+ - spec/dummy/app/models/application_record.rb
256
+ - spec/dummy/config/routes.rb
257
+ - spec/dummy/config/environment.rb
248
258
  - spec/dummy/config/spring.rb
249
- - spec/dummy/config/forms/form.yml
250
- - spec/dummy/config/forms/bad-yaml.yml
251
- - spec/dummy/config/initializers/filter_parameter_logging.rb
252
- - spec/dummy/config/initializers/wrap_parameters.rb
253
- - spec/dummy/config/initializers/mime_types.rb
254
- - spec/dummy/config/initializers/application_controller_renderer.rb
255
- - spec/dummy/config/initializers/assets.rb
256
- - spec/dummy/config/initializers/backtrace_silencers.rb
257
- - spec/dummy/config/initializers/inflections.rb
258
- - spec/dummy/config/initializers/cookies_serializer.rb
259
- - spec/dummy/config/environments/test.rb
260
259
  - spec/dummy/config/environments/production.rb
260
+ - spec/dummy/config/environments/test.rb
261
261
  - spec/dummy/config/environments/development.rb
262
+ - spec/dummy/config/forms/bad-yaml.yml
263
+ - spec/dummy/config/forms/form.yml
264
+ - spec/dummy/config/puma.rb
262
265
  - spec/dummy/config/secrets.yml
263
- - spec/dummy/config/cable.yml
264
266
  - spec/dummy/config/application.rb
265
- - spec/dummy/config/routes.rb
266
- - spec/dummy/config/boot.rb
267
- - spec/dummy/config/puma.rb
267
+ - spec/dummy/config/cable.yml
268
268
  - spec/dummy/config/locales/en.yml
269
- - spec/dummy/config/environment.rb
270
- - spec/spec_helper.rb
271
- - spec/form_spec.rb
272
- - spec/loader_spec.rb
273
- - spec/step_spec.rb
274
- - spec/controllers/forms_controller_spec.rb
269
+ - spec/dummy/config/initializers/cookies_serializer.rb
270
+ - spec/dummy/config/initializers/assets.rb
271
+ - spec/dummy/config/initializers/inflections.rb
272
+ - spec/dummy/config/initializers/backtrace_silencers.rb
273
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
274
+ - spec/dummy/config/initializers/application_controller_renderer.rb
275
+ - spec/dummy/config/initializers/wrap_parameters.rb
276
+ - spec/dummy/config/initializers/mime_types.rb
277
+ - spec/dummy/config/boot.rb
278
+ - spec/dummy/package.json