diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-22 16:08:35 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-09-22 16:09:14 +0200 |
commit | dabbee65d44a3cdd7e78c48176d3f5def51da1b7 (patch) | |
tree | 2247f4576783e516a3d2124338db10cad04ea874 | |
parent | 0ce5fb71b609ebf74d95b4027b8eb91beafa3db4 (diff) | |
download | gitlab-ce-dabbee65d44a3cdd7e78c48176d3f5def51da1b7.tar.gz |
Fix Slack notification URL and remove the usage of Ci::RoutesHelper
-rw-r--r-- | app/helpers/ci/routes_helper.rb | 29 | ||||
-rw-r--r-- | app/models/project_services/ci/hip_chat_message.rb | 8 | ||||
-rw-r--r-- | app/models/project_services/ci/slack_message.rb | 10 | ||||
-rw-r--r-- | app/models/project_services/gitlab_ci_service.rb | 2 |
4 files changed, 12 insertions, 37 deletions
diff --git a/app/helpers/ci/routes_helper.rb b/app/helpers/ci/routes_helper.rb deleted file mode 100644 index 42cd54b064f..00000000000 --- a/app/helpers/ci/routes_helper.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Ci - module RoutesHelper - class Base - include Gitlab::Application.routes.url_helpers - - def default_url_options - { - host: Settings.gitlab['host'], - protocol: Settings.gitlab['https'] ? "https" : "http", - port: Settings.gitlab['port'] - } - end - end - - def url_helpers - @url_helpers ||= Base.new - end - - def self.method_missing(method, *args, &block) - @url_helpers ||= Base.new - - if @url_helpers.respond_to?(method) - @url_helpers.send(method, *args, &block) - else - super method, *args, &block - end - end - end -end diff --git a/app/models/project_services/ci/hip_chat_message.rb b/app/models/project_services/ci/hip_chat_message.rb index 58825fe066c..25c72033eac 100644 --- a/app/models/project_services/ci/hip_chat_message.rb +++ b/app/models/project_services/ci/hip_chat_message.rb @@ -1,5 +1,7 @@ module Ci class HipChatMessage + include Gitlab::Application.routes.url_helpers + attr_reader :build def initialize(build) @@ -8,13 +10,13 @@ module Ci def to_s lines = Array.new - lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_url(project)}\">#{project.name}</a> - ") + lines.push("<a href=\"#{ci_project_url(project)}\">#{project.name}</a> - ") if commit.matrix? - lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_ref_commits_url(project, commit.ref, commit.sha)}\">Commit ##{commit.id}</a></br>") + lines.push("<a href=\"#{ci_project_ref_commits_url(project, commit.ref, commit.sha)}\">Commit ##{commit.id}</a></br>") else first_build = commit.builds_without_retry.first - lines.push("<a href=\"#{Ci::RoutesHelper.ci_project_build_url(project, first_build)}\">Build '#{first_build.name}' ##{first_build.id}</a></br>") + lines.push("<a href=\"#{ci_project_build_url(project, first_build)}\">Build '#{first_build.name}' ##{first_build.id}</a></br>") end lines.push("#{commit.short_sha} #{commit.git_author_name} - #{commit.git_commit_message}</br>") diff --git a/app/models/project_services/ci/slack_message.rb b/app/models/project_services/ci/slack_message.rb index 491ace50111..757b1961143 100644 --- a/app/models/project_services/ci/slack_message.rb +++ b/app/models/project_services/ci/slack_message.rb @@ -2,6 +2,8 @@ require 'slack-notifier' module Ci class SlackMessage + include Gitlab::Application.routes.url_helpers + def initialize(commit) @commit = commit end @@ -27,7 +29,7 @@ module Ci next unless build.failed? fields << { title: build.name, - value: "Build <#{Ci::RoutesHelper.ci_project_build_url(project, build)}|\##{build.id}> failed in #{build.duration.to_i} second(s)." + value: "Build <#{ci_project_build_url(project, build)}|\##{build.id}> failed in #{build.duration.to_i} second(s)." } end end @@ -44,12 +46,12 @@ module Ci attr_reader :commit def attachment_message - out = "<#{Ci::RoutesHelper.ci_project_url(project)}|#{project_name}>: " + out = "<#{ci_project_url(project)}|#{project_name}>: " if commit.matrix? - out << "Commit <#{Ci::RoutesHelper.ci_project_ref_commits_url(project, commit.ref, commit.sha)}|\##{commit.id}> " + out << "Commit <#{ci_project_ref_commits_url(project, commit.ref, commit.sha)}|\##{commit.id}> " else build = commit.builds_without_retry.first - out << "Build <#{Ci::RoutesHelper.ci_project_build_path(project, build)}|\##{build.id}> " + out << "Build <#{ci_project_build_url(project, build)}|\##{build.id}> " end out << "(<#{commit_sha_link}|#{commit.short_sha}>) " out << "of <#{commit_ref_link}|#{commit.ref}> " diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb index 9e2b3bcd873..388a49e791d 100644 --- a/app/models/project_services/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -88,7 +88,7 @@ class GitlabCiService < CiService def build_page(sha, ref) if project.gitlab_ci_project.present? - Ci::RoutesHelper.ci_project_ref_commits_path(project.gitlab_ci_project, ref, sha) + ci_project_ref_commits_url(project.gitlab_ci_project, ref, sha) end end |