Remove deprecated issues_tracker and issues_tracker_id from project

parent 4a8ae77e
...@@ -146,7 +146,6 @@ class Project < ActiveRecord::Base ...@@ -146,7 +146,6 @@ class Project < ActiveRecord::Base
message: Gitlab::Regex.project_path_regex_message } message: Gitlab::Regex.project_path_regex_message }
validates :issues_enabled, :merge_requests_enabled, validates :issues_enabled, :merge_requests_enabled,
:wiki_enabled, inclusion: { in: [true, false] } :wiki_enabled, inclusion: { in: [true, false] }
validates :issues_tracker_id, length: { maximum: 255 }, allow_blank: true
validates :namespace, presence: true validates :namespace, presence: true
validates_uniqueness_of :name, scope: :namespace_id validates_uniqueness_of :name, scope: :namespace_id
validates_uniqueness_of :path, scope: :namespace_id validates_uniqueness_of :path, scope: :namespace_id
...@@ -589,10 +588,6 @@ class Project < ActiveRecord::Base ...@@ -589,10 +588,6 @@ class Project < ActiveRecord::Base
update_column(:has_external_issue_tracker, services.external_issue_trackers.any?) update_column(:has_external_issue_tracker, services.external_issue_trackers.any?)
end end
def can_have_issues_tracker_id?
self.issues_enabled && !self.default_issues_tracker?
end
def build_missing_services def build_missing_services
services_templates = Service.where(template: true) services_templates = Service.where(template: true)
......
...@@ -38,9 +38,9 @@ class IssueTrackerService < Service ...@@ -38,9 +38,9 @@ class IssueTrackerService < Service
if enabled_in_gitlab_config if enabled_in_gitlab_config
self.properties = { self.properties = {
title: issues_tracker['title'], title: issues_tracker['title'],
project_url: add_issues_tracker_id(issues_tracker['project_url']), project_url: issues_tracker['project_url'],
issues_url: add_issues_tracker_id(issues_tracker['issues_url']), issues_url: issues_tracker['issues_url'],
new_issue_url: add_issues_tracker_id(issues_tracker['new_issue_url']) new_issue_url: issues_tracker['new_issue_url']
} }
else else
self.properties = {} self.properties = {}
...@@ -83,16 +83,4 @@ class IssueTrackerService < Service ...@@ -83,16 +83,4 @@ class IssueTrackerService < Service
def issues_tracker def issues_tracker
Gitlab.config.issues_tracker[to_param] Gitlab.config.issues_tracker[to_param]
end end
def add_issues_tracker_id(url)
if self.project
id = self.project.issues_tracker_id
if id
url = url.gsub(":issues_tracker_id", id)
end
end
url
end
end end
class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration
def change
remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false
remove_column :projects, :issues_tracker_id, :string
end
end
...@@ -751,8 +751,6 @@ ActiveRecord::Schema.define(version: 20160610301627) do ...@@ -751,8 +751,6 @@ ActiveRecord::Schema.define(version: 20160610301627) do
t.boolean "merge_requests_enabled", default: true, null: false t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", default: true, null: false t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id" t.integer "namespace_id"
t.string "issues_tracker", default: "gitlab", null: false
t.string "issues_tracker_id"
t.boolean "snippets_enabled", default: true, null: false t.boolean "snippets_enabled", default: true, null: false
t.datetime "last_activity_at" t.datetime "last_activity_at"
t.string "import_url" t.string "import_url"
......
...@@ -67,9 +67,6 @@ FactoryGirl.define do ...@@ -67,9 +67,6 @@ FactoryGirl.define do
'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new' 'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new'
} }
) )
project.issues_tracker = 'redmine'
project.issues_tracker_id = 'project_name_in_redmine'
end end
end end
...@@ -84,9 +81,6 @@ FactoryGirl.define do ...@@ -84,9 +81,6 @@ FactoryGirl.define do
'new_issue_url' => 'http://jira.example/secure/CreateIssue.jspa' 'new_issue_url' => 'http://jira.example/secure/CreateIssue.jspa'
} }
) )
project.issues_tracker = 'jira'
project.issues_tracker_id = 'project_name_in_jira'
end end
end end
end end
...@@ -7,10 +7,7 @@ describe IssuesHelper do ...@@ -7,10 +7,7 @@ describe IssuesHelper do
describe "url_for_project_issues" do describe "url_for_project_issues" do
let(:project_url) { ext_project.external_issue_tracker.project_url } let(:project_url) { ext_project.external_issue_tracker.project_url }
let(:ext_expected) do let(:ext_expected) { project_url.gsub(':project_id', ext_project.id.to_s) }
project_url.gsub(':project_id', ext_project.id.to_s)
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
end
let(:int_expected) { polymorphic_path([@project.namespace, project]) } let(:int_expected) { polymorphic_path([@project.namespace, project]) }
it "should return internal path if used internal tracker" do it "should return internal path if used internal tracker" do
...@@ -56,11 +53,7 @@ describe IssuesHelper do ...@@ -56,11 +53,7 @@ describe IssuesHelper do
describe "url_for_issue" do describe "url_for_issue" do
let(:issues_url) { ext_project.external_issue_tracker.issues_url} let(:issues_url) { ext_project.external_issue_tracker.issues_url}
let(:ext_expected) do let(:ext_expected) { issues_url.gsub(':id', issue.iid.to_s).gsub(':project_id', ext_project.id.to_s) }
issues_url.gsub(':id', issue.iid.to_s)
.gsub(':project_id', ext_project.id.to_s)
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
end
let(:int_expected) { polymorphic_path([@project.namespace, project, issue]) } let(:int_expected) { polymorphic_path([@project.namespace, project, issue]) }
it "should return internal path if used internal tracker" do it "should return internal path if used internal tracker" do
...@@ -106,10 +99,7 @@ describe IssuesHelper do ...@@ -106,10 +99,7 @@ describe IssuesHelper do
describe 'url_for_new_issue' do describe 'url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url } let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do let(:ext_expected) { issues_url.gsub(':project_id', ext_project.id.to_s) }
issues_url.gsub(':project_id', ext_project.id.to_s)
.gsub(':issues_tracker_id', ext_project.issues_tracker_id.to_s)
end
let(:int_expected) { new_namespace_project_issue_path(project.namespace, project) } let(:int_expected) { new_namespace_project_issue_path(project.namespace, project) }
it "should return internal path if used internal tracker" do it "should return internal path if used internal tracker" do
......
...@@ -53,7 +53,6 @@ describe Project, models: true do ...@@ -53,7 +53,6 @@ describe Project, models: true do
it { is_expected.to validate_length_of(:path).is_within(0..255) } it { is_expected.to validate_length_of(:path).is_within(0..255) }
it { is_expected.to validate_length_of(:description).is_within(0..2000) } it { is_expected.to validate_length_of(:description).is_within(0..2000) }
it { is_expected.to validate_presence_of(:creator) } it { is_expected.to validate_presence_of(:creator) }
it { is_expected.to validate_length_of(:issues_tracker_id).is_within(0..255) }
it { is_expected.to validate_presence_of(:namespace) } it { is_expected.to validate_presence_of(:namespace) }
it 'should not allow new projects beyond user limits' do it 'should not allow new projects beyond user limits' do
...@@ -321,27 +320,6 @@ describe Project, models: true do ...@@ -321,27 +320,6 @@ describe Project, models: true do
end end
end end
describe :can_have_issues_tracker_id? do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
it 'should be true for projects with external issues tracker if issues enabled' do
expect(ext_project.can_have_issues_tracker_id?).to be_truthy
end
it 'should be false for projects with internal issue tracker if issues enabled' do
expect(project.can_have_issues_tracker_id?).to be_falsey
end
it 'should be always false if issues disabled' do
project.issues_enabled = false
ext_project.issues_enabled = false
expect(project.can_have_issues_tracker_id?).to be_falsey
expect(ext_project.can_have_issues_tracker_id?).to be_falsey
end
end
describe :open_branches do describe :open_branches do
let(:project) { create(:project) } let(:project) { create(:project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment