Commit 68237290 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create maven package in one transaction

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ffea496b
......@@ -2,7 +2,9 @@
class Packages::Package < ActiveRecord::Base
belongs_to :project
has_many :package_files
has_one :maven_metadatum
has_one :maven_metadatum, inverse_of: :package
accepts_nested_attributes_for :maven_metadatum
validates :project, presence: true
validates :name, presence: true
......
......@@ -2,22 +2,19 @@
module Packages
class CreateMavenPackageService < BaseService
def execute
package = project.packages.create!(
name: params[:name],
version: params[:version]
)
app_group, _, app_name = params[:name].rpartition('/')
app_group.tr!('/', '.')
package.create_maven_metadatum!(
path: params[:path],
app_group: app_group,
app_name: app_name,
app_version: params[:version]
project.packages.create!(
name: params[:name],
version: params[:version],
maven_metadatum_attributes: {
path: params[:path],
app_group: app_group,
app_name: app_name,
app_version: params[:version]
}
)
package
end
end
end
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