jigarius / toggl2redmine

Import time from Toggl 2 Redmine.
GNU General Public License v3.0
26 stars 6 forks source link

Make plugin compatible with Redmine 4.x #44

Closed attie-argentum closed 4 years ago

attie-argentum commented 5 years ago

When installing in the redmine:latest docker container, I get the following error:

=> Booting WEBrick
=> Rails 5.2.2 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
W, [2019-03-18T15:15:03.766360 #1]  WARN -- : Creating scope :system. Overwriting existing method Enumeration.system.
/usr/local/bundle/gems/activerecord-5.2.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `attr_protected' for #<Class:0x000055c3cade1320> (NoMethodError)
Did you mean?  attr_reader
        from /usr/src/redmine/plugins/toggl2redmine/app/models/toggl_mapping.rb:14:in `<class:TogglMapping>'
        from /usr/src/redmine/plugins/toggl2redmine/app/models/toggl_mapping.rb:1:in `<top (required)>'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:378:in `block in require_or_load'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:13:in `loading'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `load_interlock'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:356:in `require_or_load'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:334:in `depend_on'
        from /usr/local/bundle/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:246:in `require_dependency'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:477:in `each'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:477:in `block in eager_load!'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:475:in `each'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:475:in `eager_load!'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/engine.rb:356:in `eager_load!'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `each'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `call'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        from /usr/local/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
        from /usr/src/redmine/config/environment.rb:14:in `<top (required)>'
        from config.ru:3:in `require'
        from config.ru:3:in `block in <main>'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'
        from config.ru:in `new'
        from config.ru:in `<main>'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/builder.rb:49:in `eval'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/builder.rb:49:in `new_from_string'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/builder.rb:40:in `parse_file'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/server.rb:319:in `build_app_and_options_from_config'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/server.rb:219:in `app'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27:in `app'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/server.rb:354:in `wrapped_app'
        from /usr/local/bundle/gems/rack-2.0.6/lib/rack/server.rb:283:in `start'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:53:in `start'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147:in `block in perform'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `tap'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142:in `perform'
        from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/command/base.rb:65:in `perform'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/command.rb:46:in `invoke'
        from /usr/local/bundle/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
W, [2019-03-18T15:15:03.929886 #1]  WARN -- : Creating scope :sorted. Overwriting existing method Group.sorted.
W, [2019-03-18T15:15:03.934397 #1]  WARN -- : Creating scope :sorted. Overwriting existing method User.sorted.
Exiting

My Dockerfile looks like this:

FROM redmine:latest

RUN cd /usr/src/redmine/plugins \
    && git clone https://github.com/jigarius/toggl2redmine.git

/admin/info shows the following (without this plugin installed):

Environment:
  Redmine version                4.0.2.stable
  Ruby version                   2.6.1-p33 (2019-01-30) [x86_64-linux]
  Rails version                  5.2.2
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Subversion                     1.9.5
  Mercurial                      4.0
  Bazaar                         2.8.0
  Git                            2.11.0
  Filesystem                     
Redmine plugins:
  no plugin installed

Any ideas?

jigarius commented 5 years ago

I've only tested the plugin with Redmine 3.4. I did some quick research and found out that Rails 5 has deprecated the use of attr_protected. I think this will take a while to fix. I'll probably need to change the versioning scheme as well and have a Redmine 3.x branch and a 4.x branch.

attie-argentum commented 5 years ago

Hi! Thanks for getting back to me - that's a shame.

I'll leave the ticket open for others, but please don't feel any pressure to look into it further for me - I think I've come up with an alternate solution that will work for my use case.

:+1:

jigarius commented 4 years ago

Done! Here's what I did:

evolvingweb-machine commented 4 years ago

Great job, Jigar!

rbugajewski commented 4 years ago

Thanks for putting in the effort to make this plugin compatible with newer versions of Redmine / Rails.

I checked out the 4.x-dev branch and unfortunately it didn’t work. Whenever I try to select another day in the importer that has entries in Toggl, there is a 500 error response logged:

"GET /toggl2redmine/toggl_time_entries?from=2019-10-22T22%3A00%3A00.000Z&till=2019-10-23T21%3A59%3A59.000Z HTTP/1.0" 500

Are there more changes required for the plugin to be compatible with newer versions or did I miss something?

This is my environment:

  Redmine version                4.0.5.stable
  Ruby version                   2.6.5-p114 (2019-10-01) [x86_64-linux]
  Rails version                  5.2.3
jigarius commented 4 years ago

Thanks for sharing the information. I was afraid this might happen, that's why I haven't created the 4.x release tag yet. I'll take a look at this is this weekend, make sure it works with Redmine 4.x and create a tag.

jigarius commented 4 years ago

Finally test the plugin with Redmine 4.x and it works fine. It'll be good if someone could test the 4.1.2-rc1 branch and confirm that it works for them.

rbugajewski commented 4 years ago

Thanks for putting out a patch so fast. I just smoke-tested the latest version and everything seems to work as expected.

This is a great project.

jigarius commented 4 years ago

Thanks for the quick confirmation. I'm marking this as done and creating the tag v4.1.2.