summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-29 11:49:14 -0700
committerDouwe Maan <douwe@gitlab.com>2015-08-29 11:49:14 -0700
commitfe86c8dfbd81ef21d0d685105397f4bf6048b2f2 (patch)
tree106ff615898f09076cada653a8dfb5710ce593db /app/models
parentd92f428024b2878682bb23b6b03bc671636b5afe (diff)
parenta429eb4d455cabde26c5cdf8a3b38e65966531dc (diff)
downloadgitlab-ce-fe86c8dfbd81ef21d0d685105397f4bf6048b2f2.tar.gz
Merge branch 'master' into joelkoglin/gitlab-ce-feature_fix_ldap_auth_issue_993
Diffstat (limited to 'app/models')
-rw-r--r--app/models/group.rb1
-rw-r--r--app/models/hooks/web_hook.rb5
-rw-r--r--app/models/milestone.rb9
-rw-r--r--app/models/project_services/buildkite_service.rb9
-rw-r--r--app/models/project_services/gitlab_ci_service.rb6
-rw-r--r--app/models/sent_notification.rb50
-rw-r--r--app/models/user.rb4
7 files changed, 73 insertions, 11 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 4ff610f8e9d..9cd146bb73b 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -17,6 +17,7 @@ require 'carrierwave/orm/activerecord'
require 'file_size_validator'
class Group < Namespace
+ include Gitlab::ConfigHelper
include Referable
has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember'
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 46fb85336e5..9a8251bdad5 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -25,6 +25,7 @@ class WebHook < ActiveRecord::Base
default_value_for :note_events, false
default_value_for :merge_requests_events, false
default_value_for :tag_push_events, false
+ default_value_for :enable_ssl_verification, false
# HTTParty timeout
default_timeout Gitlab.config.gitlab.webhook_timeout
@@ -41,7 +42,7 @@ class WebHook < ActiveRecord::Base
"Content-Type" => "application/json",
"X-Gitlab-Event" => hook_name.singularize.titleize
},
- verify: false)
+ verify: enable_ssl_verification)
else
post_url = url.gsub("#{parsed_url.userinfo}@", "")
auth = {
@@ -54,7 +55,7 @@ class WebHook < ActiveRecord::Base
"Content-Type" => "application/json",
"X-Gitlab-Event" => hook_name.singularize.titleize
},
- verify: false,
+ verify: enable_ssl_verification,
basic_auth: auth)
end
rescue SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout => e
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index d28f3c8d3f9..c6aff6f709f 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -47,6 +47,13 @@ class Milestone < ActiveRecord::Base
state :active
end
+ class << self
+ def search(query)
+ query = "%#{query}%"
+ where("title like ? or description like ?", query, query)
+ end
+ end
+
def expired?
if due_date
due_date.past?
@@ -54,7 +61,7 @@ class Milestone < ActiveRecord::Base
false
end
end
-
+
def open_items_count
self.issues.opened.count + self.merge_requests.opened.count
end
diff --git a/app/models/project_services/buildkite_service.rb b/app/models/project_services/buildkite_service.rb
index a714bc82246..9e5da6f45d2 100644
--- a/app/models/project_services/buildkite_service.rb
+++ b/app/models/project_services/buildkite_service.rb
@@ -23,7 +23,7 @@ require "addressable/uri"
class BuildkiteService < CiService
ENDPOINT = "https://buildkite.com"
- prop_accessor :project_url, :token
+ prop_accessor :project_url, :token, :enable_ssl_verification
validates :project_url, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
@@ -37,6 +37,7 @@ class BuildkiteService < CiService
def compose_service_hook
hook = service_hook || build_service_hook
hook.url = webhook_url
+ hook.enable_ssl_verification = enable_ssl_verification
hook.save
end
@@ -96,7 +97,11 @@ class BuildkiteService < CiService
{ type: 'text',
name: 'project_url',
- placeholder: "#{ENDPOINT}/example/project" }
+ placeholder: "#{ENDPOINT}/example/project" },
+
+ { type: 'checkbox',
+ name: 'enable_ssl_verification',
+ title: "Enable SSL verification" }
]
end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index ecdcd48ae60..acbbc9935b6 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -21,7 +21,7 @@
class GitlabCiService < CiService
API_PREFIX = "api/v1"
- prop_accessor :project_url, :token
+ prop_accessor :project_url, :token, :enable_ssl_verification
validates :project_url,
presence: true,
format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" }, if: :activated?
@@ -34,6 +34,7 @@ class GitlabCiService < CiService
def compose_service_hook
hook = service_hook || build_service_hook
hook.url = [project_url, "/build", "?token=#{token}"].join("")
+ hook.enable_ssl_verification = enable_ssl_verification
hook.save
end
@@ -136,7 +137,8 @@ class GitlabCiService < CiService
def fields
[
{ type: 'text', name: 'token', placeholder: 'GitLab CI project specific token' },
- { type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3' }
+ { type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3' },
+ { type: 'checkbox', name: 'enable_ssl_verification', title: "Enable SSL verification" }
]
end
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
new file mode 100644
index 00000000000..460ca40be3f
--- /dev/null
+++ b/app/models/sent_notification.rb
@@ -0,0 +1,50 @@
+class SentNotification < ActiveRecord::Base
+ belongs_to :project
+ belongs_to :noteable, polymorphic: true
+ belongs_to :recipient, class_name: "User"
+
+ validate :project, :recipient, :reply_key, presence: true
+ validate :reply_key, uniqueness: true
+
+ validates :noteable_id, presence: true, unless: :for_commit?
+ validates :commit_id, presence: true, if: :for_commit?
+
+ class << self
+ def for(reply_key)
+ find_by(reply_key: reply_key)
+ end
+
+ def record(noteable, recipient_id, reply_key)
+ return unless reply_key
+
+ noteable_id = nil
+ commit_id = nil
+ if noteable.is_a?(Commit)
+ commit_id = noteable.id
+ else
+ noteable_id = noteable.id
+ end
+
+ create(
+ project: noteable.project,
+ noteable_type: noteable.class.name,
+ noteable_id: noteable_id,
+ commit_id: commit_id,
+ recipient_id: recipient_id,
+ reply_key: reply_key
+ )
+ end
+ end
+
+ def for_commit?
+ noteable_type == "Commit"
+ end
+
+ def noteable
+ if for_commit?
+ project.commit(commit_id) rescue nil
+ else
+ super
+ end
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 1f0735a7e7b..48e0e6ed48b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -637,10 +637,6 @@ class User < ActiveRecord::Base
email.start_with?('temp-email-for-oauth')
end
- def public_profile?
- authorized_projects.public_only.any?
- end
-
def avatar_url(size = nil)
if avatar.present?
[gitlab_config.url, avatar.url].join