summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-17 12:44:02 -0700
committerStan Hu <stanhu@gmail.com>2018-07-17 12:44:02 -0700
commit282904592f1e0e4f98ddeb1a829a1b900cf63451 (patch)
tree3a48182d7b9ba8b3c1d59c8c0e06e429d329bc15 /app/models
parent11dd390c116f163a2e8a46af83e0d1bb194fb1f7 (diff)
parent2f16eab03d8af372ae8461de5abf91b480ffd761 (diff)
downloadgitlab-ce-282904592f1e0e4f98ddeb1a829a1b900cf63451.tar.gz
Merge branch 'master' into sh-support-bitbucket-server-import
Diffstat (limited to 'app/models')
-rw-r--r--app/models/deployment.rb4
-rw-r--r--app/models/environment.rb2
-rw-r--r--app/models/note.rb2
-rw-r--r--app/models/project.rb11
-rw-r--r--app/models/project_wiki.rb7
-rw-r--r--app/models/wiki_page.rb2
6 files changed, 17 insertions, 11 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index ac86e9e8de0..687246b47b2 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -92,10 +92,6 @@ class Deployment < ActiveRecord::Base
@stop_action ||= manual_actions.find_by(name: on_stop)
end
- def stop_action?
- stop_action.present?
- end
-
def formatted_deployment_time
created_at.to_time.in_time_zone.to_s(:medium)
end
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 8d523dae324..4856d313318 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -117,7 +117,7 @@ class Environment < ActiveRecord::Base
external_url.gsub(%r{\A.*?://}, '')
end
- def stop_action?
+ def stop_action_available?
available? && stop_action.present?
end
diff --git a/app/models/note.rb b/app/models/note.rb
index abc40d9016e..fe3507adcb3 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -202,7 +202,7 @@ class Note < ActiveRecord::Base
end
def hook_attrs
- attributes
+ Gitlab::HookData::NoteBuilder.new(self).build
end
def for_commit?
diff --git a/app/models/project.rb b/app/models/project.rb
index 4606cdc70a8..5f582dfa5ee 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2173,10 +2173,13 @@ class Project < ActiveRecord::Base
merge_requests = source_of_merge_requests.opened
.where(allow_collaboration: true)
- if branch_name
- merge_requests.find_by(source_branch: branch_name)&.can_be_merged_by?(user)
- else
- merge_requests.any? { |merge_request| merge_request.can_be_merged_by?(user) }
+ # Issue for N+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/49322
+ Gitlab::GitalyClient.allow_n_plus_1_calls do
+ if branch_name
+ merge_requests.find_by(source_branch: branch_name)&.can_be_merged_by?(user)
+ else
+ merge_requests.any? { |merge_request| merge_request.can_be_merged_by?(user) }
+ end
end
end
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 9ae2fb0013a..3aa56b3983f 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
class ProjectWiki
include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki
@@ -9,6 +11,7 @@ class ProjectWiki
}.freeze unless defined?(MARKUPS)
CouldNotCreateWikiError = Class.new(StandardError)
+ SIDEBAR = '_sidebar'
# Returns a string describing what went wrong after
# an operation fails.
@@ -98,6 +101,10 @@ class ProjectWiki
end
end
+ def find_sidebar(version = nil)
+ find_page(SIDEBAR, version)
+ end
+
def find_file(name, version = nil)
wiki.file(name, version)
end
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 4b49edb01a5..55243136140 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -60,7 +60,7 @@ class WikiPage
attr_accessor :attributes
def hook_attrs
- attributes
+ Gitlab::HookData::WikiPageBuilder.new(self).build
end
def initialize(wiki, page = nil, persisted = false)