hat-trick 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,5 @@
1
+ * 0.2.1 - Fix a bug where button_to data was shared across multiple users of the app. They are now user-specific, as they should be.
2
+
1
3
  * 0.2.0 - Now calls before/after :each callbacks before the step-specific ones
2
4
 
3
5
  * 0.1.5 - Allow hide_button DSL method inside before / after blocks
@@ -2,12 +2,12 @@ require 'hat_trick/step_definition'
2
2
 
3
3
  module HatTrick
4
4
  class Step
5
- attr_reader :step_def, :wizard
5
+ attr_reader :step_def, :wizard, :buttons
6
6
  attr_accessor :next_step, :redirect_from
7
7
  attr_writer :skipped
8
8
 
9
- delegate :name, :fieldset, :add_button, :delete_button, :buttons, :to_sym,
10
- :to_s, :run_after_callback, :run_before_callback, :include_data,
9
+ delegate :name, :fieldset, :to_sym, :to_s, :run_after_callback,
10
+ :run_before_callback, :include_data,
11
11
  :run_include_data_callback, :run_step_contents_callback,
12
12
  :include_data_key, :config, :step_contents, :last?, :first?,
13
13
  :to => :step_def
@@ -16,10 +16,22 @@ module HatTrick
16
16
 
17
17
  def initialize(step_def, wizard)
18
18
  @step_def = step_def
19
+ @buttons = step_def.buttons.dup
19
20
  @wizard = wizard
20
21
  @skipped = step_def.skipped?
21
22
  end
22
23
 
24
+ def add_button(button)
25
+ @buttons.delete_if do |b|
26
+ b.keys.first == button.keys.first && b[b.keys.first][:default]
27
+ end
28
+ @buttons << button
29
+ end
30
+
31
+ def delete_button(type)
32
+ @buttons.delete_if { |b| b.keys.first == type }
33
+ end
34
+
23
35
  def skipped?
24
36
  @skipped || (skipped_steps.include?(self.to_sym) && !visited?)
25
37
  end
@@ -149,7 +149,14 @@ module HatTrick
149
149
  end
150
150
 
151
151
  def run_before_callback(context, model)
152
- Rails.logger.info "Running before callback for #{name}"
152
+ log_msg = if model && model.respond_to?(:id)
153
+ "Running before callback for #{name} with model id #{model.id}"
154
+ elsif model && model.is_a?(ActiveModel::Errors)
155
+ "Running before callback for #{name} with errors on model id #{model.instance_variable_get(:@base).id}"
156
+ else
157
+ "Running before callback for #{name}"
158
+ end
159
+ Rails.logger.info log_msg
153
160
  run_callbacks(before_callbacks, context, model)
154
161
  end
155
162
 
@@ -1,3 +1,3 @@
1
1
  module HatTrick
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -22,6 +22,7 @@ module HatTrick
22
22
  end
23
23
 
24
24
  def model=(new_model)
25
+ Rails.logger.info "Setting model for #{object_id} to #{new_model.inspect}"
25
26
  @model = new_model
26
27
  end
27
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hat-trick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec