hzamani / active_record-acts_as

Simulate multi-table inheritance for activerecord models
MIT License
252 stars 86 forks source link

fixing bug when touching an actable object #84

Closed abacha closed 7 years ago

manuelmeurer commented 7 years ago

What exactly is the bug? 😄

abacha commented 7 years ago

FactoryGirl was triggering 'touch' with params and in acts-as this method doesnt accept any params. ActiveRecord definition of touch receives params:

     def touch(*) #:nodoc:                                                        
       with_transaction_returning_status { super }                                
     end  

`ArgumentError: wrong number of arguments (2 for 0)

/home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/active_record-acts_as-2.0.5/lib/active_record/acts_as/instance_methods.rb:94:in `touch'

  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/configuration.rb:18:in `block in initialize'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:15:in `[]'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/evaluation.rb:15:in `create'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:12:in `block in result'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `tap'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/strategy/create.rb:9:in `result'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/factory.rb:42:in `run'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:29:in `block in run'
  # /home/abacha/.rvm/gems/ruby-2.2.5@bigbang_services/gems/factory_girl-4.8.0/lib/factory_girl/factory_runner.rb:28:in `run'

`

manuelmeurer commented 7 years ago

Thanks for your contribution, @abacha! Didn't know before that touch accepted arguments... 😄 I implemented it so that the arguments are forwarded to the supermodel. v2.0.6 is released, can you try it out if it works for you?

abacha commented 7 years ago

@manuelmeurer now its only touching the super object not the child

manuelmeurer commented 7 years ago

As mentioned in #87, the canonical repo for this gem has moved to https://github.com/krautcomputing/active_record-acts_as Please open an issue there with a code example of what is happening.