summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-12-05 10:22:07 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-12-05 10:22:07 +0000
commitc1390bd98ccb0368f700117097f47d6ff488fdba (patch)
treec4f383b778c8a3d33bdbb82d84c8fd7a91d3fbdf /app/models
parente416d6ff1d020ec510ab71bfdbcfbc72b14cd44a (diff)
parent4ca4b0ff702a68a9aed5da70d9170da410eefafa (diff)
downloadgitlab-ce-38869-templates.tar.gz
Merge branch 'master' into 38869-templates38869-templates
* master: (50 commits) remove ambiguity about which resource type to be using for new sessions Backport changes from refactor sidebar weight block Vue and move to Issue Boards Migrate Gitlab::Git::Repository#cherry_pick to Gitaly show status of issue links in wiki page issue note component rename Prevent job link form rendering when user does not have permissions Move SingleRepositoryWorker#fsck into Gitlab::Git::Repository Import axios utils in commons Update parser gem to remove warning about wrong ruby version Merge branch 'master-i18n' into 'master' Reduce pipeline chain life span to minimize side effects Add CHANGELOG entry Refactor GCP Client#user_agent_header to use #tap Remove seed file from the development env Fixed bug Fix watch level for mentions in description Add notice to gollum initializer Add underline hover state to all links Moving query to base count service Added default order to UserFinder ...
Diffstat (limited to 'app/models')
-rw-r--r--app/models/group.rb8
-rw-r--r--app/models/project.rb9
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/user.rb12
4 files changed, 25 insertions, 6 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 76262acf50c..27287f079a4 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -289,6 +289,14 @@ class Group < Namespace
"#{parent.full_path}/#{path_was}"
end
+ def group_member(user)
+ if group_members.loaded?
+ group_members.find { |gm| gm.user_id == user.id }
+ else
+ group_members.find_by(user_id: user)
+ end
+ end
+
private
def update_two_factor_requirement
diff --git a/app/models/project.rb b/app/models/project.rb
index eaf4f555d3b..0a7e7617d9b 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -562,8 +562,7 @@ class Project < ActiveRecord::Base
if forked?
RepositoryForkWorker.perform_async(id,
forked_from_project.repository_storage_path,
- forked_from_project.full_path,
- self.namespace.full_path)
+ forked_from_project.disk_path)
else
RepositoryImportWorker.perform_async(self.id)
end
@@ -1114,7 +1113,11 @@ class Project < ActiveRecord::Base
end
def project_member(user)
- project_members.find_by(user_id: user)
+ if project_members.loaded?
+ project_members.find { |member| member.user_id == user.id }
+ else
+ project_members.find_by(user_id: user)
+ end
end
def default_branch
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 165dafd83fd..82af299ec5e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -256,7 +256,7 @@ class Repository
end
def diverging_commit_counts(branch)
- root_ref_hash = raw_repository.rev_parse_target(root_ref).oid
+ root_ref_hash = raw_repository.commit(root_ref).id
cache.fetch(:"diverging_commit_counts_#{branch.name}") do
# Rugged seems to throw a `ReferenceError` when given branch_names rather
# than SHA-1 hashes
diff --git a/app/models/user.rb b/app/models/user.rb
index 14941fd7f98..76fd395be9a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -487,7 +487,11 @@ class User < ActiveRecord::Base
end
def two_factor_u2f_enabled?
- u2f_registrations.exists?
+ if u2f_registrations.loaded?
+ u2f_registrations.any?
+ else
+ u2f_registrations.exists?
+ end
end
def namespace_uniq
@@ -998,7 +1002,11 @@ class User < ActiveRecord::Base
end
def notification_settings_for(source)
- notification_settings.find_or_initialize_by(source: source)
+ if notification_settings.loaded?
+ notification_settings.find { |notification| notification.source == source }
+ else
+ notification_settings.find_or_initialize_by(source: source)
+ end
end
# Lazy load global notification setting