Commit c643b50dbd726b6a3396ea459d14378e1c52b48b

Authored by Andrew8xx8
1 parent 9b606ede

Default value for issues_tracker setting added

app/models/project.rb
@@ -96,7 +96,7 @@ class Project < ActiveRecord::Base @@ -96,7 +96,7 @@ class Project < ActiveRecord::Base
96 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } 96 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
97 scope :public_only, -> { where(public: true) } 97 scope :public_only, -> { where(public: true) }
98 98
99 - enumerize :issues_tracker, :in => (Settings[:issues_tracker].keys).append(:gitlab), :default => :gitlab 99 + enumerize :issues_tracker, :in => (Gitlab.config.issues_tracker.keys).append(:gitlab), :default => :gitlab
100 100
101 class << self 101 class << self
102 def abandoned 102 def abandoned
config/gitlab.yml.example
@@ -143,7 +143,10 @@ development: @@ -143,7 +143,10 @@ development:
143 <<: *defaults 143 <<: *defaults
144 144
145 test: 145 test:
146 - <<: *base 146 + <<: *defaults
  147 + issues_tracker:
  148 + redmine:
  149 + issues_url: "http://redmine/:project_id/:issues_tracker_id/:id"
147 150
148 staging: 151 staging:
149 <<: *defaults 152 <<: *defaults
config/initializers/1_settings.rb
@@ -42,6 +42,8 @@ Settings[&#39;omniauth&#39;] ||= Settingslogic.new({}) @@ -42,6 +42,8 @@ Settings[&#39;omniauth&#39;] ||= Settingslogic.new({})
42 Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil? 42 Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
43 Settings.omniauth['providers'] ||= [] 43 Settings.omniauth['providers'] ||= []
44 44
  45 +Settings['issues_tracker'] ||= {}
  46 +
45 # 47 #
46 # GitLab 48 # GitLab
47 # 49 #
spec/helpers/issues_helper_spec.rb
@@ -25,7 +25,7 @@ describe IssuesHelper do @@ -25,7 +25,7 @@ describe IssuesHelper do
25 25
26 describe :url_for_issue do 26 describe :url_for_issue do
27 let(:issue_id) { 3 } 27 let(:issue_id) { 3 }
28 - let(:issues_url) { "http://redmine/:project_id/:issues_tracker_id/:id" } 28 + let(:issues_url) { Gitlab.config.issues_tracker.redmine.issues_url}
29 let(:ext_expected) do 29 let(:ext_expected) do
30 issues_url.gsub(':id', issue_id.to_s) 30 issues_url.gsub(':id', issue_id.to_s)
31 .gsub(':project_id', ext_project.id.to_s) 31 .gsub(':project_id', ext_project.id.to_s)
@@ -40,7 +40,6 @@ describe IssuesHelper do @@ -40,7 +40,6 @@ describe IssuesHelper do
40 40
41 it "should return path to external tracker" do 41 it "should return path to external tracker" do
42 @project = ext_project 42 @project = ext_project
43 - Settings[:issues_tracker][ext_project.issues_tracker]["issues_url"] = issues_url  
44 43
45 url_for_issue(issue_id).should match(ext_expected) 44 url_for_issue(issue_id).should match(ext_expected)
46 end 45 end