BigW Consortium Gitlab

Commit e6d2e569 by Andrew8xx8

Issue tracker field added to projects

parent 8f621c9e
......@@ -40,4 +40,31 @@ module IssuesHelper
def issues_active_milestones
@project.milestones.active.order("id desc").all
end
def url_for_issue(issue_id)
if @project.issues_tracker == Project.issues_tracker.default_value
url = project_issue_url project_id: @project, id: issue_id
else
url = Settings[:issues_tracker][@project.issues_tracker]["issues_url"]
url.gsub(':id', issue_id.to_s).gsub(':project_id', @project.id.to_s)
end
end
def title_for_issue(issue_id)
if issue = @project.issues.where(id: issue_id).first
issue.title
else
""
end
end
def issue_exists?(issue_id)
return false if @project.nil?
if @project.issues_tracker == Project.issues_tracker.default_value
@project.issues.where(id: issue_id).first.present?
else
true
end
end
end
......@@ -11,6 +11,7 @@
# creator_id :integer
# default_branch :string(255)
# issues_enabled :boolean default(TRUE), not null
# issues_tracker :string not null
# wall_enabled :boolean default(TRUE), not null
# merge_requests_enabled :boolean default(TRUE), not null
# wiki_enabled :boolean default(TRUE), not null
......@@ -22,10 +23,11 @@ require "grit"
class Project < ActiveRecord::Base
include Gitolited
extend Enumerize
class TransferError < StandardError; end
attr_accessible :name, :path, :description, :default_branch,
attr_accessible :name, :path, :description, :default_branch, :issues_tracker,
:issues_enabled, :wall_enabled, :merge_requests_enabled,
:wiki_enabled, :public, :import_url, as: [:default, :admin]
......@@ -93,6 +95,8 @@ class Project < ActiveRecord::Base
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public_only, -> { where(public: true) }
enumerize :issues_tracker, :in => (Settings[:issues_tracker].keys).append(:gitlab), :default => :gitlab
class << self
def abandoned
project_ids = Event.select('max(created_at) as latest_date, project_id').
......
......@@ -25,6 +25,10 @@
%span.descr Lightweight issue tracking system for this project
.control-group
= f.label :issues_tracker, "Issues tracker", class: 'control-label'
.input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled })
.control-group
= f.label :merge_requests_enabled, "Merge Requests", class: 'control-label'
.controls
= f.check_box :merge_requests_enabled
......
......@@ -7,6 +7,7 @@
# 2. Replace gitlab -> host with your domain
# 3. Replace gitlab -> email_from
<<<<<<< HEAD
production: &base
#
# 1. GitLab app settings
......@@ -37,6 +38,11 @@ production: &base
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
# username_changing_enabled: false # default: true - User can change her username/namespace
## Available issues trackers
issues_tracker:
redmine:
issues_url: "http://redmine.sample/issues/:id"
## Gravatar
gravatar:
enabled: true # Use user avatar images from Gravatar.com (default: true)
......
class AddIssuesTrackerToProject < ActiveRecord::Migration
def change
add_column :projects, :issues_tracker, :string, default: :gitlab, null: false
end
end
......@@ -163,8 +163,11 @@ module Gitlab
end
def reference_issue(identifier)
if issue = @project.issues.where(id: identifier).first
link_to("##{identifier}", project_issue_url(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}"))
if issue_exists? identifier
url = url_for_issue(identifier)
title = title_for_issue(identifier)
link_to("##{identifier}", url, html_options.merge(title: "Issue: #{title}", class: "gfm gfm-issue #{html_options[:class]}"))
end
end
......
......@@ -2,6 +2,7 @@ require "spec_helper"
describe GitlabMarkdownHelper do
include ApplicationHelper
include IssuesHelper
let!(:project) { create(:project) }
......
require 'spec_helper'
describe IssuesTracker do
let(:project) { double('project') }
before do
@project = project
project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']))
project.stub(path_with_namespace: 'gitlab/gitlab-ci')
end
it 'returns url for issue' do
ololo
end
end
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