Commit 242fd923457bbb06d7b8fc3810b0868e69afe02f

Authored by Arthur Neves
1 parent c4a21232
Exists in master and in 1 other branch production

Issue tracker model should not have any view/render concerns

Showing 1 changed file with 5 additions and 20 deletions   Show diff stats
app/models/issue_tracker.rb
... ... @@ -2,11 +2,6 @@ class IssueTracker
2 2 include Mongoid::Document
3 3 include Mongoid::Timestamps
4 4  
5   - include Rails.application.routes.url_helpers
6   -
7   - default_url_options[:host] = ActionMailer::Base.default_url_options[:host]
8   - default_url_options[:port] = ActionMailer::Base.default_url_options[:port]
9   -
10 5 embedded_in :app, :inverse_of => :issue_tracker
11 6  
12 7 field :type_tracker, :type => String
... ... @@ -14,22 +9,12 @@ class IssueTracker
14 9  
15 10 validate :validate_tracker
16 11  
17   - ##
18   - # Update default_url_option with valid data from the request information
19   - #
20   - # @param [ Request ] a request with host, port and protocol
21   - #
22   - def self.update_url_options(request)
23   - IssueTracker.default_url_options[:host] = request.host
24   - IssueTracker.default_url_options[:port] = request.port
25   - IssueTracker.default_url_options[:protocol] = request.scheme
26   - end
27   -
28 12 def tracker
29   - klass = ErrbitPlugin::Registry.issue_trackers[self.type_tracker]
30   - klass = ErrbitPlugin::NoneIssueTracker unless klass
31   -
32   - @tracker = klass.new(app, self.options)
  13 + @tracker ||=
  14 + begin
  15 + klass = ErrbitPlugin::Registry.issue_trackers[self.type_tracker] || ErrbitPlugin::NoneIssueTracker
  16 + klass.new(self.options)
  17 + end
33 18 end
34 19  
35 20 # Allow the tracker to validate its own params
... ...