Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit private callback lookup. #58

Merged
merged 1 commit into from
Jan 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def run_action(action, *args)
end

def has_callback?(action)
self.respond_to?(action) or self.class.private_method_defined?(action)
self.respond_to?(action) or self.private_methods(false).map(&:to_sym).include?(action)
end

def run_action_callback(action_name, *args)
Expand Down
16 changes: 16 additions & 0 deletions test/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,22 @@ def assign(args)
a.assign!(args)
end

test '#58 Limited private transition callback lookup' do
args = mock()
c = Class.new
c.class_eval do
include Workflow
workflow do
state :new do
event :fail, :transitions_to => :failed
end
state :failed
end
end
a = c.new
a.fail!(args)
end

test 'Single table inheritance (STI)' do
class BigOrder < Order
end
Expand Down