Commit a538dc26 authored by Marin Jankovski's avatar Marin Jankovski

Add missing end in group.rb

Fix redmine issue tracker tests, fix typos. Make sure all fields exist for jira tracker.
parent 10b37239
...@@ -95,6 +95,7 @@ class Group < Namespace ...@@ -95,6 +95,7 @@ class Group < Namespace
def ldap_synced? def ldap_synced?
ldap_cn.present? ldap_cn.present?
end
def post_create_hook def post_create_hook
system_hook_service.execute_hooks_for(self, :create) system_hook_service.execute_hooks_for(self, :create)
......
...@@ -383,6 +383,14 @@ class Project < ActiveRecord::Base ...@@ -383,6 +383,14 @@ class Project < ActiveRecord::Base
@ci_service ||= ci_services.select(&:activated?).first @ci_service ||= ci_services.select(&:activated?).first
end end
def jira_tracker?
issues_tracker.to_param == 'jira'
end
def redmine_tracker?
issues_tracker.to_param == 'redmine'
end
def avatar_type def avatar_type
unless self.avatar.image? unless self.avatar.image?
self.errors.add :avatar, 'only images allowed' self.errors.add :avatar, 'only images allowed'
......
class JiraService < IssueTrackerService class JiraService < IssueTrackerService
include HTTParty include HTTParty
prop_accessor :username, :password, :api_version, :jira_issue_transition_id prop_accessor :username, :password, :api_version, :jira_issue_transition_id,
:title, :description, :project_url, :issues_url, :new_issue_url :title, :description, :project_url, :issues_url, :new_issue_url
validates :username, :password, presence: true, if: :activated?
before_validation :set_api_version before_validation :set_api_version
def title def title
...@@ -29,12 +27,12 @@ class JiraService < IssueTrackerService ...@@ -29,12 +27,12 @@ class JiraService < IssueTrackerService
end end
def fields def fields
[ super.push(
{ type: 'text', name: 'username', placeholder: '' }, { type: 'text', name: 'username', placeholder: '' },
{ type: 'password', name: 'password', placeholder: '' }, { type: 'password', name: 'password', placeholder: '' },
{ type: 'text', name: 'api_version', placeholder: '2' }, { type: 'text', name: 'api_version', placeholder: '2' },
{ type: 'text', name: 'jira_issue_transition_id', placeholder: '2' } { type: 'text', name: 'jira_issue_transition_id', placeholder: '2' }
] )
end end
def set_api_version def set_api_version
......
...@@ -9,10 +9,6 @@ module Files ...@@ -9,10 +9,6 @@ module Files
return error("You are not allowed to create file in this branch") return error("You are not allowed to create file in this branch")
end end
unless repository.branch_names.include?(ref)
return error("You can only create files if you are on top of a branch")
end
if git_hook && !git_hook.commit_message_allowed?(params[:commit_message]) if git_hook && !git_hook.commit_message_allowed?(params[:commit_message])
return error("Commit message must match next format: #{git_hook.commit_message_regex}") return error("Commit message must match next format: #{git_hook.commit_message_regex}")
end end
......
...@@ -298,7 +298,7 @@ describe GitlabMarkdownHelper do ...@@ -298,7 +298,7 @@ describe GitlabMarkdownHelper do
before do before do
jira = @project.create_jira_service if @project.jira_service.nil? jira = @project.create_jira_service if @project.jira_service.nil?
properties = {"title"=>"JIRA tracker", "project_url"=>"http://jira.example/issues/?jql=project=A", "issues_url"=>"http://jira.example/browse/:id", "new_issue_url"=>"http://jira.example/secure/CreateIssue.jspa"} properties = {"title"=>"JIRA tracker", "project_url"=>"http://jira.example/issues/?jql=project=A", "issues_url"=>"http://jira.example/browse/JIRA-1", "new_issue_url"=>"http://jira.example/secure/CreateIssue.jspa"}
jira.update_attributes(properties: properties, active: true) jira.update_attributes(properties: properties, active: true)
end end
...@@ -346,10 +346,13 @@ describe GitlabMarkdownHelper do ...@@ -346,10 +346,13 @@ describe GitlabMarkdownHelper do
let(:reference) { "##{issue.iid}" } let(:reference) { "##{issue.iid}" }
before do before do
issue_tracker_config = { "redmine" => { "title" => "Redmine tracker", "issues_url" => "http://redmine.example/issues/:id" } } redmine = @project.create_redmine_service if @project.redmine_service.nil?
Gitlab.config.stub(:issues_tracker).and_return(issue_tracker_config) properties = {"title"=>"Redmine", "project_url"=>"http://redmine.example/projects/A", "issues_url"=>"http://redmine.example/issues/:id", "new_issue_url"=>"http://redmine.example/projects/A/issues/new"}
@project.stub(:issues_tracker).and_return("redmine") redmine.update_attributes(properties: properties, active: true)
@project.stub(:issues_tracker_id).and_return("REDMINE") end
after do
@project.redmine_service.destroy! unless @project.redmine_service.nil?
end end
it "should link using a valid id" do it "should link using a valid id" do
...@@ -377,7 +380,7 @@ describe GitlabMarkdownHelper do ...@@ -377,7 +380,7 @@ describe GitlabMarkdownHelper do
end end
it "should include a title attribute" do it "should include a title attribute" do
title = "Issue in Redmine tracker" title = "Issue in Redmine"
gfm(actual).should match(/title="#{title}"/) gfm(actual).should match(/title="#{title}"/)
end end
......
...@@ -41,6 +41,8 @@ describe JiraService do ...@@ -41,6 +41,8 @@ describe JiraService do
WebMock.should have_requested(:post, @api_url).with( WebMock.should have_requested(:post, @api_url).with(
body: /this-is-a-custom-id/ body: /this-is-a-custom-id/
).once ).once
end
end
describe "Validations" do describe "Validations" do
context "active" do context "active" do
......
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