Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when closing an issue without any journals #1

Open
edavis10 opened this issue Jul 3, 2009 · 3 comments
Open

Error when closing an issue without any journals #1

edavis10 opened this issue Jul 3, 2009 · 3 comments

Comments

@edavis10
Copy link

edavis10 commented Jul 3, 2009

  1. View an open issue that has no journals
  2. Change the status so the issue will be closed but don't enter a note.

Probably need to check if there are journals before calling journals.last.notes

Processing IssuesController#edit (for 127.0.0.1 at 2009-07-03 13:31:12) [POST]
  Parameters: {"time_entry"=>{"comments"=>"", "activity_id"=>"9", "hours"=>""}, "commit"=>"Submit", "action"=>"edit", "id"=>"2351", "notes"=>"", "controller"=>"issues", "issue"=>{"start_date"=>"2009-03-27", "estimated_hours"=>"", "priority_id"=>"26", "lock_version"=>"0", "subject"=>"Spanish Translation", "description"=>"here it is", "fixed_version_id"=>"", "category_id"=>"", "done_ratio"=>"0", "due_date"=>"", "assigned_to_id"=>"", "status_id"=>"5", "custom_field_values"=>{"19"=>""}}, "note"=>{"question_assigned_to"=>""}, "attachments"=>{"1"=>{"description"=>"", "file"=>""}}}


NoMethodError (undefined method `notes' for nil:NilClass):
    /vendor/plugins/redmine_require_closing_note/lib/require_closing_note_patch.rb:20:in `before_save'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:318:in `send'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:318:in `callback'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/callbacks.rb:221:in `create_or_update'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2383:in `save_without_validation'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:1009:in `save_without_dirty'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/dirty.rb:79:in `save_without_transactions'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in `send'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:179:in `with_transaction_returning_status'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:129:in `transaction'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:138:in `transaction'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:178:in `with_transaction_returning_status'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in `save'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:158:in `rollback_active_record_state!'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/transactions.rb:146:in `save'
    /app/controllers/issues_controller.rb:198:in `edit'
@bwc
Copy link

bwc commented Dec 21, 2009

I'm seeing the same bug - its line 20 in vendor/plugins/redmine_require_closing_note/lib/require_closing_note_patch.rb

if journals.last.notes.blank?

This plugin should check to see if the user is adding notes when submitting the close request too not just if the issue has a note or not.

if !defined? journals || journals.last.notes.blank?

keeps the NoMethodError from happening, but I'm not sure how to check the "notes" parameter.

@farviewsoft
Copy link

I did a little debuggin on this and journals.last.notes actually references the previous journal update. So it's really looking at whether the update previous to the current one. The one just entered has not yet been saved as a journal, so it doesn't appear in the journals model.

@farviewsoft
Copy link

Okay--

I have this working in my environment. What you want to do, is actually check against the @current_journal object, not the journals model (which only has the journals for previous updates).

Replace the line:

if journals.last.notes.blank?

With the line:

if @current_journal.notes.blank?

And you should be good.

I'd make a patch, but this really seems like a small enough change that it doesn't merrit it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant