Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Memoizing issue templates.

  • Loading branch information...
commit d55b077661c7d225711d772cee1717a81728cc09 1 parent e012272
@oruen oruen authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 app/models/issue_tracker.rb
View
14 app/models/issue_tracker.rb
@@ -28,7 +28,7 @@ def create_redmine_issue err
RedmineClient::Issue.site = account + "/projects/:project_id"
issue = RedmineClient::Issue.new(:project_id => project_id)
issue.subject = issue_title err
- issue.description = ERB.new(File.read(Rails.root + "app/views/errs/redmine_body.txt.erb").gsub(/^\s*/, '')).result(binding)
+ issue.description = self.class.redmine_body_template.result(binding)
issue.save!
err.update_attribute :issue_link, "#{RedmineClient::Issue.site.to_s.sub(/#{RedmineClient::Issue.site.path}$/, '')}#{RedmineClient::Issue.element_path(issue.id, :project_id => project_id)}".sub(/\.xml$/, '')
end
@@ -43,7 +43,7 @@ def create_lighthouseapp_issue err
ticket = Lighthouse::Ticket.new(:project_id => project_id)
ticket.title = issue_title err
- ticket.body = ERB.new(File.read(Rails.root + "app/views/errs/lighthouseapp_body.txt.erb").gsub(/^\s*/, '')).result(binding)
+ ticket.body = self.class.lighthouseapp_body_template.result(binding)
ticket.tags << "errbit"
ticket.save!
@@ -65,4 +65,14 @@ def check_params
errors.add(:base, message)
end
end
+
+ class << self
+ def lighthouseapp_body_template
+ @@lighthouseapp_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/lighthouseapp_body.txt.erb").gsub(/^\s*/, ''))
+ end
+
+ def redmine_body_template
+ @@redmine_body_template ||= ERB.new(File.read(Rails.root + "app/views/errs/redmine_body.txt.erb").gsub(/^\s*/, ''))
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.