{"action":"closed","issue":{"url":"https://api.github.com/repos/aasm/aasm/issues/394","repository_url":"https://api.github.com/repos/aasm/aasm","labels_url":"https://api.github.com/repos/aasm/aasm/issues/394/labels{/name}","comments_url":"https://api.github.com/repos/aasm/aasm/issues/394/comments","events_url":"https://api.github.com/repos/aasm/aasm/issues/394/events","html_url":"https://github.com/aasm/aasm/issues/394","id":171253584,"number":394,"title":"Rspec ArgumentError when passing parameters to event","user":{"login":"joerodrig3","id":4582235,"avatar_url":"https://avatars.githubusercontent.com/u/4582235?v=3","gravatar_id":"","url":"https://api.github.com/users/joerodrig3","html_url":"https://github.com/joerodrig3","followers_url":"https://api.github.com/users/joerodrig3/followers","following_url":"https://api.github.com/users/joerodrig3/following{/other_user}","gists_url":"https://api.github.com/users/joerodrig3/gists{/gist_id}","starred_url":"https://api.github.com/users/joerodrig3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joerodrig3/subscriptions","organizations_url":"https://api.github.com/users/joerodrig3/orgs","repos_url":"https://api.github.com/users/joerodrig3/repos","events_url":"https://api.github.com/users/joerodrig3/events{/privacy}","received_events_url":"https://api.github.com/users/joerodrig3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-15T20:25:01Z","updated_at":"2016-08-19T18:24:33Z","closed_at":"2016-08-19T18:24:33Z","body":"I'm running into an issue where passing parameters into an AASM event from my controller produces an argument error. \r\n\r\nThe error is produced from the example code below:\r\n```ruby\r\n  # controllers/records_controller.rb\r\n  def run\r\n    @record.start_running!(current_user)\r\n  end\r\n\r\n  # controllers/records_controller_spec.rb\r\n  describe \"#run\" do\r\n    ...\r\n    it \"begins running a pending record\" do\r\n      put project_record_run_url(project, subject)\r\n      expect(response).to have_http_status(:success)\r\n    end\r\n  end\r\n\r\n  # models/record.rb\r\n  event :start_running, after: proc { |*args| run_record(*args) } do\r\n    transitions from: :pending, to: :running\r\n  end\r\n\r\n\r\n  def run_record(user)\r\n    update(user: user, start_time: Time.current)\r\n  end\r\n```\r\n\r\nError produced:\r\n```ruby\r\nFailure/Error: @record.start_running!(current_user)\r\n     \r\n     ArgumentError:\r\n       Wrong number of arguments. Expected 0, got 1.\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:156:in `invoke_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `block in invoke_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `each'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `invoke_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `block in invoke_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `each'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:165:in `invoke_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/core/event.rb:57:in `fire_global_callbacks'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/aasm.rb:171:in `aasm_fired'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/aasm.rb:120:in `aasm_fire_event'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/persistence/active_record_persistence.rb:194:in `block in aasm_fire_event'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/persistence/active_record_persistence.rb:192:in `aasm_fire_event'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/aasm-4.11.0/lib/aasm/base.rb:126:in `block in event'\r\n     # ./app/controllers/records_controller.rb:33:in `run'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/omniauth-1.3.1/lib/omniauth/builder.rb:63:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/etag.rb:25:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/conditional_get.rb:38:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/head.rb:12:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:222:in `context'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/session/abstract/id.rb:216:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/runtime.rb:22:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-2.0.1/lib/rack/sendfile.rb:111:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/sentry-raven-1.2.2/lib/raven/integrations/rack.rb:50:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-test-0.6.3/lib/rack/mock_session.rb:30:in `request'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:244:in `process_request'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/rack-test-0.6.3/lib/rack/test.rb:124:in `request'\r\n     # ./spec/requests/builds_controller_spec.rb:64:in `block (7 levels) in <top (required)>'\r\n     # ./spec/support/database_cleaner.rb:9:in `block (3 levels) in <top (required)>'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/database_cleaner-1.5.3/lib/database_cleaner/generic/base.rb:16:in `cleaning'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/database_cleaner-1.5.3/lib/database_cleaner/base.rb:98:in `cleaning'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:86:in `block (2 levels) in cleaning'\r\n     # /Users/Joe/.gem/ruby/2.3.1/gems/database_cleaner-1.5.3/lib/database_cleaner/configuration.rb:87:in `cleaning'\r\n     # ./spec/support/database_cleaner.rb:8:in `block (2 levels) in <top (required)>'\r\n```\r\n\r\nI've checked through the [parameterized event code](https://github.com/aasm/aasm/blob/master/spec/models/parametrised_event_multiple.rb#L16) and the accompanying [specs](https://github.com/aasm/aasm/blob/master/spec/unit/event_spec.rb#L350). I've also looked through some more recent solutions given in issue #324, but can't seem to figure out why this error is being produced. I'm able to enter the `run_record` method just fine, but it isn't until that method returns that this error is produced.\r\n\r\nOddly enough, this issue also seems to only occur in RSpec. Manually running the code recognizes the call just fine."}}
{"actor":{"display_login":"joerodrig3"}}