#472: Update Api::V1::RepositoriesController

This commit is contained in:
Vokhmin Alexey V 2015-05-20 22:54:38 +03:00
parent 347c97703a
commit 83981996cd
5 changed files with 22 additions and 9 deletions

View File

@ -97,7 +97,7 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
def signatures
key_pair = @repository.key_pair
key_pair.destroy if key_pair
key_pair = @repository.build_key_pair(params[:repository])
key_pair = @repository.build_key_pair subject_params(Repository, KeyPair)
key_pair.user_id = current_user.id
if key_pair.save
render_json_response @repository, 'Signatures have been updated for repository successfully'

View File

@ -4,7 +4,6 @@ class KeyPair < ActiveRecord::Base
belongs_to :user
attr_accessor :fingerprint
# attr_accessible :public, :secret, :repository_id
attr_encrypted :secret, key: APP_CONFIG['keys']['key_pair_secret_key']
validates :repository, :user, presence: true

View File

@ -36,13 +36,6 @@ class Repository < ActiveRecord::Base
before_destroy :detele_directory
# attr_accessible :name,
# :description,
# :publish_without_qa,
# :synchronizing_publications,
# :publish_builds_only_from_branch,
# :build_for_platform_id
attr_readonly :name, :platform_id
attr_accessor :projects_list, :build_for_platform_id

View File

@ -6,4 +6,11 @@ class KeyPairPolicy < ApplicationPolicy
end
alias_method :destroy?, :create?
# Public: Get list of parameters that the user is allowed to alter.
#
# Returns Array
def permitted_attributes
%i(public secret)
end
end

View File

@ -54,6 +54,20 @@ class RepositoryPolicy < ApplicationPolicy
end
alias_method :remove_repo_lock_file?, :add_repo_lock_file?
# Public: Get list of parameters that the user is allowed to alter.
#
# Returns Array
def permitted_attributes
%i(
name
description
publish_without_qa
synchronizing_publications
publish_builds_only_from_branch
build_for_platform_id
)
end
private
# Public: Get user ids of repository.