Commit b07dc938 authored by James Lopez's avatar James Lopez

fixed specs and refactored a few things due to recent model changes and merge conflicts

parent ad68bc63
class CommitStatus < ActiveRecord::Base class CommitStatus < ActiveRecord::Base
include Statuseable include Statuseable
include Importable
self.table_name = 'ci_builds' self.table_name = 'ci_builds'
...@@ -7,7 +8,7 @@ class CommitStatus < ActiveRecord::Base ...@@ -7,7 +8,7 @@ class CommitStatus < ActiveRecord::Base
belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :commit_id, touch: true belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :commit_id, touch: true
belongs_to :user belongs_to :user
validates :pipeline, presence: true validates :pipeline, presence: true, unless: :importing?
validates_presence_of :name validates_presence_of :name
......
...@@ -4,6 +4,7 @@ class Note < ActiveRecord::Base ...@@ -4,6 +4,7 @@ class Note < ActiveRecord::Base
include Participable include Participable
include Mentionable include Mentionable
include Awardable include Awardable
include Importable
default_value_for :system, false default_value_for :system, false
...@@ -28,11 +29,11 @@ class Note < ActiveRecord::Base ...@@ -28,11 +29,11 @@ class Note < ActiveRecord::Base
validates :attachment, file_size: { maximum: :max_attachment_size } validates :attachment, file_size: { maximum: :max_attachment_size }
validates :noteable_type, presence: true validates :noteable_type, presence: true
validates :noteable_id, presence: true, unless: :for_commit? validates :noteable_id, presence: true, unless: [:for_commit?, :importing?]
validates :commit_id, presence: true, if: :for_commit? validates :commit_id, presence: true, if: :for_commit?
validates :author, presence: true validates :author, presence: true
validate unless: :for_commit? do |note| validate unless: [:for_commit?, :importing?] do |note|
unless note.noteable.try(:project) == note.project unless note.noteable.try(:project) == note.project
errors.add(:invalid_project, 'Note and noteable project mismatch') errors.add(:invalid_project, 'Note and noteable project mismatch')
end end
......
...@@ -3,7 +3,7 @@ module Gitlab ...@@ -3,7 +3,7 @@ module Gitlab
class RelationFactory class RelationFactory
OVERRIDES = { snippets: :project_snippets, OVERRIDES = { snippets: :project_snippets,
ci_commits: 'Ci::Commit', pipelines: 'Ci::Pipeline',
statuses: 'commit_status', statuses: 'commit_status',
variables: 'Ci::Variable', variables: 'Ci::Variable',
triggers: 'Ci::Trigger', triggers: 'Ci::Trigger',
...@@ -18,7 +18,7 @@ module Gitlab ...@@ -18,7 +18,7 @@ module Gitlab
def initialize(relation_sym:, relation_hash:, members_mapper:, user_admin:) def initialize(relation_sym:, relation_hash:, members_mapper:, user_admin:)
@relation_name = OVERRIDES[relation_sym] || relation_sym @relation_name = OVERRIDES[relation_sym] || relation_sym
@relation_hash = relation_hash.except('id') @relation_hash = relation_hash.except('id', 'noteable_id')
@members_mapper = members_mapper @members_mapper = members_mapper
@user_admin = user_admin @user_admin = user_admin
end end
......
module Gitlab module Gitlab
module ImportExport module ImportExport
class UploadsRestorer < UploadsSaver class UploadsRestorer < UploadsSaver
def restore
class << self
alias_method :restore, :save
end
def save
return true unless File.directory?(uploads_export_path) return true unless File.directory?(uploads_export_path)
copy_files(uploads_export_path, uploads_path) copy_files(uploads_export_path, uploads_path)
......
This diff is collapsed.
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