TravisSpangle / redmine_spent_time_in_issue_description

Redmine Plugin that drops Time Entry data into the Issue Description
16 stars 16 forks source link

undefined method `spent_on_shown?' #20

Closed hsychla closed 9 years ago

hsychla commented 9 years ago

As requested, a new issue with my problem. After installing the plugin, we get a 500 error when opening issues and the following log entry:

Started GET "/issues/3217" for 127.0.0.1 at 2015-04-08 09:57:49 +0200
Processing by IssuesController#show as HTML
  Parameters: {"id"=>"3217"}
  Current user: hsychla (id=4)
  Rendered issues/_action_menu.html.erb (25.2ms)
  Rendered plugins/advanced_roadmap_v2/app/views/hooks/issues/_show.html.erb (2.0ms)
  Rendered plugins/redmine_contacts/app/views/deals_issues/_show.html.erb (1.4ms)
  Rendered plugins/redmine_tags/app/views/issues/_tags.html.erb (2.1ms)
  Rendered plugins/redmine_contacts_helpdesk/app/views/issues/_ticket_data.html.erb (10.4ms)
  Rendered plugins/redmine_products/app/views/products_issues/_products.html.erb (3.1ms)
  Rendered attachments/_links.html.erb (4.5ms)
  Rendered plugins/redmine_checklists/app/views/issues/_checklist.html.erb (1.0ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/_time_spent_report.html.erb (71.8ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/show.html.erb within layouts/base (146.0ms)
Completed 500 Internal Server Error in 262.9ms

ActionView::Template::Error (undefined method `spent_on_shown?' for #<#<Class:0x00000002ce15b0>:0x00000000ef12f8>):
    15:   <tbody>
    16:     <% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
    17:       <tr>
    18:         <%= content_tag(:td, format_date( entry.spent_on ) ) if spent_on_shown? %>
    19:         <%= content_tag(:td, link_to_user( entry.user )) if user_shown? %>
    20:         <%= content_tag(:td, report_time_spent(entry) ) if report_time_shown? %>
    21:         <%= content_tag(:td, entry.comments ) if comment_shown? %>
  app/controllers/issues_controller.rb:128:in `block (2 levels) in show'
  app/controllers/issues_controller.rb:125:in `show'

Our system is:

Environment:
  Redmine version                2.6.3.stable.14155
  Ruby version                   2.1.2-p95 (2014-05-08) [x86_64-linux]
  Rails version                  3.2.21
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.8.8
  Git                            1.9.1
  Filesystem                     
Redmine plugins:
  advanced_roadmap_v2            2.4.0
  redmine_agile                  1.3.8
  redmine_checklists             3.0.4
  redmine_contacts               3.4.5
  redmine_contacts_google_sync   2.0.3
  redmine_contacts_helpdesk      2.4.0
  redmine_contacts_invoices      3.3.0
  redmine_contacts_money_exchange 1.1.1
  redmine_finance                1.2.1
  redmine_ics_export             3.0.0.dev
  redmine_leaves                 0.1.0
  redmine_mentions               0.0.1
  redmine_people                 0.1.8
  redmine_products               1.1.0
  redmine_questions              0.0.5
  redmine_tags                   2.0.1-dev
  redmine_timesheet_plugin       0.7.0
  redmine_update_reminder        1.0.1
  redmine_zenedit                0.0.2
  wiki_external_filter           0.0.2

Any idea what's missing/wrong?

alexbevi commented 9 years ago

I'm having the same problem, and it looks like it's due to the hook being overwritten by a plugin with a higher precedence (based on load-order?)

in my case, it was the advanced_roadmap:

Started GET "/issues/171" for 127.0.0.1 at 2015-07-28 02:20:46 +0000
Processing by IssuesController#show as HTML
  Parameters: {"id"=>"171"}
  Current user: alex (id=1)
  Rendered issues/_action_menu.html.erb (14.8ms)
  Rendered plugins/advanced_roadmap/app/views/common/_advanced_roadmap_footer.html.erb (0.8ms)
  Rendered plugins/advanced_roadmap/app/views/hooks/issues/_show.html.erb (7.9ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/_time_spent_report.html.erb (80.1ms)
  Rendered plugins/redmine_spent_time_in_issue_description/app/views/issues/show.html.erb within layouts/base (164.7ms)
Completed 500 Internal Server Error in 341ms (ActiveRecord: 77.6ms)

ActionView::Template::Error (undefined method `spent_on_shown?' for #<#<Class:0x0000000984e960>:0x00000008896928>):
    16:   <tbody>
    17:     <% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
    18:       <tr>
    19:         <%= content_tag(:td, format_date( entry.spent_on ) ) if spent_on_shown? %>
    20:         <%= content_tag(:td, link_to_user( entry.user )) if user_shown? %>
    21:         <%= content_tag(:td, report_time_spent(entry) ) if report_time_shown? %>
    22:         <%= content_tag(:td, entry.comments ) if comment_shown? %>
  app/controllers/issues_controller.rb:118:in `block (2 levels) in show'
  app/controllers/issues_controller.rb:115:in `show'

Removing your plugin for the time being, but this shouldn't be too difficult to fix.

Maybe in your initialization block try using

ActionDispatch::Reloader.to_prepare do
  require 'issue_helper_patch'
  require 'setup_issue_show'
end

to require your patches?

alexbevi commented 9 years ago

nevermind. I just tried that and that does NOT work ...

TravisSpangle commented 9 years ago

It's some incompatibility with other plugins. Still haven't been able to pin point the cause but it is with the Issues Helper Patch.

TravisSpangle commented 9 years ago

I included the IssuesHelper methods a different way and it now works with the conflicting plugin advanced_roadmap. Can someone checkout the SpentShownFix branch and verify on their end?

iarovikov commented 9 years ago

@TravisSpangle I tried SpentShownFix branch and it seems to work. Thank you. Can you merge it to master? image

TravisSpangle commented 9 years ago

Thanks for verifying!