ogom / redmine_sidekiq

Sidekiq plugin for Redmine
21 stars 29 forks source link

Removed :delay method for class and added guidelines to end user #4

Closed devaroop closed 10 years ago

devaroop commented 10 years ago

The delay method still existed as a class method and was giving errors for dangerous attributes from the IssuesController. Added user guidelines for whomsoever are using the :delay method, instead use the alias :sidekiq_delay

ogom commented 10 years ago

thank a lot.

devaroop commented 10 years ago

Cheers buddy (y) Thanks for accepting !

amse2000 commented 10 years ago

Somehow I cannot view Issues, because there is a "delay" attribute in the Database-Table: "issue_relations" - maybe this comes from any other plugin.

I don't know how to get it to work. After renaming the "delay" attribut in issue_relations to "issue_delay" it seems to work, but I don't know what will happen if anything else is trying to access the issue_relations.delay attribute then... going to test it further. Any help would be appreciated.

I found this on: https://github.com/Undev/redmine_sidekiq/blob/master/lib/redmine_sidekiq.rb IssueRelation has a "delay" attribute and to prevent ActiveRecord::DangerousAttributeError we remove sidekiq method: ActiveRecord::Base.send :undef_method, :delay

devaroop commented 10 years ago

Well, the last statement is also removing the :delay method like how this patch does. Can you please try this:

1) Goto redmine console (using RAILS_ENV=production rails c from redmine root) 2) Type User.delay

That should throw you a undefined method 'delay' exception.

If it doesn't, then just try to grab the exception you are getting while viewing the issues and paste it here. Lets dig more into that.

amse2000 commented 10 years ago

Tanks for the fast reply and help. Here some information and finaly the exception...

First the Environment and installed plugins. Environment: Redmine version 2.5.1.devel Ruby version 1.9.3-p547 (2014-05-14) [x86_64-linux] Rails version 3.2.19 Environment production Database adapter Mysql2 SCM: Subversion 1.6.17 Git 1.7.10.4 Filesystem
Redmine plugins: redmine_better_gantt_chart 0.9.0 redmine_bootstrap_kit 0.1 redmine_ckeditor 1.0.16 redmine_close_button 0.0.8 redmine_git_hosting 0.7.3 redmine_issue_checklist 2.0.5 redmine_sidekiq 2.0.1

The ouput of User.delay was: (I already changed some config to get rid of the [deprecated] info, but I changed it back thinking the Issue-Error comes from some failure here) RAILS_ENV=production rails c [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. Loading production environment (Rails 3.2.19) 1.9.3-p547 :001 > User.delay => 995f2158c51eba9362ec4580 1.9.3-p547 :002 >

Some infos from the plugins directory: grep -rin --include=.rb ':delay' \ redmine_sidekiq/lib/redmine_sidekiq/configure.rb:20: remove_method :delay if respond_to?(:delay) redmine_sidekiq/lib/redmine_sidekiq/configure.rb:24: remove_method :delay if respond_to?(:delay) redmine_sidekiq/lib/redmine_sidekiq/configure.rb:28: remove_method :delay if respond_to?(:delay)

Or even: grep -rin --include=.rb 'delay' \ (I tried using sidekiq_delay instead of delay in issue_dependency, but I think this refers to the delay attribute in the issue_relations datatable) redmine_better_gantt_chart/lib/redmine_better_gantt_chart/issues_helper_patch.rb:22: @cached_label_delay ||= l(:field_delay) redmine_better_gantt_chart/lib/redmine_better_gantt_chart/issue_dependency_patch.rb:95: new_start_date = RedmineBetterGanttChart::Calendar.workdays_from_date(due_date, relation.sidekiq_delay) + 1.day redmine_better_gantt_chart/spec/controllers/gantts_controller_spec.rb:73: @blocks_issue.relations << IssueRelation.create!(:issue_from => @blocks_issue, :issue_to => @duplicated_issue, :relation_type => "duplicates", :sidekiq_delay => 0) redmine_better_gantt_chart/spec/controllers/gantts_controller_spec.rb:81: @blocks_issue.relations << IssueRelation.create!(:issue_from => @blocks_issue, :issue_to => @duplicated_issue, :relation_type => "duplicates", :sidekiq_delay => 0) redmine_sidekiq/lib/redmine_sidekiq/configure.rb:20: remove_method :delay if respond_to?(:delay) redmine_sidekiq/lib/redmine_sidekiq/configure.rb:24: remove_method :delay if respond_to?(:delay) redmine_sidekiq/lib/redmine_sidekiq/configure.rb:28: remove_method :delay if respond_to?(:delay)

Finally the exception from the "production.log": Started GET "/issues/13" for at 2014-07-08 17:28:17 +0200 Processing by IssuesController#show as HTML Parameters: {"id"=>"13"} Current user: My (id=1) Completed 500 Internal Server Error in 807.7ms

ActiveRecord::DangerousAttributeError (delay is defined by ActiveRecord): app/models/issue_relation.rb:89:in initialize' app/controllers/issues_controller.rb:123:innew' app/controllers/issues_controller.rb:123:in `show'

amse2000 commented 10 years ago

I found something interesting. After switching back to the snapshot before starting some updates, I realised that the Rails Version changed from 3.2.18 to 3.2.19 and the redmine_sidekiq plugin changed from 2.0.0 to 2.0.1.

User.delay then tells the following: 1.9.3-p547 :001 > User.delay NoMethodError: undefined method delay' for #<Class:0x000000050b7958> from /usr/local/rvm/gems/ruby-1.9.3-p547/gems/activerecord-3.2.18/lib/active_record/dynamic_matchers.rb:55:inmethod_missing' ...

Viewing of Issues works fine - so something seems to went wrong while updating - or I forgot to do something after the update... ?

devaroop commented 10 years ago

@amse2000 The response for User.delay in your previous comment is what we need. The one just before that is actually calling the sidekiq method instead. Use the master branch of this plugin and try again. Hopefully that will solve your problem. Let us know.

ogom commented 10 years ago

Add Sidekiq.remove_delay! on configure.rb

Sidekiq.remove_delay! if Sidekiq.methods.index(:remove_delay!)

https://github.com/mperham/sidekiq/wiki/Delayed-Extensions#disabling-extensions