Skip to content

Commit

Permalink
Merge pull request #1531 from xmera-circle/bug/fixing-no-method-error…
Browse files Browse the repository at this point in the history
…-in-dmsf-file-revision-format

Fixing NoMethodError in DmsfFileRevisionFormat
  • Loading branch information
picman authored Jul 4, 2024
2 parents 402aadc + 8bcc5a5 commit c29e363
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DmsfFileRevisionFormat < Redmine::FieldFormat::Unbounded

def edit_tag(view, tag_id, tag_name, custom_value, options = {})
member = Member.find_by(user_id: User.current.id, project_id: custom_value.customized.project.id)
if member.dmsf_fast_links?
if member&.dmsf_fast_links?
view.text_field_tag(tag_name, custom_value.value, options.merge(id: tag_id))
else
select_edit_tag(view, tag_id, tag_name, custom_value, options)
Expand Down
16 changes: 16 additions & 0 deletions test/unit/custom_field_dmsf_file_format_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,20 @@ def test_possible_values_options
end
assert_equal n, @field.possible_values_options(@issue).size
end

def test_edit_tag_when_member_not_found
User.current = User.generate!
view = ActionView::Base.new(ActionController::Base.view_paths, {}, ActionController::Base.new)
view.extend(ApplicationHelper)

begin
@field.format.edit_tag(view,
"issue_custom_field_values_#{@field.id}",
"issue[custom_field_values][#{@field.id}]",
CustomValue.create!(custom_field: @field, customized: @issue))
assert true
rescue NoMethodError => e
flunk "Test failure: #{e.message}"
end
end
end

0 comments on commit c29e363

Please sign in to comment.