shoulda-callback-matchers icon indicating copy to clipboard operation
shoulda-callback-matchers copied to clipboard

Wrong number of arguments when upgrading to Rails 5.2

Open zaidhuda opened this issue 6 years ago • 7 comments

Upgrading from Rails 5.1.5 to 5.2.0 results in

ArgumentError: wrong number of arguments (given 1, expected 0)

for

callback(:after_commit_callback).after(:commit).on(:create)

zaidhuda avatar Jul 10 '18 04:07 zaidhuda

+1

rubendinho avatar Jul 28 '18 03:07 rubendinho

Same problem here !

Zethir avatar Nov 08 '18 14:11 Zethir

Looks like the issue comes from the following PR: https://github.com/rails/rails/pull/30945

More precisely:

  • https://github.com/rails/rails/commit/c792354adcbf8c966f274915c605c6713b840548#diff-174733f2db65ef1bc53e3222d6ac0e61R288
  • https://github.com/rails/rails/commit/c792354adcbf8c966f274915c605c6713b840548#diff-1ecd313ff0ab827af30014553cf8918dL460

Those changes look incompatible with calling a condition with an argument: https://github.com/jdliss/shoulda-callback-matchers/blob/b8a3680bc1d19ac713e43054a2b33238ce845698/lib/shoulda/callback/matchers/active_model.rb#L208

From my understanding, this is a "bug" on Rails side, since the mentioned PR introduces conditions that cannot be called with an argument and that change doesn't look related to the PR goal.

That said, I've only done a quick check of the two codebases, and shoulda-callback-matchers digs rather deep in a complex and private Rails API, so I might be mistaken here.

guingois avatar Nov 11 '18 11:11 guingois

+1 rails 5.2.2

kinnalru avatar Mar 20 '19 13:03 kinnalru

It looks like there was a commit a while back on a fork to work around this issue. Is that worthwhile to include? Or since it sounds like it's considered an issue with Rails, is there an issue over there I can signal boost?

moliver-hemasystems avatar Aug 01 '19 23:08 moliver-hemasystems

Same issue. Rails 6.0.0, 6.0.1

Blaze34 avatar Nov 19 '19 07:11 Blaze34

+1 -- is there an expected fix for this?

thoraxe avatar Dec 02 '21 19:12 thoraxe