[#343] use new ruby hash syntax

This commit is contained in:
Alexander Machehin 2014-01-21 10:51:49 +06:00
parent 5954583959
commit 0e39aae1bf
691 changed files with 4611 additions and 4669 deletions

36
Gemfile
View File

@ -1,7 +1,7 @@
source 'https://rubygems.org'
gem 'rails', '3.2.16' #, :git => 'git://github.com/rails/rails.git'
gem 'redhillonrails_core', :git => 'git://github.com/rosa-abf/redhillonrails_core.git', :branch => 'rails31' # '~> 2.0.0.pre' # deprecated
gem 'rails', '3.2.16' #, git: 'git://github.com/rails/rails.git'
gem 'redhillonrails_core', git: 'git://github.com/rosa-abf/redhillonrails_core.git', branch: 'rails31' # '~> 2.0.0.pre' # deprecated
gem 'pg', '~> 0.14.0'
@ -24,10 +24,10 @@ gem 'highline', '~> 1.6.11'
gem 'state_machine'
gem 'redis-rails'
gem 'grack', :git => 'git://github.com/rosa-abf/grack.git', :require => 'git_http'
gem 'grit', :git => 'git://github.com/rosa-abf/grit.git'
gem 'grack', git: 'git://github.com/rosa-abf/grack.git', require: 'git_http'
gem 'grit', git: 'git://github.com/rosa-abf/grit.git'
gem 'charlock_holmes', '~> 0.6.9'
gem 'github-linguist', '~> 2.3.4', :require => 'linguist'
gem 'github-linguist', '~> 2.3.4', require: 'linguist'
gem 'diff-display', '~> 0.0.1'
# Wiki
@ -39,17 +39,17 @@ gem 'rdiscount'
gem 'RedCloth'
gem 'wikicloth'
# gem 'unicorn', '~> 4.3.1', :platforms => [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', :platforms => :jruby
# gem 'unicorn', '~> 4.3.1', platforms: [:mri, :rbx]
gem 'trinidad', '~> 1.0.2', platforms: :jruby
gem 'newrelic_rpm'
# gem 'whenever', '~> 0.7.3', :require => false
gem 'whenever', '~> 0.9.0', :require => false
# gem 'whenever', '~> 0.7.3', require: false
gem 'whenever', '~> 0.9.0', require: false
gem 'jbuilder', '~> 1.4.2'
gem 'rails3-jquery-autocomplete', '~> 1.0.7'
gem 'will_paginate', '~> 3.0.3'
gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags'
gem 'meta-tags', '~> 1.2.5', require: 'meta_tags'
gem "haml-rails", '~> 0.3.4'
gem 'jquery-rails', '~> 2.0.2'
gem 'ruby-haml-js', '~> 0.0.3'
@ -81,14 +81,14 @@ group :assets do
gem 'coffee-rails', '~> 3.2.2'
gem 'compass-rails', '~> 1.0.3'
gem 'uglifier', '~> 1.2.4'
gem 'therubyracer', '~> 0.10.2', :platforms => [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby
gem 'therubyracer', '~> 0.10.2', platforms: [:mri, :rbx]
gem 'therubyrhino', '~> 1.73.1', platforms: :jruby
gem 'turbo-sprockets-rails3'
end
group :production do
gem "airbrake", '~> 3.1.2'
gem 'bluepill', '~> 0.0.60', :require => false
gem 'bluepill', '~> 0.0.60', require: false
# gem 'le'
gem 'logglier'
gem 'puma'
@ -100,10 +100,10 @@ group :development do
gem 'hirb'
gem 'shotgun'
# deploy
gem 'capistrano', :require => false
gem 'rvm-capistrano', :require => false
gem 'cape', :require => false
gem 'capistrano_colors', :require => false
gem 'capistrano', require: false
gem 'rvm-capistrano', require: false
gem 'cape', require: false
gem 'capistrano_colors', require: false
# Better Errors & RailsPanel
gem 'better_errors'
gem 'binding_of_caller'
@ -112,7 +112,7 @@ group :development do
end
group :test do
gem 'rspec-rails', '~> 2.11.0', :group => 'development'
gem 'rspec-rails', '~> 2.11.0', group: 'development'
gem 'factory_girl_rails', '~> 4.0.0'
gem 'rr', '~> 1.0.4'
gem 'shoulda'

View File

@ -1,5 +1,5 @@
class Admin::EventLogsController < Admin::BaseController
def index
@event_logs = EventLog.default_order.eager_loading.paginate :page => params[:page]
@event_logs = EventLog.default_order.eager_loading.paginate page: params[:page]
end
end

View File

@ -1,10 +1,10 @@
class Admin::FlashNotifiesController < Admin::BaseController
def index
@flash_notifies = FlashNotify.paginate(:page => params[:page], :per_page => 20)
@flash_notifies = FlashNotify.paginate(page: params[:page], per_page: 20)
end
def new
@flash_notify = FlashNotify.new(:published => true)
@flash_notify = FlashNotify.new(published: true)
end
def create

View File

@ -1,20 +1,20 @@
class Admin::RegisterRequestsController < Admin::BaseController
def index
@register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page])
@register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(page: params[:page])
end
def update
RegisterRequest.where(:id => params[:request_ids]).each(&params[:update_type].to_sym) if params[:update_type].present? && params[:request_ids].present?
redirect_to :action => :index
RegisterRequest.where(id: params[:request_ids]).each(&params[:update_type].to_sym) if params[:update_type].present? && params[:request_ids].present?
redirect_to action: :index
end
def approve
@register_request.approve
redirect_to :action => :index
redirect_to action: :index
end
def reject
@register_request.reject
redirect_to :action => :index
redirect_to action: :index
end
end

View File

@ -1,7 +1,7 @@
class Admin::UsersController < Admin::BaseController
include AvatarHelper
prepend_before_filter :find_user
load_and_authorize_resource :collection => [:system, :list]
load_and_authorize_resource collection: [:system, :list]
def index
@filter = params[:filter] || 'all'
@ -29,7 +29,7 @@ class Admin::UsersController < Admin::BaseController
flash[:warning] = @user.errors.full_messages.join('. ')
@system = @user.system?
render :action => :new
render action: :new
end
end
@ -45,7 +45,7 @@ class Admin::UsersController < Admin::BaseController
else
flash[:error] = t('flash.user.save_error')
flash[:warning] = @user.errors.full_messages.join('. ')
render :action => :edit
render action: :edit
end
end
@ -65,7 +65,7 @@ class Admin::UsersController < Admin::BaseController
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
order = "users.#{colName[sort_col.to_i]} #{sort_dir}"
@users = @users.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength])
@users = @users.paginate(page: (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, per_page: params[:iDisplayLength])
@total_users = @users.count
if !params[:sSearch].blank? && search = "%#{params[:sSearch]}%"
@users = @users.where('users.name ILIKE ? or users.uname ILIKE ? or users.email ILIKE ?', search, search, search)
@ -74,7 +74,7 @@ class Admin::UsersController < Admin::BaseController
@users = @users.send(@filter) if ['real', 'admin', 'banned', 'tester'].include? @filter
@users = @users.order(order)
render :partial => 'users_ajax', :layout => false
render partial: 'users_ajax', layout: false
end
def reset_auth_token

View File

@ -1,13 +1,13 @@
class AdvisoriesController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user! if APP_CONFIG['anonymous_access']
load_resource :find_by => :advisory_id
load_resource find_by: :advisory_id
authorize_resource
def index
@advisories = @advisories.scoped(:include => :platforms)
@advisories = @advisories.scoped(include: :platforms)
@advisories = @advisories.search_by_id(params[:q]) if params[:q]
@advisories = @advisories.paginate(:page => params[:page])
@advisories = @advisories.paginate(page: params[:page])
respond_to do |format|
format.html
format.atom
@ -21,7 +21,7 @@ class AdvisoriesController < ApplicationController
def search
@advisory = Advisory.by_update_type(params[:bl_type]).search_by_id(params[:query]).first
if @advisory.nil?
render :nothing => true, :status => 404
render nothing: true, status: 404
else
# respond_to do |format|
# format.json { render @advisory }

View File

@ -1,12 +1,12 @@
class Api::V1::AdvisoriesController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
load_resource :advisory, :find_by => :advisory_id
before_filter :find_and_authorize_build_list, :only => [:create, :update]
authorize_resource :build_list, :only => [:create, :update]
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_resource :advisory, find_by: :advisory_id
before_filter :find_and_authorize_build_list, only: [:create, :update]
authorize_resource :build_list, only: [:create, :update]
def index
@advisories = @advisories.scoped(:include => [:platforms, :projects]).
@advisories = @advisories.scoped(include: [:platforms, :projects]).
paginate(paginate_params)
end

View File

@ -47,7 +47,7 @@ class Api::V1::BaseController < ApplicationController
role = params[:role]
class_name = subject.class.name.downcase
if member.present? && role.present? && subject.respond_to?(:owner) && subject.owner != member &&
subject.send(relation).by_actor(member).update_all(:role => role)
subject.send(relation).by_actor(member).update_all(role: role)
render_json_response subject, "Role for #{member.class.name.downcase} '#{member.id} has been updated in #{class_name} successfully"
else
render_validation_error subject, "Role for member has not been updated in #{class_name}"
@ -89,12 +89,12 @@ class Api::V1::BaseController < ApplicationController
def render_json_response(subject, message, status = 200)
id = status != 200 ? nil : subject.id
render :json => {
render json: {
subject.class.name.underscore.to_sym => {
:id => id,
:message => message
id: id,
message: message
}
}.to_json, :status => status
}.to_json, status: status
end
def render_validation_error(subject, message)
@ -103,9 +103,9 @@ class Api::V1::BaseController < ApplicationController
def member_path(subject)
if subject.is_a?(User)
api_v1_user_path(subject.id, :format => :json)
api_v1_user_path(subject.id, format: :json)
else
api_v1_group_path(subject.id, :format => :json)
api_v1_group_path(subject.id, format: :json)
end
end
@ -113,7 +113,7 @@ class Api::V1::BaseController < ApplicationController
def member
if @member.blank? && %w(User Group).include?(params[:type])
@member = params[:type].constantize.where(:id => params[:member_id]).first
@member = params[:type].constantize.where(id: params[:member_id]).first
end
@member
end

View File

@ -1,20 +1,20 @@
class Api::V1::BuildListsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project, :only => :index
load_and_authorize_resource :build_list, :only => [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing]
load_and_authorize_resource :project, only: :index
load_and_authorize_resource :build_list, only: [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing]
def index
filter = BuildList::Filter.new(@project, current_user, current_ability, params[:filter] || {})
@build_lists = filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch])
@build_lists = filter.find.scoped(include: [:save_to_platform, :project, :user, :arch])
@build_lists = @build_lists.recent.paginate(paginate_params)
end
def create
bl_params = params[:build_list] || {}
save_to_repository = Repository.where(:id => bl_params[:save_to_repository_id]).first
save_to_repository = Repository.where(id: bl_params[:save_to_repository_id]).first
if save_to_repository
bl_params[:save_to_platform_id] = save_to_repository.platform_id

View File

@ -1,7 +1,7 @@
class Api::V1::GroupsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource
def index

View File

@ -2,11 +2,11 @@ class Api::V1::IssuesController < Api::V1::BaseController
respond_to :json
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :group_index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :group_index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :group, :only => :group_index, :find_by => :id, :parent => false
load_and_authorize_resource :group, only: :group_index, find_by: :id, parent: false
load_and_authorize_resource :project
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :update, :create, :index]
load_and_authorize_resource :issue, through: :project, find_by: :serial_id, only: [:show, :update, :create, :index]
def index
@issues = @project.issues
@ -15,20 +15,20 @@ class Api::V1::IssuesController < Api::V1::BaseController
def all_index
project_ids = get_all_project_ids Project.accessible_by(current_ability, :membered).pluck(:id)
@issues = Issue.where(:project_id => project_ids)
@issues = Issue.where(project_id: project_ids)
render_issues_list
end
def user_index
project_ids = get_all_project_ids current_user.projects.pluck(:id)
@issues = Issue.where(:project_id => project_ids)
@issues = Issue.where(project_id: project_ids)
render_issues_list
end
def group_index
project_ids = @group.projects.pluck(:id)
project_ids = Project.accessible_by(current_ability, :membered).where(:id => project_ids).pluck(:id)
@issues = Issue.where(:project_id => project_ids)
project_ids = Project.accessible_by(current_ability, :membered).where(id: project_ids).pluck(:id)
@issues = Issue.where(project_id: project_ids)
render_issues_list
end
@ -70,7 +70,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
if action_name == 'index' && params[:assignee].present?
case params[:assignee]
when 'none'
@issues = @issues.where(:assigned_id => nil)
@issues = @issues.where(assigned_id: nil)
when '*'
@issues = @issues.where('issues.assigned_id IS NOT NULL')
else
@ -81,10 +81,10 @@ class Api::V1::IssuesController < Api::V1::BaseController
if %w[all_index user_index group_index].include?(action_name)
case params[:filter]
when 'created'
@issues = @issues.where(:user_id => current_user)
@issues = @issues.where(user_id: current_user)
when 'all'
else
@issues = @issues.where(:assignee_id => current_user)
@issues = @issues.where(assignee_id: current_user)
end
else
@issues.where('users.uname = ?', params[:creator]) if params[:creator].present?
@ -109,7 +109,7 @@ class Api::V1::IssuesController < Api::V1::BaseController
if ['created', 'all'].include? params[:filter]
# add own issues
project_ids = Project.accessible_by(current_ability, :show).joins(:issues).
where(:issues => {:user_id => current_user.id}).pluck('projects.id')
where(issues: {user_id: current_user.id}).pluck('projects.id')
end
project_ids |= default_project_ids
end

View File

@ -15,7 +15,7 @@ class Api::V1::JobsController < Api::V1::BaseController
if current_user.system?
if task = (Resque.pop('rpm_worker_default') || Resque.pop('rpm_worker'))
@build_list = BuildList.where(:id => task['args'][0]['id']).first
@build_list = BuildList.where(id: task['args'][0]['id']).first
end
end
@ -37,12 +37,12 @@ class Api::V1::JobsController < Api::V1::BaseController
if @build_list
job = {
:worker_queue => @build_list.worker_queue_with_priority,
:worker_class => @build_list.worker_queue_class,
worker_queue: @build_list.worker_queue_with_priority,
worker_class: @build_list.worker_queue_class,
:worker_args => [@build_list.abf_worker_args]
}
end
render :json => { :job => job }.to_json
render json: { job: job }.to_json
end
def statistics
@ -51,25 +51,25 @@ class Api::V1::JobsController < Api::V1::BaseController
:id => params[:uid],
:user_id => current_user.id,
:system => current_user.system?,
:worker_count => params[:worker_count],
:busy_workers => params[:busy_workers]
worker_count: params[:worker_count],
busy_workers: params[:busy_workers]
) rescue nil
end
render :nothing => true
render nothing: true
end
def status
render :text => Resque.redis.get(params[:key])
render text: Resque.redis.get(params[:key])
end
def logs
name = params[:name]
if name =~ /abfworker::rpm-worker/
if current_user.system? || current_user.id == BuildList.where(:id => name.gsub(/[^\d]/, '')).first.try(:builder_id)
if current_user.system? || current_user.id == BuildList.where(id: name.gsub(/[^\d]/, '')).first.try(:builder_id)
BuildList.log_server.setex name, 15, params[:logs]
end
end
render :nothing => true
render nothing: true
end
def feedback
@ -77,11 +77,11 @@ class Api::V1::JobsController < Api::V1::BaseController
worker_class = params[:worker_class]
if QUEUES.include?(worker_queue) && QUEUE_CLASSES.include?(worker_class)
worker_args = (params[:worker_args] || []).first || {}
worker_args = worker_args.merge(:feedback_from_user => current_user.id)
worker_args = worker_args.merge(feedback_from_user: current_user.id)
Resque.push worker_queue, 'class' => worker_class, 'args' => [worker_args]
render :nothing => true
render nothing: true
else
render :nothing => true, :status => 403
render nothing: true, status: 403
end
end

View File

@ -1,15 +1,15 @@
class Api::V1::PlatformsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => :allowed
skip_before_filter :authenticate_user!, :only => [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: :allowed
skip_before_filter :authenticate_user!, only: [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :except => :allowed
load_and_authorize_resource except: :allowed
def allowed
if Platform.allowed?(params[:path] || '', request)
render :nothing => true
render nothing: true
else
render :nothing => true, :status => 403
render nothing: true, status: 403
end
end
@ -28,14 +28,14 @@ class Api::V1::PlatformsController < Api::V1::BaseController
def create
platform_params = params[:platform] || {}
owner = User.where(:id => platform_params[:owner_id]).first
owner = User.where(id: platform_params[:owner_id]).first
@platform.owner = owner || get_owner
create_subject @platform
end
def update
platform_params = params[:platform] || {}
owner = User.where(:id => platform_params[:owner_id]).first
owner = User.where(id: platform_params[:owner_id]).first
platform_params[:owner] = owner if owner
update_subject @platform
end

View File

@ -1,8 +1,8 @@
class Api::V1::ProductBuildListsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :product, :only => :index
load_and_authorize_resource :product, only: :index
load_and_authorize_resource
def index
@ -27,7 +27,7 @@ class Api::V1::ProductBuildListsController < Api::V1::BaseController
end
def update
params[:product_build_list] = {:not_delete => (params[:product_build_list] || {})[:not_delete]}
params[:product_build_list] = {not_delete: (params[:product_build_list] || {})[:not_delete]}
update_subject @product_build_list
end

View File

@ -1,6 +1,6 @@
class Api::V1::ProductsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource

View File

@ -1,7 +1,7 @@
class Api::V1::ProjectsController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
@ -38,7 +38,7 @@ class Api::V1::ProjectsController < Api::V1::BaseController
owner_type = p_params[:owner_type]
if owner_type.present? && %w(User Group).include?(owner_type)
@project.owner = owner_type.constantize.
where(:id => p_params[:owner_id]).first
where(id: p_params[:owner_id]).first
else
@project.owner = nil
end

View File

@ -2,37 +2,37 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
respond_to :json
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access']
load_resource :group, :only => :group_index, :find_by => :id, :parent => false
load_resource :group, only: :group_index, find_by: :id, parent: false
load_resource :project
load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :only => [:show, :index, :commits, :files, :merge, :update]
load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :only => [:show, :index, :commits, :files, :merge, :update]
load_resource :issue, through: :project, find_by: :serial_id, parent: false, only: [:show, :index, :commits, :files, :merge, :update]
load_and_authorize_resource instance_name: :pull, through: :issue, singleton: true, only: [:show, :index, :commits, :files, :merge, :update]
def index
@pulls = @project.pull_requests
@pulls_url = api_v1_project_pull_requests_path(@project, :format => :json)
@pulls_url = api_v1_project_pull_requests_path(@project, format: :json)
render_pulls_list
end
def all_index
project_ids = get_all_project_ids Project.accessible_by(current_ability, :membered).pluck(:id)
@pulls = PullRequest.where('pull_requests.to_project_id IN (?)', project_ids)
@pulls_url = api_v1_pull_requests_path :format => :json
@pulls_url = api_v1_pull_requests_path format: :json
render_pulls_list
end
def user_index
project_ids = get_all_project_ids current_user.projects.pluck(:id)
@pulls = PullRequest.where('pull_requests.to_project_id IN (?)', project_ids)
@pulls_url = pull_requests_api_v1_user_path :format => :json
@pulls_url = pull_requests_api_v1_user_path format: :json
render_pulls_list
end
def group_index
project_ids = @group.projects.pluck(:id)
project_ids = Project.accessible_by(current_ability, :membered).where(:id => project_ids).pluck(:id)
@pulls = PullRequest.where(:to_project_id => project_ids)
project_ids = Project.accessible_by(current_ability, :membered).where(id: project_ids).pluck(:id)
@pulls = PullRequest.where(to_project_id: project_ids)
@pulls_url = pull_requests_api_v1_group_path
render_pulls_list
end
@ -47,7 +47,7 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
authorize! :read, from_project
@pull = @project.pull_requests.new
@pull.build_issue :title => pull_params[:title], :body => pull_params[:body]
@pull.build_issue title: pull_params[:title], body: pull_params[:body]
@pull.from_project = @project
@pull.to_ref, @pull.from_ref = pull_params[:to_ref], pull_params[:from_ref]
@pull.issue.assignee_id = pull_params[:assignee_id] if can?(:write, @project)
@ -59,7 +59,7 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
@pull.check(false) # don't make event transaction
if @pull.already?
@pull.destroy
error_message = I18n.t('projects.pull_requests.up_to_date', :to_ref => @pull.to_ref, :from_ref => @pull.from_ref)
error_message = I18n.t('projects.pull_requests.up_to_date', to_ref: @pull.to_ref, from_ref: @pull.from_ref)
render_json_response(@pull, error_message, 422)
else
@pull.send(@pull.status == 'blocked' ? 'block' : @pull.status)
@ -68,12 +68,12 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
end
def update
@pull = @project.pull_requests.includes(:issue).where(:issues => {:serial_id => params[:id]}).first
@pull = @project.pull_requests.includes(:issue).where(issues: {serial_id: params[:id]}).first
authorize! :update, @pull
if pull_params.present?
attrs = pull_params.slice(:title, :body)
attrs.merge!(:assignee_id => pull_params[:assignee_id]) if can?(:write, @project)
attrs.merge!(assignee_id: pull_params[:assignee_id]) if can?(:write, @project)
if (action = pull_params[:status]) && %w(close reopen).include?(pull_params[:status])
if @pull.send("can_#{action}?")
@ -113,7 +113,7 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
private
def render_pulls_list
@pulls = @pulls.includes(:issue => [:user, :assignee])
@pulls = @pulls.includes(issue: [:user, :assignee])
if params[:status] == 'closed'
@pulls = @pulls.closed_or_merged
else
@ -157,7 +157,7 @@ class Api::V1::PullRequestsController < Api::V1::BaseController
if ['created', 'all'].include? params[:filter]
# add own pulls
project_ids = Project.accessible_by(current_ability, :show).joins(:issues).
where(:issues => {:user_id => current_user.id}).pluck('projects.id')
where(issues: {user_id: current_user.id}).pluck('projects.id')
end
project_ids |= default_project_ids
end

View File

@ -1,9 +1,9 @@
class Api::V1::RepositoriesController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :projects] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :projects] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :repository, :through => :platform, :shallow => true
load_and_authorize_resource :repository, through: :platform, shallow: true
def show
end
@ -73,7 +73,7 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
end
def add_project
if project = Project.where(:id => params[:project_id]).first
if project = Project.where(id: params[:project_id]).first
if can?(:read, project)
begin
@repository.projects << project
@ -91,7 +91,7 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
def remove_project
project_id = params[:project_id]
ProjectToRepository.where(:project_id => project_id, :repository_id => @repository.id).destroy_all
ProjectToRepository.where(project_id: project_id, repository_id: @repository.id).destroy_all
render_json_response @repository, "Project '#{project_id}' has been removed from repository successfully"
end

View File

@ -1,9 +1,9 @@
class Api::V1::UsersController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :user, :only => :show
before_filter :set_current_user, :except => :show
skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :user, only: :show
before_filter :set_current_user, except: :show
def show
@user = User.opened.find params[:id] # dont show system users

View File

@ -11,24 +11,24 @@ class ApplicationController < ActionController::Base
before_filter :set_locale
before_filter lambda { EventLog.current_controller = self },
:only => [:create, :destroy, :open_id, :cancel, :publish, :change_visibility] # :update
only: [:create, :destroy, :open_id, :cancel, :publish, :change_visibility] # :update
after_filter lambda { EventLog.current_controller = nil }
helper_method :get_owner
unless Rails.env.development?
rescue_from Exception, :with => :render_500
rescue_from Exception, with: :render_500
rescue_from ActiveRecord::RecordNotFound,
# ActionController::RoutingError, # see: config/routes.rb:<last line>
ActionController::UnknownController,
AbstractController::ActionNotFound, :with => :render_404
AbstractController::ActionNotFound, with: :render_404
end
rescue_from CanCan::AccessDenied do |exception|
redirect_to forbidden_url, :alert => t("flash.exception_message")
redirect_to forbidden_url, alert: t("flash.exception_message")
end
rescue_from Grit::NoSuchPathError, :with => :not_found
rescue_from Grit::NoSuchPathError, with: :not_found
def render_404
@ -47,8 +47,8 @@ class ApplicationController < ActionController::Base
def render_error(status)
respond_to do |format|
format.json { render :json => {:status => status, :message => t("flash.#{status}_message")}.to_json, :status => status }
format.html { redirect_to "/#{status}.html", :alert => t("flash.#{status}_message") }
format.json { render json: {status: status, message: t("flash.#{status}_message")}.to_json, status: status }
format.html { redirect_to "/#{status}.html", alert: t("flash.#{status}_message") }
end
end

View File

@ -1,6 +1,6 @@
class Groups::MembersController < Groups::BaseController
is_related_controller!
belongs_to :group, :finder => 'find_by_insensitive_uname!', :optional => true
belongs_to :group, finder: 'find_by_insensitive_uname!', optional: true
before_filter lambda { authorize! :manage_members, @group }
@ -10,10 +10,10 @@ class Groups::MembersController < Groups::BaseController
def update
params['user'].keys.each do |user_id|
role = params['user'][user_id]
if relation = parent.actors.where(:actor_id => user_id, :actor_type => 'User') #find_by_actor_id_and_actor_type(user_id, 'User')
relation.update_all(:role => role) if parent.owner.id.to_s != user_id
if relation = parent.actors.where(actor_id: user_id, actor_type: 'User') #find_by_actor_id_and_actor_type(user_id, 'User')
relation.update_all(role: role) if parent.owner.id.to_s != user_id
else
relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role)
relation = parent.actors.build(actor_id: user_id, actor_type: 'User', role: role)
relation.save!
end
end if params['user']
@ -30,7 +30,7 @@ class Groups::MembersController < Groups::BaseController
params['user_remove'].each do |user_id, remove|
all_user_ids << user_id if remove == ["1"]
end if params['user_remove']
User.where(:id => all_user_ids).each do |user|
User.where(id: all_user_ids).each do |user|
parent.remove_member(user)
end
redirect_to group_members_path(parent)
@ -39,7 +39,7 @@ class Groups::MembersController < Groups::BaseController
def add
@user = User.find_by_uname(params[:user_uname])
if !@user
flash[:error] = t("flash.collaborators.wrong_user", :uname => params[:user_uname])
flash[:error] = t("flash.collaborators.wrong_user", uname: params[:user_uname])
elsif parent.add_member(@user, params[:role])
flash[:notice] = t("flash.members.successfully_added")
else

View File

@ -1,10 +1,10 @@
class Groups::ProfileController < Groups::BaseController
include AvatarHelper
load_and_authorize_resource :class => Group, :instance_name => 'group'
skip_before_filter :authenticate_user!, :only => :show if APP_CONFIG['anonymous_access']
load_and_authorize_resource class: Group, instance_name: 'group'
skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
def index
@groups = current_user.groups.paginate(:page => params[:group_page]) # accessible_by(current_ability)
@groups = current_user.groups.paginate(page: params[:group_page]) # accessible_by(current_ability)
@groups = @groups.search(params[:query]) if params[:query].present?
end
@ -18,7 +18,7 @@ class Groups::ProfileController < Groups::BaseController
else
@projects = @projects.by_visibilities('hidden').accessible_by(current_ability, :read)
end
render :partial => 'shared/profile_projects', :layout => nil, :locals => {:projects => paginate_projects(page)}
render partial: 'shared/profile_projects', layout: nil, locals: {projects: paginate_projects(page)}
else
@projects = paginate_projects(page)
end
@ -38,7 +38,7 @@ class Groups::ProfileController < Groups::BaseController
else
flash[:error] = t('flash.group.save_error')
flash[:warning] = @group.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
@ -49,7 +49,7 @@ class Groups::ProfileController < Groups::BaseController
redirect_to group_path(@group)
else
flash[:error] = t('flash.group.save_error')
render :action => :edit
render action: :edit
end
end
@ -67,6 +67,6 @@ class Groups::ProfileController < Groups::BaseController
protected
def paginate_projects(page)
@projects.paginate(:page => (page>0 ? page : nil), :per_page => 24)
@projects.paginate(page: (page>0 ? page : nil), per_page: 24)
end
end

View File

@ -1,26 +1,26 @@
class HomeController < ApplicationController
before_filter :authenticate_user!, :only => [:activity, :issues, :pull_requests]
before_filter :authenticate_user!, only: [:activity, :issues, :pull_requests]
def root
render 'pages/tour/abf-tour-project-description-1', :layout => 'tour'
render 'pages/tour/abf-tour-project-description-1', layout: 'tour'
end
def activity
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
@activity_feeds = current_user.activity_feeds
@activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
@activity_feeds = @activity_feeds.paginate :page => params[:page]
@activity_feeds = @activity_feeds.where(kind: "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
@activity_feeds = @activity_feeds.paginate page: params[:page]
respond_to do |format|
format.html { request.xhr? ? render('_list', :layout => false) : render('activity') }
format.html { request.xhr? ? render('_list', layout: false) : render('activity') }
format.atom
end
end
def issues
@created_issues = current_user.issues
@assigned_issues = Issue.where(:assignee_id => current_user.id)
@assigned_issues = Issue.where(assignee_id: current_user.id)
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
@all_issues = Issue.where(:project_id => pr_ids)
@all_issues = Issue.where(project_id: pr_ids)
@created_issues, @assigned_issues, @all_issues =
if action_name == 'issues'
[@created_issues.without_pull_requests,
@ -51,8 +51,8 @@ class HomeController < ApplicationController
@direction = params[:direction] == 'asc' ? :asc : :desc
@issues = @issues.order("issues.#{@sort}_at #{@direction}")
.includes(:assignee, :user, :pull_request).uniq
.paginate :per_page => 20, :page => params[:page]
render 'issues', :layout => request.xhr? ? 'with_sidebar' : 'application'
.paginate per_page: 20, page: params[:page]
render 'issues', layout: request.xhr? ? 'with_sidebar' : 'application'
end
def pull_requests

View File

@ -9,7 +9,7 @@ class PagesController < ApplicationController
when 'projects'
%w(control git tracker)
end
render "pages/tour/tour-inside", :layout => 'tour'
render "pages/tour/tour-inside", layout: 'tour'
end
def forbidden

View File

@ -1,8 +1,8 @@
class Platforms::KeyPairsController < Platforms::BaseController
before_filter :authenticate_user!
load_and_authorize_resource :platform, :only => [:index]
load_and_authorize_resource :only => [:create, :destroy]
load_and_authorize_resource :platform, only: [:index]
load_and_authorize_resource only: [:create, :destroy]
def create
@key_pair.user_id = current_user.id

View File

@ -1,12 +1,12 @@
class Platforms::MaintainersController < ApplicationController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
def index
@maintainers = BuildList::Package.includes(:project)
.actual.by_platform(@platform)
.like_name(params[:q])
.paginate(:page => params[:page])
.paginate(page: params[:page])
end
end

View File

@ -1,7 +1,7 @@
class Platforms::MassBuildsController < Platforms::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :get_list] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access']
load_resource :platform
load_and_authorize_resource :through => :platform, :shallow => true
@ -14,11 +14,11 @@ class Platforms::MassBuildsController < Platforms::BaseController
@mass_build.user, @mass_build.arches = current_user, params[:arches]
if @mass_build.save
redirect_to(platform_mass_builds_path(@platform), :notice => t("flash.platform.build_all_success"))
redirect_to(platform_mass_builds_path(@platform), notice: t("flash.platform.build_all_success"))
else
flash[:warning] = @mass_build.errors.full_messages.join('. ')
flash[:error] = t('flash.platform.build_all_error')
render :action => :new
render action: :new
end
end
@ -28,11 +28,11 @@ class Platforms::MassBuildsController < Platforms::BaseController
else
@mass_build.publish_success_builds current_user
end
redirect_to(platform_mass_builds_path(@mass_build.save_to_platform), :notice => t("flash.platform.publish_success"))
redirect_to(platform_mass_builds_path(@mass_build.save_to_platform), notice: t("flash.platform.publish_success"))
end
def index
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(page: params[:page], per_page: 20)
end
def cancel
@ -47,6 +47,6 @@ class Platforms::MassBuildsController < Platforms::BaseController
elsif ['projects_list', 'missed_projects_list'].include? params[:kind]
@mass_build.send params[:kind]
end
render :text => text
render text: text
end
end

View File

@ -2,11 +2,11 @@ class Platforms::PlatformsController < Platforms::BaseController
include FileStoreHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:advisories, :members, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:advisories, :members, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource
def index
@platforms = @platforms.accessible_by(current_ability, :related).order(:name).paginate(:page => params[:page], :per_page => 20)
@platforms = @platforms.accessible_by(current_ability, :related).order(:name).paginate(page: params[:page], per_page: 20)
end
def show
@ -34,7 +34,7 @@ class Platforms::PlatformsController < Platforms::BaseController
else
flash[:error] = I18n.t("flash.platform.create_error")
flash[:warning] = @platform.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
@ -52,7 +52,7 @@ class Platforms::PlatformsController < Platforms::BaseController
else
flash[:error] = I18n.t("flash.platform.save_error")
flash[:warning] = @platform.errors.full_messages.join('. ')
render :action => :edit
render action: :edit
end
end
@ -72,7 +72,7 @@ class Platforms::PlatformsController < Platforms::BaseController
else
flash[:error] = I18n.t("flash.platform.save_error")
flash[:warning] = @platform.errors.full_messages.join('. ')
render :action => :edit
render action: :edit
end
end
@ -83,7 +83,7 @@ class Platforms::PlatformsController < Platforms::BaseController
end
def make_clone
@cloned = @platform.full_clone params[:platform].merge(:owner => current_user)
@cloned = @platform.full_clone params[:platform].merge(owner: current_user)
if @cloned.persisted?
flash[:notice] = I18n.t("flash.platform.clone_success")
redirect_to @cloned
@ -106,29 +106,29 @@ class Platforms::PlatformsController < Platforms::BaseController
def remove_members
user_ids = params[:user_remove] ?
params[:user_remove].map{ |k, v| k if v.first == '1' }.compact : []
User.where(:id => user_ids).each{ |user| @platform.remove_member(user) }
User.where(id: user_ids).each{ |user| @platform.remove_member(user) }
redirect_to members_platform_path(@platform)
end
def remove_member
User.where(:id => params[:member_id]).each{ |user| @platform.remove_member(user) }
User.where(id: params[:member_id]).each{ |user| @platform.remove_member(user) }
redirect_to members_platform_path(@platform)
end
def add_member
member = User.where(:id => params[:member_id]).first
member = User.where(id: params[:member_id]).first
if !member
flash[:error] = t("flash.collaborators.wrong_user", :uname => params[:member_id])
flash[:error] = t("flash.collaborators.wrong_user", uname: params[:member_id])
elsif @platform.add_member(member)
flash[:notice] = t('flash.platform.members.successfully_added', :name => member.uname)
flash[:notice] = t('flash.platform.members.successfully_added', name: member.uname)
else
flash[:error] = t('flash.platform.members.error_in_adding', :name => member.uname)
flash[:error] = t('flash.platform.members.error_in_adding', name: member.uname)
end
redirect_to members_platform_url(@platform)
end
def advisories
@advisories = @platform.advisories.paginate(:page => params[:page])
@advisories = @platform.advisories.paginate(page: params[:page])
end
def clear

View File

@ -13,7 +13,7 @@ class Platforms::PrivateUsersController < Platforms::BaseController
@pair = PrivateUser.generate_pair(params[:platform_id], current_user.id)
@urpmi_list = @platform.urpmi_list(request.host, @pair)
redirect_to platform_private_users_path(params[:platform_id]), :notice => I18n.t('flash.private_users', :login => @pair[:login], :password => @pair[:pass])
redirect_to platform_private_users_path(params[:platform_id]), notice: I18n.t('flash.private_users', login: @pair[:login], password: @pair[:pass])
end
#def destroy
@ -25,7 +25,7 @@ class Platforms::PrivateUsersController < Platforms::BaseController
protected
def find_platform_and_private_users
@private_users = PrivateUser.where(:platform_id => params[:platform_id]).paginate :page => params[:page]
@private_users = PrivateUser.where(platform_id: params[:platform_id]).paginate page: params[:page]
@platform = Platform.find(params[:platform_id])
end
end

View File

@ -8,7 +8,7 @@ class Platforms::PrivatesController < Platforms::BaseController
file_name = "#{APP_CONFIG['root_path']}/platforms/#{params[:platform_name]}/#{params[:file_path]}"
if File.directory?(file_name) || !File.exists?(file_name)
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
render file: "#{Rails.root}/public/404.html", layout: false, status: 404
else
send_file file_name
end
@ -19,9 +19,9 @@ class Platforms::PrivatesController < Platforms::BaseController
def authenticate
authenticate_or_request_with_http_basic do |username, password|
PrivateUser.exists?(
:login => username,
:password => Digest::SHA2.new.hexdigest(password),
:platform_id => @platform.try(:id)
login: username,
password: Digest::SHA2.new.hexdigest(password),
platform_id: @platform.try(:id)
)
end
end

View File

@ -2,12 +2,12 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
include FileStoreHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show, :log] if APP_CONFIG['anonymous_access']
before_filter :redirect_to_full_path_if_short_url, :only => :show
load_and_authorize_resource :platform, :except => :index
load_and_authorize_resource :product, :through => :platform, :except => :index
load_and_authorize_resource :product_build_list, :through => :product, :except => :index
load_and_authorize_resource :only => [:index, :show, :log, :cancel, :update]
skip_before_filter :authenticate_user!, only: [:index, :show, :log] if APP_CONFIG['anonymous_access']
before_filter :redirect_to_full_path_if_short_url, only: :show
load_and_authorize_resource :platform, except: :index
load_and_authorize_resource :product, through: :platform, except: :index
load_and_authorize_resource :product_build_list, through: :product, except: :index
load_and_authorize_resource only: [:index, :show, :log, :cancel, :update]
def new
product = @product_build_list.product
@ -25,7 +25,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
end
def update
if @product_build_list.update_attributes(:not_delete => (params[:product_build_list] || {})[:not_delete])
if @product_build_list.update_attributes(not_delete: (params[:product_build_list] || {})[:not_delete])
flash[:notice] = t('flash.product_build_list.updated')
else
flash[:error] = t('flash.product_build_list.update_error')
@ -40,13 +40,13 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
else
notice = t('layout.build_lists.cancel_fail')
end
redirect_to :back, :notice => notice
redirect_to :back, notice: notice
end
def log
render :json => {
:log => @product_build_list.abf_worker_log,
:building => @product_build_list.build_started?
render json: {
log: @product_build_list.abf_worker_log,
building: @product_build_list.build_started?
}
end
@ -62,7 +62,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
else
flash[:error] = t('flash.product.build_error')
flash[:warning] = pbl.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
@ -77,12 +77,12 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
def index
if params[:product_id].present?
@product_build_lists = @product_build_lists.where(:id => params[:product_id])
@product_build_lists = @product_build_lists.where(id: params[:product_id])
else
@product_build_lists = @product_build_lists.scoped_to_product_name(params[:product_name]) if params[:product_name].present?
@product_build_lists = @product_build_lists.for_status(params[:status]) if params[:status].present?
end
@product_build_lists = @product_build_lists.recent.paginate :page => params[:page]
@product_build_lists = @product_build_lists.recent.paginate page: params[:page]
@build_server_status = AbfWorker::StatusInspector.products_status
end

View File

@ -1,14 +1,14 @@
class Platforms::ProductsController < Platforms::BaseController
include GitHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
load_and_authorize_resource :product, :through => :platform, :except => :autocomplete_project
before_filter :set_project, :only => [:create, :update]
load_and_authorize_resource :product, through: :platform, except: :autocomplete_project
before_filter :set_project, only: [:create, :update]
def index
@products = @products.paginate(:page => params[:page])
@products = @products.paginate(page: params[:page])
end
def new
@ -26,7 +26,7 @@ class Platforms::ProductsController < Platforms::BaseController
else
flash[:error] = t('flash.product.save_error')
flash[:warning] = @product.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
@ -37,7 +37,7 @@ class Platforms::ProductsController < Platforms::BaseController
else
flash[:error] = t('flash.product.save_error')
flash[:warning] = @product.errors.full_messages.join('. ')
render :action => "edit"
render action: "edit"
end
end
@ -54,12 +54,12 @@ class Platforms::ProductsController < Platforms::BaseController
items = Project.accessible_by(current_ability, :membered)
.search(params[:term]).limit(20)
#items.select! {|e| e.repo.branches.count > 0}
render :json => items.map{ |p|
render json: items.map{ |p|
{
:id => p.id,
:label => p.name_with_owner,
:value => p.name_with_owner,
:project_versions => versions_for_group_select(p)
id: p.id,
label: p.name_with_owner,
value: p.name_with_owner,
project_versions: versions_for_group_select(p)
}
}
end

View File

@ -2,53 +2,53 @@ class Platforms::RepositoriesController < Platforms::BaseController
include FileStoreHelper
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show, :projects_list] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show, :projects_list] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform
load_and_authorize_resource :repository, :through => :platform, :shallow => true
before_filter :set_members, :only => [:edit, :update]
load_and_authorize_resource :repository, through: :platform, shallow: true
before_filter :set_members, only: [:edit, :update]
def index
@repositories = Repository.custom_sort(@repositories).paginate(:page => params[:page])
@repositories = Repository.custom_sort(@repositories).paginate(page: params[:page])
end
def show
@projects = @repository.projects.recent.search(params[:query])
.paginate(:page => params[:project_page], :per_page => 30)
.paginate(page: params[:project_page], per_page: 30)
end
def edit
end
def update
if @repository.update_attributes params[:repository].slice(:description, :synchronizing_publications).merge(:publish_without_qa => (params[:repository][:publish_without_qa] || @repository.publish_without_qa))
if @repository.update_attributes params[:repository].slice(:description, :synchronizing_publications).merge(publish_without_qa: (params[:repository][:publish_without_qa] || @repository.publish_without_qa))
flash[:notice] = I18n.t("flash.repository.updated")
redirect_to platform_repository_path(@platform, @repository)
else
flash[:error] = I18n.t("flash.repository.update_error")
flash[:warning] = @repository.errors.full_messages.join('. ')
render :action => :edit
render action: :edit
end
end
def remove_members
user_ids = params[:user_remove] ?
params[:user_remove].map{ |k, v| k if v.first == '1' }.compact : []
User.where(:id => user_ids).each{ |user| @repository.remove_member(user) }
User.where(id: user_ids).each{ |user| @repository.remove_member(user) }
redirect_to edit_platform_repository_path(@platform, @repository)
end
def remove_member
User.where(:id => params[:member_id]).each{ |user| @repository.remove_member(user) }
User.where(id: params[:member_id]).each{ |user| @repository.remove_member(user) }
redirect_to edit_platform_repository_path(@platform, @repository)
end
def add_member
if member = User.where(:id => params[:member_id]).first
if member = User.where(id: params[:member_id]).first
if @repository.add_member(member)
flash[:notice] = t('flash.repository.members.successfully_added', :name => member.uname)
flash[:notice] = t('flash.repository.members.successfully_added', name: member.uname)
else
flash[:error] = t('flash.repository.members.error_in_adding', :name => member.uname)
flash[:error] = t('flash.repository.members.error_in_adding', name: member.uname)
end
end
redirect_to edit_platform_repository_path(@platform, @repository)
@ -74,14 +74,14 @@ class Platforms::RepositoriesController < Platforms::BaseController
else
flash[:error] = t('flash.repository.save_error')
flash[:warning] = @repository.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
def add_project
if projects_list = params.try(:[], :repository).try(:[], :projects_list)
@repository.add_projects projects_list, current_user
redirect_to platform_repository_path(@platform, @repository), :notice => t('flash.repository.projects_will_be_added')
redirect_to platform_repository_path(@platform, @repository), notice: t('flash.repository.projects_will_be_added')
return
end
if params[:project_id].present?
@ -103,7 +103,7 @@ class Platforms::RepositoriesController < Platforms::BaseController
end
def projects_list
render(:text => @repository.projects.map(&:name).join("\n")) && return if params[:text] == 'true'
render(text: @repository.projects.map(&:name).join("\n")) && return if params[:text] == 'true'
owner_subquery = "
INNER JOIN (
@ -126,8 +126,8 @@ class Platforms::RepositoriesController < Platforms::BaseController
@projects = @projects.opened if @repository.platform.main? && !@repository.platform.hidden?
end
@projects = @projects.paginate(
:page => (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
:per_page => params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
page: (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
per_page: params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
)
@total_projects = @projects.count
@ -135,7 +135,7 @@ class Platforms::RepositoriesController < Platforms::BaseController
respond_to do |format|
format.json {
render :partial => (params[:added] == "true") ? 'project' : 'proj_ajax', :layout => false
render partial: (params[:added] == "true") ? 'project' : 'proj_ajax', layout: false
}
end
end
@ -143,11 +143,11 @@ class Platforms::RepositoriesController < Platforms::BaseController
def remove_project
if projects_list = params.try(:[], :repository).try(:[], :projects_list)
@repository.remove_projects projects_list
redirect_to platform_repository_path(@platform, @repository), :notice => t('flash.repository.projects_will_be_removed')
redirect_to platform_repository_path(@platform, @repository), notice: t('flash.repository.projects_will_be_removed')
end
if params[:project_id].present?
ProjectToRepository.where(:project_id => params[:project_id], :repository_id => @repository.id).destroy_all
redirect_to platform_repository_path(@platform, @repository), :notice => t('flash.repository.project_removed')
ProjectToRepository.where(project_id: params[:project_id], repository_id: @repository.id).destroy_all
redirect_to platform_repository_path(@platform, @repository), notice: t('flash.repository.project_removed')
end
end

View File

@ -7,7 +7,7 @@ class Platforms::TokensController < Platforms::BaseController
def index
authorize! :local_admin_manage, @platform
@tokens = @platform.tokens.includes(:creator, :updater)
.paginate(:per_page => 20, :page => params[:page])
.paginate(per_page: 20, page: params[:page])
end
def show
@ -17,9 +17,9 @@ class Platforms::TokensController < Platforms::BaseController
if @token.block
@token.updater = current_user
@token.save
redirect_to :back, :notice => t('flash.tokens.withdraw_success')
redirect_to :back, notice: t('flash.tokens.withdraw_success')
else
redirect_to :back, :notice => t('flash.tokens.withdraw_fail')
redirect_to :back, notice: t('flash.tokens.withdraw_fail')
end
end

View File

@ -6,7 +6,7 @@ class Projects::BaseController < ApplicationController
def find_collaborators
search = "%#{params[:search_user]}%"
users = User.joins(:groups => :projects).where(:projects => {:id => @project.id}).where("users.uname ILIKE ?", search)
users = User.joins(groups: :projects).where(projects: {id: @project.id}).where("users.uname ILIKE ?", search)
users2 = @project.collaborators.where("users.uname ILIKE ?", search)
@users = (users + users2).uniq.sort {|x,y| x.uname <=> y.uname}.first(10)
end

View File

@ -4,15 +4,15 @@ class Projects::BuildListsController < Projects::BaseController
NESTED_ACTIONS = [:index, :new, :create]
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :log] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access']
before_filter :find_build_list, :only => [:show, :publish, :cancel, :update, :log, :create_container]
before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container]
load_and_authorize_resource :project, :only => NESTED_ACTIONS
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
load_and_authorize_resource :except => NESTED_ACTIONS
load_and_authorize_resource :project, only: NESTED_ACTIONS
load_and_authorize_resource :build_list, through: :project, only: NESTED_ACTIONS, shallow: true
load_and_authorize_resource except: NESTED_ACTIONS
before_filter :create_from_build_list, :only => :new
before_filter :create_from_build_list, only: :new
def index
params[:filter].each{|k,v| params[:filter].delete(k) if v.blank? } if params[:filter]
@ -24,16 +24,16 @@ class Projects::BuildListsController < Projects::BaseController
@bls = @filter.find.recent
.paginate(
:page => (params[:page].to_i == 0 ? nil : params[:page]),
:per_page => BuildList::Filter::PER_PAGE.include?(params[:per_page].to_i) ? params[:per_page].to_i : 25
per_page: BuildList::Filter::PER_PAGE.include?(params[:per_page].to_i) ? params[:per_page].to_i : 25
)
@build_lists = BuildList.where(:id => @bls.pluck(:id)).recent
@build_lists = BuildList.where(id: @bls.pluck(:id)).recent
.includes(
:save_to_platform,
:save_to_repository,
:build_for_platform,
:user,
:source_packages,
:project => :project_statistics
project: :project_statistics
)
@build_server_status = AbfWorker::StatusInspector.projects_status
@ -43,7 +43,7 @@ class Projects::BuildListsController < Projects::BaseController
def new
if params[:show] == 'inline' && params[:build_list_id].present?
render '_new_form', :layout => false, :locals => {:project => @project, :build_list => @build_list}
render '_new_form', layout: false, locals: {project: @project, build_list: @build_list}
else
render :new
end
@ -59,17 +59,17 @@ class Projects::BuildListsController < Projects::BaseController
params[:build_list][:auto_publish] = false unless @repository.publish_without_qa?
build_for_platforms = Repository.select(:platform_id).
where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
where(id: params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id)
build_lists = []
Arch.where(:id => params[:arches]).each do |arch|
Platform.main.where(:id => build_for_platforms).each do |build_for_platform|
Arch.where(id: params[:arches]).each do |arch|
Platform.main.where(id: build_for_platforms).each do |build_for_platform|
@build_list = @project.build_lists.build(params[:build_list])
@build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user
@build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i}
@build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name}
flash_options = {project_version: @build_list.project_version, arch: arch.name, build_for_platform: build_for_platform.name}
if authorize!(:create, @build_list) && @build_list.save
build_lists << @build_list
notices << t("flash.build_list.saved", flash_options)
@ -82,9 +82,9 @@ class Projects::BuildListsController < Projects::BaseController
if errors.present?
@build_list ||= BuildList.new
flash[:error] = errors.join('<br>').html_safe
render :action => :new
render action: :new
else
BuildList.where(:id => build_lists.map(&:id)).update_all(:group_id => build_lists[0].id) if build_lists.size > 1
BuildList.where(id: build_lists.map(&:id)).update_all(group_id: build_lists[0].id) if build_lists.size > 1
flash[:notice] = notices.join('<br>').html_safe
redirect_to project_build_lists_path(@project)
end
@ -100,54 +100,54 @@ class Projects::BuildListsController < Projects::BaseController
if params[:attach_advisory].present? and params[:attach_advisory] != 'no' and !@build_list.advisory
unless @build_list.update_type.in? BuildList::RELEASE_UPDATE_TYPES
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
redirect_to :back, notice: t('layout.build_lists.publish_fail') and return
end
if params[:attach_advisory] == 'new'
# create new advisory
unless @build_list.associate_and_create_advisory(params[:build_list][:advisory])
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
redirect_to :back, notice: t('layout.build_lists.publish_fail') and return
end
else
# attach existing advisory
a = Advisory.where(:advisory_id => params[:attach_advisory]).first
a = Advisory.where(advisory_id: params[:attach_advisory]).first
unless (a && a.attach_build_list(@build_list))
redirect_to :back, :notice => t('layout.build_lists.publish_fail') and return
redirect_to :back, notice: t('layout.build_lists.publish_fail') and return
end
end
end
@build_list.publisher = current_user
message = @build_list.publish ? 'success' : 'fail'
redirect_to :back, :notice => t("layout.build_lists.publish_#{message}")
redirect_to :back, notice: t("layout.build_lists.publish_#{message}")
end
def publish_into_testing
@build_list.publisher = current_user
message = @build_list.publish_into_testing ? 'success' : 'fail'
redirect_to :back, :notice => t("layout.build_lists.publish_#{message}")
redirect_to :back, notice: t("layout.build_lists.publish_#{message}")
end
def reject_publish
@build_list.publisher = current_user
message = @build_list.reject_publish ? 'success' : 'fail'
redirect_to :back, :notice => t("layout.build_lists.reject_publish_#{message}")
redirect_to :back, notice: t("layout.build_lists.reject_publish_#{message}")
end
def create_container
message = @build_list.publish_container ? 'success' : 'fail'
redirect_to :back, :notice => t("layout.build_lists.create_container_#{message}")
redirect_to :back, notice: t("layout.build_lists.create_container_#{message}")
end
def cancel
message = @build_list.cancel ? 'will_be_canceled' : 'cancel_fail'
redirect_to :back, :notice => t("layout.build_lists.#{message}")
redirect_to :back, notice: t("layout.build_lists.#{message}")
end
def log
render :json => {
:log => @build_list.log(params[:load_lines]),
:building => @build_list.build_started?
render json: {
log: @build_list.log(params[:load_lines]),
building: @build_list.build_started?
}
end
@ -157,13 +157,13 @@ class Projects::BuildListsController < Projects::BaseController
sort_dir = params[:sSortDir_0] == 'asc' ? 'asc' : 'desc'
order = "build_lists.updated_at #{sort_dir}"
@build_lists = @build_lists.paginate(:page => (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, :per_page => params[:iDisplayLength])
@build_lists = @build_lists.paginate(page: (params[:iDisplayStart].to_i/params[:iDisplayLength].to_i).to_i + 1, per_page: params[:iDisplayLength])
@total_build_lists = @build_lists.count
@build_lists = @build_lists.where(:user_id => current_user) if params[:owner_filter] == 'true'
@build_lists = @build_lists.where(:status => [BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH]) if params[:status_filter] == 'true'
@build_lists = @build_lists.where(user_id: current_user) if params[:owner_filter] == 'true'
@build_lists = @build_lists.where(status: [BuildList::BUILD_ERROR, BuildList::FAILED_PUBLISH, BuildList::REJECTED_PUBLISH]) if params[:status_filter] == 'true'
@build_lists = @build_lists.order(order)
render :partial => 'build_lists_ajax', :layout => false
render partial: 'build_lists_ajax', layout: false
end

View File

@ -20,7 +20,7 @@ class Projects::CollaboratorsController < Projects::BaseController
users = users.search(params[:term])
groups = groups.search(params[:term])
end
@collaborators = (users | groups).map{|act| Collaborator.new(:actor => act, :project => @project)}
@collaborators = (users | groups).map{|act| Collaborator.new(actor: act, project: @project)}
respond_with @collaborators do |format|
format.json { render 'index' }
end
@ -31,7 +31,7 @@ class Projects::CollaboratorsController < Projects::BaseController
@collaborator.project = @project
if @collaborator.save
respond_with @collaborator do |format|
format.json { render :partial => 'collaborator', :locals => {:collaborator => @collaborator} }
format.json { render partial: 'collaborator', locals: {collaborator: @collaborator} }
end
else
raise

View File

@ -3,7 +3,7 @@ class Projects::CommentsController < Projects::BaseController
load_and_authorize_resource :project
before_filter :find_commentable
before_filter :find_or_build_comment
load_and_authorize_resource :new => :new_line
load_and_authorize_resource new: :new_line
include CommentsHelper
@ -30,7 +30,7 @@ class Projects::CommentsController < Projects::BaseController
else
[400, view_context.local_alert(@comment.errors.full_messages.join('. '))]
end
render :inline => message, :status => status
render inline: message, status: status
end
def destroy
@ -41,7 +41,7 @@ class Projects::CommentsController < Projects::BaseController
def new_line
@path = view_context.project_commentable_comments_path(@project, @commentable)
render :layout => false
render layout: false
end
protected
@ -52,7 +52,7 @@ class Projects::CommentsController < Projects::BaseController
end
def find_or_build_comment
@comment = params[:id].present? && Comment.where(:automatic => false).find(params[:id]) ||
@comment = params[:id].present? && Comment.where(automatic: false).find(params[:id]) ||
current_user.comments.build(params[:comment]) {|c| c.commentable = @commentable; c.project = @project}
end
end

View File

@ -25,6 +25,6 @@ class Projects::CommitSubscribesController < Projects::BaseController
def find_commit
@commit = @project.repo.commit(params[:commit_id])
@options = {:project_id => @project.id, :subscribeable_id => @commit.id.hex, :subscribeable_type => @commit.class.name, :user_id => current_user.id}
@options = {project_id: @project.id, subscribeable_id: @commit.id.hex, subscribeable_type: @commit.class.name, user_id: current_user.id}
end
end

View File

@ -1,6 +1,6 @@
class Projects::Git::BaseController < Projects::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive, :diff, :tags, :branches] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :index, :blame, :raw, :archive, :diff, :tags, :branches] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
before_filter :set_treeish_and_path

View File

@ -1,6 +1,6 @@
class Projects::Git::BlobsController < Projects::Git::BaseController
before_filter :set_blob
before_filter lambda {authorize! :write, @project}, :only => [:edit, :update]
before_filter lambda {authorize! :write, @project}, only: [:edit, :update]
def show
end
@ -10,12 +10,12 @@ class Projects::Git::BlobsController < Projects::Git::BaseController
def update
if @project.update_file(params[:path], params[:content].gsub("\r", ''),
:message => params[:message].gsub("\r", ''), :actor => current_user, :head => @treeish)
flash[:notice] = t("flash.blob.successfully_updated", :name => params[:path])
message: params[:message].gsub("\r", ''), actor: current_user, head: @treeish)
flash[:notice] = t("flash.blob.successfully_updated", name: params[:path])
else
flash[:notice] = t("flash.blob.updating_error", :name => params[:path])
flash[:notice] = t("flash.blob.updating_error", name: params[:path])
end
redirect_to :action => :show
redirect_to action: :show
end
def blame
@ -25,14 +25,14 @@ class Projects::Git::BlobsController < Projects::Git::BaseController
def raw
repo = Grit::GitRuby::Repository.new(@project.repo.path)
raw = repo.get_raw_object_by_sha1(@blob.id)
send_data raw.content, :type => @blob.content_type, :disposition => @blob.disposition
send_data raw.content, type: @blob.content_type, disposition: @blob.disposition
end
protected
def set_blob
@blob = @tree / @path or raise Grit::NoSuchPathError
redirect_to tree_path(@project, :treeish => @treeish, :path => @path) if @blob.is_a? Grit::Tree
@commit = @project.repo.log(@treeish, @path, :max_count => 1).first
redirect_to tree_path(@project, treeish: @treeish, path: @path) if @blob.is_a? Grit::Tree
@commit = @project.repo.log(@treeish, @path, max_count: 1).first
end
end

View File

@ -3,7 +3,7 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
if @path.present?
@commits = @project.repo.log(@treeish, @path)
else
@commits, @page, @last_page = @project.paginate_commits(@treeish, :page => params[:page])
@commits, @page, @last_page = @project.paginate_commits(@treeish, page: params[:page])
end
end
@ -13,8 +13,8 @@ class Projects::Git::CommitsController < Projects::Git::BaseController
respond_to do |format|
format.html
format.diff { render :text => (@commit.diffs.map(&:diff).join("\n") rescue ''), :content_type => "text/plain" }
format.patch { render :text => (@commit.to_patch rescue ''), :content_type => "text/plain" }
format.diff { render text: (@commit.diffs.map(&:diff).join("\n") rescue ''), content_type: "text/plain" }
format.patch { render text: (@commit.to_patch rescue ''), content_type: "text/plain" }
end
end

View File

@ -1,16 +1,16 @@
class Projects::Git::TreesController < Projects::Git::BaseController
before_filter lambda{redirect_to @project if params[:treeish] == @project.default_branch and params[:path].blank?}, :only => :show
skip_before_filter :set_branch_and_tree, :set_treeish_and_path, :only => :archive
before_filter lambda { raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) }, :only => [:branch, :destroy]
before_filter lambda{redirect_to @project if params[:treeish] == @project.default_branch and params[:path].blank?}, only: :show
skip_before_filter :set_branch_and_tree, :set_treeish_and_path, only: :archive
before_filter lambda { raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) }, only: [:branch, :destroy]
skip_authorize_resource :project, :only => [:destroy, :restore_branch, :create]
before_filter lambda { authorize!(:write, @project) }, :only => [:destroy, :restore_branch, :create]
skip_authorize_resource :project, only: [:destroy, :restore_branch, :create]
before_filter lambda { authorize!(:write, @project) }, only: [:destroy, :restore_branch, :create]
def show
unless request.xhr?
render('empty') and return if @project.is_empty?
@tree = @tree / @path if @path.present?
@commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, :max_count => 1).first
@commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, max_count: 1).first
raise Grit::NoSuchPathError unless @commit
end
end
@ -28,7 +28,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController
redirect_to "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{sha1}"
else
archive = @project.archive_by_treeish_and_format @treeish, format
send_file archive[:path], :disposition => 'attachment', :type => "application/#{format == 'zip' ? 'zip' : 'x-tar-gz'}", :filename => archive[:fullname]
send_file archive[:path], disposition: 'attachment', type: "application/#{format == 'zip' ? 'zip' : 'x-tar-gz'}", filename: archive[:fullname]
end
end
@ -38,7 +38,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController
render :refs_list
else
respond_to do |format|
format.json { render :nothing => true, :status => 422 }
format.json { render nothing: true, status: 422 }
format.html
end
end
@ -46,17 +46,17 @@ class Projects::Git::TreesController < Projects::Git::BaseController
def restore_branch
status = @project.create_branch(@treeish, params[:sha], current_user) ? 200 : 422
render :nothing => true, :status => status
render nothing: true, status: status
end
def create
status = @project.create_branch(params[:new_ref], params[:from_ref], current_user) ? 200 : 422
render :nothing => true, :status => status
render nothing: true, status: status
end
def destroy
status = @branch && @project.delete_branch(@branch, current_user) ? 200 : 422
render :nothing => true, :status => status
render nothing: true, status: status
end
def branches
@ -65,7 +65,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController
render :refs_list
else
respond_to do |format|
format.json { render :nothing => true, :status => 422 }
format.json { render nothing: true, status: 422 }
format.html
end
end

View File

@ -1,7 +1,7 @@
class Projects::HooksController < Projects::BaseController
before_filter :authenticate_user!
load_and_authorize_resource :project
load_and_authorize_resource :hook, :through => :project
load_and_authorize_resource :hook, through: :project
def index
@ -19,7 +19,7 @@ class Projects::HooksController < Projects::BaseController
def create
if @hook.save
redirect_to project_hooks_path(@project, :name => @hook.name), :notice => t('flash.hook.created')
redirect_to project_hooks_path(@project, name: @hook.name), notice: t('flash.hook.created')
else
flash[:error] = t('flash.hook.save_error')
flash[:warning] = @hook.errors.full_messages.join('. ')
@ -29,7 +29,7 @@ class Projects::HooksController < Projects::BaseController
def update
if @hook.update_attributes(params[:hook])
redirect_to project_hooks_path(@project, :name => @hook.name), :notice => t('flash.hook.updated')
redirect_to project_hooks_path(@project, name: @hook.name), notice: t('flash.hook.updated')
else
flash[:error] = t('flash.hook.save_error')
flash[:warning] = @hook.errors.full_messages.join('. ')
@ -39,7 +39,7 @@ class Projects::HooksController < Projects::BaseController
def destroy
@hook.destroy
redirect_to project_hooks_path(@project, :name => @hook.name)
redirect_to project_hooks_path(@project, name: @hook.name)
end
end

View File

@ -1,19 +1,19 @@
class Projects::IssuesController < Projects::BaseController
NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label]
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_resource :project
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id, :only => [:show, :edit, :update, :destroy, :new, :create, :index]
before_filter :load_and_authorize_label, :only => NON_RESTFUL_ACTION
before_filter :find_collaborators, :only => [:new, :create, :show, :search_collaborators]
load_and_authorize_resource :issue, through: :project, find_by: :serial_id, only: [:show, :edit, :update, :destroy, :new, :create, :index]
before_filter :load_and_authorize_label, only: NON_RESTFUL_ACTION
before_filter :find_collaborators, only: [:new, :create, :show, :search_collaborators]
layout false, :only => [:update, :search_collaborators]
layout false, only: [:update, :search_collaborators]
def index(status = 200)
@labels = params[:labels] || []
@issues = @project.issues.without_pull_requests
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'assigned'
@issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == []
@issues = @issues.where(assignee_id: current_user.id) if @is_assigned_to_me = params[:filter] == 'assigned'
@issues = @issues.joins(:labels).where(labels: {name: @labels}) unless @labels == []
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
@issues = @issues.search(params[:search_issue]) if params[:search_issue] !~ /#{t('layout.issues.search')}/
@ -25,11 +25,11 @@ class Projects::IssuesController < Projects::BaseController
@direction = params[:direction] == 'asc' ? :asc : :desc
@issues = @issues.order("issues.#{@sort}_at #{@direction}")
@issues = @issues.includes(:assignee, :user, :pull_request).uniq
.paginate :per_page => 20, :page => params[:page]
.paginate per_page: 20, page: params[:page]
if status == 200
render 'index', :layout => request.xhr? ? 'with_sidebar' : 'application'
render 'index', layout: request.xhr? ? 'with_sidebar' : 'application'
else
render :status => status, :nothing => true
render status: status, nothing: true
end
end
@ -49,7 +49,7 @@ class Projects::IssuesController < Projects::BaseController
redirect_to project_issues_path(@project)
else
flash[:error] = I18n.t("flash.issue.save_error")
render :action => :new
render action: :new
end
end
@ -68,16 +68,16 @@ class Projects::IssuesController < Projects::BaseController
if params[:issue] && status = params[:issue][:status]
@issue.set_close(current_user) if status == 'closed'
@issue.set_open if status == 'open'
render :partial => 'status', :status => (@issue.save ? 200 : 400)
render partial: 'status', status: (@issue.save ? 200 : 400)
elsif params[:issue]
status, message = if @issue.update_attributes(params[:issue])
[200, view_context.markdown(@issue.body)]
else
[400, view_context.local_alert(@issue.errors.full_messages.join('. '))]
end
render :inline => message, :status => status
render inline: message, status: status
else
render :nothing => true, :status => 200
render nothing: true, status: 200
end
end
@ -88,11 +88,11 @@ class Projects::IssuesController < Projects::BaseController
end
def create_label
index(@project.labels.create!(:name => params[:name], :color => params[:color]) ? 200 : 500)
index(@project.labels.create!(name: params[:name], color: params[:color]) ? 200 : 500)
end
def update_label
index(@label.update_attributes(:name => params[:name], :color => params[:color]) ? 200 : 500)
index(@label.update_attributes(name: params[:name], color: params[:color]) ? 200 : 500)
end
def destroy_label
@ -100,7 +100,7 @@ class Projects::IssuesController < Projects::BaseController
end
def search_collaborators
render :partial => 'search_collaborators'
render partial: 'search_collaborators'
end
private

View File

@ -1,8 +1,8 @@
class Projects::ProjectsController < Projects::BaseController
include ProjectsHelper
before_filter :authenticate_user!
load_and_authorize_resource :id_param => :project_name # to force member actions load
before_filter :who_owns, :only => [:new, :create, :mass_import, :run_mass_import]
load_and_authorize_resource id_param: :project_name # to force member actions load
before_filter :who_owns, only: [:new, :create, :mass_import, :run_mass_import]
def index
@projects = Project.accessible_by(current_ability, :membered)
@ -11,8 +11,8 @@ class Projects::ProjectsController < Projects::BaseController
format.html {
@all_projects = @projects
@groups = current_user.groups
@owners = User.where(:id => @projects.where(:owner_type => 'User').uniq.pluck(:owner_id))
@projects = @projects.recent.paginate(:page => params[:page], :per_page => 25)
@owners = User.where(id: @projects.where(owner_type: 'User').uniq.pluck(:owner_id))
@projects = @projects.recent.paginate(page: params[:page], per_page: 25)
}
format.json {
selected_groups = params[:groups] || []
@ -27,7 +27,7 @@ class Projects::ProjectsController < Projects::BaseController
end
def mass_import
@project = Project.new(:mass_import => true)
@project = Project.new(mass_import: true)
end
def run_mass_import
@ -61,7 +61,7 @@ class Projects::ProjectsController < Projects::BaseController
else
flash[:error] = t('flash.project.save_error')
flash[:warning] = @project.errors.full_messages.join('. ')
render :action => :new
render action: :new
end
end
@ -74,7 +74,7 @@ class Projects::ProjectsController < Projects::BaseController
@project.save
flash[:error] = t('flash.project.save_error')
flash[:warning] = @project.errors.full_messages.join('. ')
render :action => :edit
render action: :edit
end
end
@ -88,7 +88,7 @@ class Projects::ProjectsController < Projects::BaseController
owner = (Group.find params[:group] if params[:group].present?) || current_user
authorize! :write, owner if owner.class == Group
if forked = @project.fork(owner, params[:fork_name]) and forked.valid?
redirect_to forked, :notice => t("flash.project.forked")
redirect_to forked, notice: t("flash.project.forked")
else
flash[:warning] = t("flash.project.fork_error")
flash[:error] = forked.errors.full_messages.join("\n")
@ -97,8 +97,8 @@ class Projects::ProjectsController < Projects::BaseController
end
def possible_forks
render :partial => 'projects/git/base/forks', :layout => false,
:locals => { :owner => current_user, :name => (params[:name].presence || @project.name) }
render partial: 'projects/git/base/forks', layout: false,
locals: { owner: current_user, name: (params[:name].presence || @project.name) }
end
def sections
@ -123,18 +123,18 @@ class Projects::ProjectsController < Projects::BaseController
term, limit = params[:term], params[:limit] || 10
items = User.member_of_project(@project)
.where("users.name ILIKE ? OR users.uname ILIKE ?", "%#{term}%", "%#{term}%")
.limit(limit).map { |u| {:value => u.fullname, :label => u.fullname, :id => u.id} }
render :json => items
.limit(limit).map { |u| {value: u.fullname, label: u.fullname, id: u.id} }
render json: items
end
def preview
render :inline => view_context.markdown(params[:text] || ''), :layout => false
render inline: view_context.markdown(params[:text] || ''), layout: false
end
def refs_list
refs = @project.repo.branches_and_tags.map(&:name)
@selected = (refs.include? params[:selected]) ? params[:selected] : @project.default_branch
render :layout => false
render layout: false
end
protected
@ -167,7 +167,7 @@ class Projects::ProjectsController < Projects::BaseController
length = params[:iDisplayLength].to_i
page = start/length + 1
projects.paginate(:page => page, :per_page => length)
projects.paginate(page: page, per_page: length)
else
projects
end

View File

@ -1,11 +1,11 @@
class Projects::PullRequestsController < Projects::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project
load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :except => [:index, :autocomplete_to_project]
load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index, :autocomplete_to_project]
before_filter :find_collaborators, :only => [:new, :create, :show]
load_resource :issue, through: :project, find_by: :serial_id, parent: false, except: [:index, :autocomplete_to_project]
load_and_authorize_resource instance_name: :pull, through: :issue, singleton: true, except: [:index, :autocomplete_to_project]
before_filter :find_collaborators, only: [:new, :create, :show]
def new
to_project = find_destination_project(false)
@ -21,7 +21,7 @@ class Projects::PullRequestsController < Projects::BaseController
@pull.check(false) # don't make event transaction
if @pull.already?
@pull.destroy
flash.now[:warning] = I18n.t('projects.pull_requests.up_to_date', :to_ref => @pull.to_ref, :from_ref => @pull.from_ref)
flash.now[:warning] = I18n.t('projects.pull_requests.up_to_date', to_ref: @pull.to_ref, from_ref: @pull.from_ref)
else
load_diff_commits_data
end
@ -48,7 +48,7 @@ class Projects::PullRequestsController < Projects::BaseController
@pull.check(false) # don't make event transaction
if @pull.already?
@pull.destroy
flash.now[:error] = I18n.t('projects.pull_requests.up_to_date', :to_ref => @pull.to_ref, :from_ref => @pull.from_ref)
flash.now[:error] = I18n.t('projects.pull_requests.up_to_date', to_ref: @pull.to_ref, from_ref: @pull.from_ref)
render :new
else
@pull.send(@pull.status == 'blocked' ? 'block' : @pull.status)
@ -68,7 +68,7 @@ class Projects::PullRequestsController < Projects::BaseController
def merge
status = @pull.merge!(current_user) ? 200 : 422
render :nothing => true, :status => status
render nothing: true, status: status
end
def update
@ -81,7 +81,7 @@ class Projects::PullRequestsController < Projects::BaseController
status = 200
end
end
render :nothing => true, :status => status
render nothing: true, status: status
end
def show
@ -96,7 +96,7 @@ class Projects::PullRequestsController < Projects::BaseController
def index(status = 200)
@issues_with_pull_request = @project.issues.joins(:pull_request)
@issues_with_pull_request = @issues_with_pull_request.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me'
@issues_with_pull_request = @issues_with_pull_request.where(assignee_id: current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me'
@issues_with_pull_request = @issues_with_pull_request.search(params[:search_pull_request]) if params[:search_pull_request] !~ /#{t('layout.pull_requests.search')}/
@opened_issues, @closed_issues = @issues_with_pull_request.not_closed_or_merged.count, @issues_with_pull_request.closed_or_merged.count
@ -110,11 +110,11 @@ class Projects::PullRequestsController < Projects::BaseController
@issues_with_pull_request = @issues_with_pull_request.
includes(:assignee, :user, :pull_request).uniq.
paginate :per_page => 20, :page => params[:page]
paginate per_page: 20, page: params[:page]
if status == 200
render 'index', :layout => request.xhr? ? 'with_sidebar' : 'application'
render 'index', layout: request.xhr? ? 'with_sidebar' : 'application'
else
render :status => status, :nothing => true
render status: status, nothing: true
end
end
@ -125,7 +125,7 @@ class Projects::PullRequestsController < Projects::BaseController
items.concat p.by_owner_and_name(term)
end
items = items.uniq{|i| i.id}.select{|e| e.repo.branches.count > 0}
render :json => json_for_autocomplete_base(items)
render json: json_for_autocomplete_base(items)
end
protected
@ -136,7 +136,7 @@ class Projects::PullRequestsController < Projects::BaseController
def json_for_autocomplete_base items
items.collect do |project|
hash = {:id => project.id.to_s, :label => project.name_with_owner, :value => project.name_with_owner}
hash = {id: project.id.to_s, label: project.name_with_owner, value: project.name_with_owner}
hash[:get_refs_url] = project_refs_list_path(project)
hash
end

View File

@ -2,11 +2,11 @@ class Projects::SubscribesController < Projects::BaseController
before_filter :authenticate_user!
load_and_authorize_resource :project
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id
load_and_authorize_resource :subscribe, :through => :issue, :find_by => :user_id
load_and_authorize_resource :issue, through: :project, find_by: :serial_id
load_and_authorize_resource :subscribe, through: :issue, find_by: :user_id
def create
@subscribe = @issue.subscribes.build(:user_id => current_user.id)
@subscribe = @issue.subscribes.build(user_id: current_user.id)
if @subscribe.save
flash[:notice] = I18n.t("flash.subscribe.saved")
redirect_to :back

View File

@ -5,11 +5,11 @@ class Projects::WikiController < Projects::BaseController
WIKI_OPTIONS = {}
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access']
load_resource :project
before_filter :authorize_read_actions, :only => [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages]
before_filter :authorize_write_actions, :only => [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_filter :authorize_read_actions, only: [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages]
before_filter :authorize_write_actions, only: [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_filter :get_wiki
def index
@ -49,13 +49,13 @@ class Projects::WikiController < Projects::BaseController
@page = @wiki.page(@name)
name = params[:rename] || @name
update_wiki_page(@wiki, @page, params[:content], {:committer => committer}, name, params[:format])
update_wiki_page(@wiki, @page.footer, params[:footer], {:committer => committer}) if params[:footer]
update_wiki_page(@wiki, @page.sidebar, params[:sidebar], {:committer => committer}) if params[:sidebar]
update_wiki_page(@wiki, @page, params[:content], {committer: committer}, name, params[:format])
update_wiki_page(@wiki, @page.footer, params[:footer], {committer: committer}) if params[:footer]
update_wiki_page(@wiki, @page.sidebar, params[:sidebar], {committer: committer}) if params[:sidebar]
committer.commit
flash[:notice] = t('flash.wiki.successfully_updated', :name => @name)
flash[:notice] = t('flash.wiki.successfully_updated', name: @name)
redirect_to project_wiki_path(@project, CGI.escape(@name))
end
@ -67,11 +67,11 @@ class Projects::WikiController < Projects::BaseController
@name = CGI.unescape(params['page'])
format = params['format'].intern
begin
@wiki.write_page(@name, format, params['content'] || '', {:committer => committer}).commit
@wiki.write_page(@name, format, params['content'] || '', {committer: committer}).commit
redirect_to project_wiki_path(@project, CGI.escape(@name))
rescue Gollum::DuplicatePageError => e
flash[:error] = t("flash.wiki.duplicate_page", :name => @name)
render :action => :new
rescue Gollum:DuplicatePageError: e
flash[:error] = t("flash.wiki.duplicate_page", name: @name)
render action: :new
end
end
@ -79,10 +79,10 @@ class Projects::WikiController < Projects::BaseController
@name = CGI.unescape(params[:id])
page = @wiki.page(@name)
if page
@wiki.delete_page(page, {:committer => committer}).commit
@wiki.delete_page(page, {committer: committer}).commit
flash[:notice] = t("flash.wiki.page_successfully_removed")
else
flash[:notice] = t("flash.wiki.page_not_found", :name => params[:id])
flash[:notice] = t("flash.wiki.page_not_found", name: params[:id])
end
redirect_to project_wiki_index_path(@project)
end
@ -149,7 +149,7 @@ class Projects::WikiController < Projects::BaseController
sha2 = params[:sha2]
sha2 = nil if params[:sha2] == 'prev'
if c = @wiki.revert_page(@page, sha1, sha2, {:committer => committer}) and c.commit
if c = @wiki.revert_page(@page, sha1, sha2, {committer: committer}) and c.commit
flash[:notice] = t("flash.wiki.revert_success")
redirect_to project_wiki_path(@project, CGI.escape(@name))
else
@ -170,7 +170,7 @@ class Projects::WikiController < Projects::BaseController
sha1 = params[:sha1]
sha2 = params[:sha2]
sha2 = nil if sha2 == 'prev'
if c = @wiki.revert_commit(sha1, sha2, {:committer => committer}) and c.commit
if c = @wiki.revert_commit(sha1, sha2, {committer: committer}) and c.commit
flash[:notice] = t("flash.wiki.revert_success")
redirect_to project_wiki_index_path(@project)
else
@ -218,7 +218,7 @@ class Projects::WikiController < Projects::BaseController
def get_wiki
@wiki = Gollum::Wiki.new(@project.wiki_path,
WIKI_OPTIONS.merge(:base_path => project_wiki_index_path(@project)))
WIKI_OPTIONS.merge(base_path: project_wiki_index_path(@project)))
end
# This method was grabbed from sinatra application, shipped with Gollum gem.
@ -247,14 +247,14 @@ class Projects::WikiController < Projects::BaseController
msg << " (#{params['format']})" if params['format']
end
msg = 'Unhandled action' if !msg || msg.empty?
{ :message => msg }
{ message: msg }
end
def committer
unless @committer
p = commit_message.merge({:name => current_user.uname, :email => current_user.email})
p = commit_message.merge({name: current_user.uname, email: current_user.email})
@committer = Gollum::Committer.new(@wiki, p)
GitHook.perform_later!(:notification, :process, {:project_id => @project.id, :actor_name => @committer.actor.name, :commit_sha => @committer.commit})
GitHook.perform_later!(:notification, :process, {project_id: @project.id, actor_name: @committer.actor.name, commit_sha: @committer.commit})
end
@committer
end
@ -265,12 +265,12 @@ class Projects::WikiController < Projects::BaseController
@editable = can?(:write, @project)
render :show
elsif file = @wiki.file(@name)
render :text => file.raw_data, :content_type => file.mime_type
render text: file.raw_data, content_type: file.mime_type
elsif can? :write, @project
@new = true
render :new
else
redirect_to :action => :index #forbidden_path
redirect_to action: :index #forbidden_path
end
end

View File

@ -8,7 +8,7 @@ class SearchController < ApplicationController
Search.by_term_and_type(
@query,
@type,
{:page => params[:page]}
{page: params[:page]}
).each do |k, v|
var = :"@#{k}"
instance_variable_set var, v unless instance_variable_defined?(var)

View File

@ -13,7 +13,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def passthru
render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
render file: "#{Rails.root}/public/404.html", status: 404, layout: false
end
private
@ -22,8 +22,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
provider = kind.downcase
@user = find_for_ouath(env["omniauth.auth"], current_user)
if @user && @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => action_name.classify
sign_in_and_redirect @user, :event => :authentication
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: action_name.classify
sign_in_and_redirect @user, event: :authentication
else
session["devise.#{provider}_data"] = env["omniauth.auth"]
redirect_to new_user_registration_url

View File

@ -1,5 +1,5 @@
class Users::ProfileController < Users::BaseController
skip_before_filter :authenticate_user!, :only => :show if APP_CONFIG['anonymous_access']
skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access']
def show
@path, page = user_path, params[:page].to_i
@ -11,7 +11,7 @@ class Users::ProfileController < Users::BaseController
else
@projects = @projects.by_visibilities('hidden').accessible_by(current_ability, :read)
end
render :partial => 'shared/profile_projects', :layout => nil, :locals => {:projects => paginate_projects(page)}
render partial: 'shared/profile_projects', layout: nil, locals: {projects: paginate_projects(page)}
else
@projects = paginate_projects(page)
end
@ -20,6 +20,6 @@ class Users::ProfileController < Users::BaseController
protected
def paginate_projects(page)
@projects.paginate(:page => (page>0 ? page : nil), :per_page => 24)
@projects.paginate(page: (page>0 ? page : nil), per_page: 24)
end
end

View File

@ -3,7 +3,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
def create
# Try stop bots
if params[:recaptcha_response_field].present?
respond_with(resource, :location => after_inactive_sign_up_path_for(resource))
respond_with(resource, location: after_inactive_sign_up_path_for(resource))
return
end
super

View File

@ -34,7 +34,7 @@ class Users::SettingsController < Users::BaseController
else
flash[:error] = t('flash.user.save_error')
flash[:warning] = @user.errors.full_messages.join('. ')
render(:action => :private)
render(action: :private)
end
end
end

View File

@ -1,6 +1,6 @@
class Users::UsersController < Users::BaseController
skip_before_filter :authenticate_user!, :only => [:allowed, :check, :discover]
before_filter :find_user_by_key, :only => [:allowed, :discover]
skip_before_filter :authenticate_user!, only: [:allowed, :check, :discover]
before_filter :find_user_by_key, only: [:allowed, :discover]
def allowed
owner_name, project_name = params[:project].split '/'
@ -11,15 +11,15 @@ class Users::UsersController < Users::BaseController
when 'git-receive-pack'
then :write
end
render :inline => (!@user.access_locked? && Ability.new(@user).can?(action, project)).to_s
render inline: (!@user.access_locked? && Ability.new(@user).can?(action, project)).to_s
end
def check
render :nothing => true
render nothing: true
end
def discover
render :json => {:name => @user.name}.to_json
render json: {name: @user.name}.to_json
end
protected

View File

@ -1,6 +1,6 @@
module ActivityFeedsHelper
def render_activity_feed(activity_feed)
render activity_feed.partial, activity_feed.data.merge(:activity_feed => activity_feed)
render activity_feed.partial, activity_feed.data.merge(activity_feed: activity_feed)
end
def get_feed_title_from_content(content)

View File

@ -1,12 +1,12 @@
module AdvisoriesHelper
def advisories_select_options(advisories, opts = {:class => 'popoverable'})
def_values = [[t("layout.advisories.no_"), 'no'], [t("layout.advisories.new"), 'new'], [t("layout.advisories.existing"), 'existing', {:class => 'advisory_id'}]]
def advisories_select_options(advisories, opts = {class: 'popoverable'})
def_values = [[t("layout.advisories.no_"), 'no'], [t("layout.advisories.new"), 'new'], [t("layout.advisories.existing"), 'existing', {class: 'advisory_id'}]]
options_for_select(def_values, def_values.first)
end
def advisory_id_for_hint
sprintf(Advisory::ID_STRING_TEMPLATE, :type => "{#{Advisory::TYPES.values.join(',')}}",
:year => 'YYYY', :id => 'XXXX')
sprintf(Advisory::ID_STRING_TEMPLATE, type: "{#{Advisory::TYPES.values.join(',')}}",
year: 'YYYY', id: 'XXXX')
end
def construct_ref_link(ref)

View File

@ -39,18 +39,18 @@ module ApplicationHelper
def local_alert(text, type = 'error')
html = "<div class='flash'><div class='alert #{type}'> #{text}"
html << link_to('×', '#', :class => 'close close-alert', 'data-dismiss' => 'alert')
html << link_to('×', '#', class: 'close close-alert', 'data-dismiss' => 'alert')
html << '</div></div>'
end
# Why 42? Because it is the Answer!
def short_message(message, length = 42)
truncate(message, :length => length, :omission => '…')
truncate(message, length: length, omission: '…')
end
def datetime_moment(date, options = {})
tag = options[:tag] || :div
klass = "datetime_moment #{options[:class]}"
content_tag(tag, nil, :class => klass, :title => date.strftime('%Y-%m-%d %H:%M:%S UTC'), :origin_datetime => date.to_i)
content_tag(tag, nil, class: klass, title: date.strftime('%Y-%m-%d %H:%M:%S UTC'), origin_datetime: date.to_i)
end
end

View File

@ -26,9 +26,9 @@ module BuildListsHelper
"#{r.platform.name}/#{r.name}",
r.id,
{
:publish_without_qa => r.publish_without_qa? ? 1 : 0,
:platform_id => r.platform.id,
:default_arches => (r.platform.platform_arch_settings.by_default.pluck(:arch_id).presence || Arch.where(:name => Arch::DEFAULT).pluck(:id)).join(' ')
publish_without_qa: r.publish_without_qa? ? 1 : 0,
platform_id: r.platform.id,
default_arches: (r.platform.platform_arch_settings.by_default.pluck(:arch_id).presence || Arch.where(name: Arch::DEFAULT).pluck(:id)).join(' ')
}
]
end.sort_by { |col| col[0] }
@ -68,10 +68,10 @@ module BuildListsHelper
def build_list_classified_update_types
advisoriable = BuildList::RELEASE_UPDATE_TYPES.map do |el|
[el, {:class => 'advisoriable'}]
[el, {class: 'advisoriable'}]
end
nonadvisoriable = (BuildList::UPDATE_TYPES - BuildList::RELEASE_UPDATE_TYPES).map do |el|
[el, {:class => 'nonadvisoriable'}]
[el, {class: 'nonadvisoriable'}]
end
return advisoriable + nonadvisoriable
@ -82,8 +82,8 @@ module BuildListsHelper
if item.version =~ /^[\da-z]+$/ && item.name == item.build_list.project.name
bl = item.build_list
{
:text => str_version ? "#{shortest_hash_id item.version, hash_size}" : shortest_hash_id(item.version, hash_size),
:href => commit_path(bl.project.owner, bl.project, item.version)
text: str_version ? "#{shortest_hash_id item.version, hash_size}" : shortest_hash_id(item.version, hash_size),
href: commit_path(bl.project.owner, bl.project, item.version)
}
else
{}

View File

@ -6,11 +6,11 @@ module CommitHelper
res << "<tr>"
res << "<td><a href='#diff-#{ind}'>#{h(filename.rtruncate 120)}</a></td>"
res << "<td class='diffstat'>"
res << I18n.t("layout.projects.inline_changes_count", :count => total).strip +
res << I18n.t("layout.projects.inline_changes_count", count: total).strip +
" (" +
I18n.t("layout.projects.inline_additions_count", :count => adds).strip +
I18n.t("layout.projects.inline_additions_count", count: adds).strip +
", " +
I18n.t("layout.projects.inline_deletions_count", :count => deletes).strip +
I18n.t("layout.projects.inline_deletions_count", count: deletes).strip +
")"
res << "</td>"
ind +=1
@ -25,7 +25,7 @@ module CommitHelper
# end
def commit_date(date)
I18n.localize(date, { :format => "%d %B %Y" })
I18n.localize(date, { format: "%d %B %Y" })
end
def short_hash_id(id)
@ -39,7 +39,7 @@ module CommitHelper
def commit_author_link(author)
name = author.name
email = author.email
u = User.where(:email => email).first
u = User.where(email: email).first
u.present? ? link_to(name, user_path(u)) : mail_to(email, name)
end

View File

@ -8,9 +8,9 @@ module ContentsHelper
compound_path = ''
paths.map do |p|
compound_path << p << '/' if p != '/'
link_to(platform_content_path(platform, compound_path), {:remote => true}) do
content_tag(:span, p, {:class => 'text'}) +
content_tag(:span, '', {:class => 'arrow-right'})
link_to(platform_content_path(platform, compound_path), {remote: true}) do
content_tag(:span, p, {class: 'text'}) +
content_tag(:span, '', {class: 'arrow-right'})
end
end.join.html_safe
end

View File

@ -6,11 +6,11 @@ module DiffHelper
res << "<tr>"
res << "<td>#{link_to stat.filename.rtruncate(120), "#{path}#diff-#{ind}"}</td>"
res << "<td class='diffstat'>"
res << I18n.t("layout.projects.inline_changes_count", :count => stat.additions + stat.deletions).strip +
res << I18n.t("layout.projects.inline_changes_count", count: stat.additions + stat.deletions).strip +
" (" +
I18n.t("layout.projects.inline_additions_count", :count => stat.additions).strip +
I18n.t("layout.projects.inline_additions_count", count: stat.additions).strip +
", " +
I18n.t("layout.projects.inline_deletions_count", :count => stat.deletions).strip +
I18n.t("layout.projects.inline_deletions_count", count: stat.deletions).strip +
")"
res << "</td>"
end
@ -34,7 +34,7 @@ module DiffHelper
elsif @commit
commit_path @project, @commit
end
prepare(args.merge({:filepath => filepath, :comments => comments, :in_discussion => in_discussion}))
prepare(args.merge({filepath: filepath, comments: comments, in_discussion: in_discussion}))
res = '<table class="diff inline" cellspacing="0" cellpadding="0" ng-non-bindable>'
res << '<tbody>'
@ -228,7 +228,7 @@ module DiffHelper
def line_comment
return if @no_commit_comment || (@in_discussion && @add_reply_id && @line_comments[0].data[:line].to_i != @num_line)
link_to image_tag('line_comment.png', :alt => t('layout.comments.new_header')), new_comment_path, :class => 'add_line-comment' if current_user
link_to image_tag('line_comment.png', alt: t('layout.comments.new_header')), new_comment_path, class: 'add_line-comment' if current_user
end
def render_line_comments
@ -251,17 +251,17 @@ module DiffHelper
<td>"
comments.each do |comment|
res << "<div class='line-comments'>
#{render 'projects/comments/comment', :comment => comment, :data => {:project => @project, :commentable => @commentable, :add_anchor => 'inline', :in_discussion => @in_discussion}}
#{render 'projects/comments/comment', comment: comment, data: {project: @project, commentable: @commentable, add_anchor: 'inline', in_discussion: @in_discussion}}
</div>"
end
res << link_to(t('layout.comments.new_inline'), new_comment_path, :class => 'new_inline_comment button') if current_user
res << link_to(t('layout.comments.new_inline'), new_comment_path, class: 'new_inline_comment button') if current_user
res << "</td></tr>"
end
def new_comment_path
hash = {:path => @filepath, :line => @num_line}
hash = {path: @filepath, line: @num_line}
if @commentable.is_a? Issue
project_new_line_pull_comment_path(@project, @commentable, hash.merge({:in_reply => @add_reply_id}))
project_new_line_pull_comment_path(@project, @commentable, hash.merge({in_reply: @add_reply_id}))
elsif @commentable.is_a? Grit::Commit
new_line_commit_comment_path(@project, @commentable, hash)
end

View File

@ -69,19 +69,19 @@ module GitHelper
def branch_selector_options(project)
p, tag_enabled = params.dup, !(controller_name == 'trees' && action_name == 'branches')
p.delete(:path) if p[:path].present? # to root path
p.merge!(:project_id => project.id, :treeish => project.default_branch).delete(:id) unless p[:treeish].present?
p.merge!(project_id: project.id, treeish: project.default_branch).delete(:id) unless p[:treeish].present?
current = url_for(p).split('?', 2).first
res = []
if params[:treeish].present? && !project.repo.branches_and_tags.map(&:name).include?(params[:treeish])
res << [I18n.t('layout.git.repositories.commits'), [params[:treeish].truncate(20)]]
end
linking = Proc.new {|name| [name.truncate(20), url_for(p.merge :treeish => name).split('?', 2).first]}
linking = Proc.new {|name| [name.truncate(20), url_for(p.merge treeish: name).split('?', 2).first]}
res << [I18n.t('layout.git.repositories.branches'), project.repo.branches.map(&:name).sort.map(&linking)]
if tag_enabled
res << [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name).sort.map(&linking)]
else
res << [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name).sort.map {|name| [name.truncate(20), {:disabled => true}]}]
res << [I18n.t('layout.git.repositories.tags'), project.repo.tags.map(&:name).sort.map {|name| [name.truncate(20), {disabled: true}]}]
end
grouped_options_for_select(res, current)
end

View File

@ -1,7 +1,7 @@
module MassBuildHelper
def link_to_list platform, mass_build, which
link_to t("layout.mass_builds.#{which}"),
get_list_platform_mass_build_path(@platform, mass_build, :kind => which, :format => :txt),
:target => "_blank" if can?(:get_list, mass_build)
get_list_platform_mass_build_path(@platform, mass_build, kind: which, format: :txt),
target: "_blank" if can?(:get_list, mass_build)
end
end

View File

@ -6,7 +6,7 @@ module PaginateHelper
per_page = 100 if per_page >100
page = params[:page].to_i
page = nil if page == 0
{:page => page, :per_page => per_page}
{page: page, per_page: per_page}
end
def angularjs_will_paginate(collection_or_options = nil, options = {})

View File

@ -1,20 +1,20 @@
module ProjectsHelper
def options_for_filters(all_projects, groups, owners)
projects_count_by_groups = all_projects.where(:owner_id => groups, :owner_type => 'Group').
projects_count_by_groups = all_projects.where(owner_id: groups, owner_type: 'Group').
group(:owner_id).count
projects_count_by_owners = all_projects.where(:owner_id => owners, :owner_type => 'User').
projects_count_by_owners = all_projects.where(owner_id: owners, owner_type: 'User').
group(:owner_id).count
(groups + owners).map do |o|
class_name = o.class.name
{
:id => "#{class_name.downcase}-#{o.id}",
:color => '0054a6',
:selected => false,
:check_box_name => class_name.downcase.pluralize,
:check_box_value => o.id,
:name => content_tag(:div, content_tag(:span, o.uname, :class => class_name.downcase)),
:uname => o.uname, # only for sorting
:count => o.is_a?(User) ? projects_count_by_owners[o.id] : projects_count_by_groups[o.id]
id: "#{class_name.downcase}-#{o.id}",
color: '0054a6',
selected: false,
check_box_name: class_name.downcase.pluralize,
check_box_value: o.id,
name: content_tag(:div, content_tag(:span, o.uname, class: class_name.downcase)),
uname: o.uname, # only for sorting
count: o.is_a?(User) ? projects_count_by_owners[o.id] : projects_count_by_groups[o.id]
}
end.sort_by{ |f| f[:uname] }
end

View File

@ -9,13 +9,13 @@ module PullRequestHelper
def pull_status_label pull_status, options = {}
statuses = {'ready' => 'success', 'closed' => 'important', 'merged' => 'important', 'blocked' => 'warning'}
content_tag :span, t("projects.pull_requests.statuses.#{pull_status}"), options.merge(:class => "state label-bootstrap label-#{statuses[pull_status]}")
content_tag :span, t("projects.pull_requests.statuses.#{pull_status}"), options.merge(class: "state label-bootstrap label-#{statuses[pull_status]}")
end
def pull_status pull
if %w(blocked merged closed ready open).include? pull.status
t("projects.pull_requests.#{pull.status}", :user => pull.issue.closer.try(:uname), :to_ref => show_ref(pull, 'to'),
:from_ref => show_ref(pull, 'from'), :time => pull.issue.closed_at).html_safe
t("projects.pull_requests.#{pull.status}", user: pull.issue.closer.try(:uname), to_ref: show_ref(pull, 'to'),
from_ref: show_ref(pull, 'from'), time: pull.issue.closed_at).html_safe
else
raise "pull id (#{pull.id}) wrong status #{pull.status} "
end

View File

@ -1,7 +1,7 @@
module UsersHelper
def avatar_url_by_email(email, size = :small)
avatar_url(User.where(:email => email).first || User.new(:email => email), size)
avatar_url(User.where(email: email).first || User.new(email: email), size)
end
def avatar_url(subject, size = :small)

View File

@ -22,9 +22,9 @@ module WikiHelper
def editor_path(project, name)
if @new
url_for(:controller => :wiki, :action => :create, :project_id => project.id)
url_for(controller: :wiki, action: :create, project_id: project.id)
else
url_for(:controller => :wiki, :action => :update, :project_id => project.id, :id => name)
url_for(controller: :wiki, action: :update, project_id: project.id, id: name)
end
end

View File

@ -1,10 +1,10 @@
class FeedbackMailer < ActionMailer::Base
FBM_CONFIG = APP_CONFIG['feedback']
default :to => FBM_CONFIG['email'],
:cc => FBM_CONFIG['cc'],
:bcc => FBM_CONFIG['bcc']
default_url_options.merge!(:protocol => 'https') if APP_CONFIG['mailer_https_url']
default to: FBM_CONFIG['email'],
cc: FBM_CONFIG['cc'],
bcc: FBM_CONFIG['bcc']
default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url']
include Resque::Mailer # send email async
@ -14,7 +14,7 @@ class FeedbackMailer < ActionMailer::Base
from = "#{@data.name} <#{@data.email}>"
subj = prepare_subject(@data.subject)
mail :from => from, :subject => subj
mail from: from, subject: subj
end
protected
@ -31,5 +31,4 @@ class FeedbackMailer < ActionMailer::Base
def affix(affixes)
' %s ' % Array(affixes).map{|e| "[#{e}]"}.join
end
end

View File

@ -2,17 +2,17 @@ class UserMailer < ActionMailer::Base
add_template_helper ActivityFeedsHelper
add_template_helper CommitHelper
default :from => "\"#{APP_CONFIG['project_name']}\" <#{APP_CONFIG['do-not-reply-email']}>"
default_url_options.merge!(:protocol => 'https') if APP_CONFIG['mailer_https_url']
default from: "\"#{APP_CONFIG['project_name']}\" <#{APP_CONFIG['do-not-reply-email']}>"
default_url_options.merge!(protocol: 'https') if APP_CONFIG['mailer_https_url']
include Resque::Mailer # send email async
def new_user_notification(user)
@user = user
mail(
:to => email_with_name(user, user.email),
:subject => I18n.t("notifications.subjects.new_user_notification",
:project_name => APP_CONFIG['project_name'])
to: email_with_name(user, user.email),
subject: I18n.t("notifications.subjects.new_user_notification",
project_name: APP_CONFIG['project_name'])
) do |format|
format.html
end
@ -23,9 +23,9 @@ class UserMailer < ActionMailer::Base
subject = @comment.issue_comment? ? subject_for_issue(@comment.commentable) :
I18n.t('notifications.subjects.new_commit_comment_notification')
mail(
:to => email_with_name(user, user.email),
:subject => subject,
:from => email_with_name(comment.user)
to: email_with_name(user, user.email),
subject: subject,
from: email_with_name(comment.user)
) do |format|
format.html
end
@ -34,9 +34,9 @@ class UserMailer < ActionMailer::Base
def new_issue_notification(issue, user)
@user, @issue = user, issue
mail(
:to => email_with_name(user, user.email),
:subject => subject_for_issue(issue, true),
:from => email_with_name(issue.user)
to: email_with_name(user, user.email),
subject: subject_for_issue(issue, true),
from: email_with_name(issue.user)
) do |format|
format.html
end
@ -45,8 +45,8 @@ class UserMailer < ActionMailer::Base
def issue_assign_notification(issue, user)
@issue = issue
mail(
:to => email_with_name(user, user.email),
:subject => subject_for_issue(@issue)
to: email_with_name(user, user.email),
subject: subject_for_issue(@issue)
) do |format|
format.html
end
@ -59,11 +59,11 @@ class UserMailer < ActionMailer::Base
subject = "[№ #{build_list.id}] "
subject << (build_list.project ? build_list.project.name_with_owner : t("layout.projects.unexisted_project"))
subject << " - #{build_list.human_status} "
subject << I18n.t("notifications.subjects.for_arch", :arch => @build_list.arch.name)
subject << I18n.t("notifications.subjects.for_arch", arch: @build_list.arch.name)
mail(
:to => email_with_name(user, user.email),
:subject => subject,
:from => email_with_name(build_list.publisher || build_list.user)
to: email_with_name(user, user.email),
subject: subject,
from: email_with_name(build_list.publisher || build_list.user)
) do |format|
format.html
end
@ -73,8 +73,8 @@ class UserMailer < ActionMailer::Base
set_locale register_request
@register_request = register_request
mail(
:to => register_request.email,
:subject => I18n.t("notifications.subjects.invite_approve_notification")
to: register_request.email,
subject: I18n.t("notifications.subjects.invite_approve_notification")
) do |format|
format.html
end
@ -83,20 +83,20 @@ class UserMailer < ActionMailer::Base
def git_delete_branch_notification(user, options)
set_locale user
mail(
:to => user.email,
:subject => I18n.t('notifications.subjects.update_code', :project_name => "#{options[:project_owner]}/#{options[:project_name]}")
to: user.email,
subject: I18n.t('notifications.subjects.update_code', project_name: "#{options[:project_owner]}/#{options[:project_name]}")
) do |format|
format.html { render 'git_delete_branch_notification', :locals => options }
format.html { render 'git_delete_branch_notification', locals: options }
end
end
def git_new_push_notification(user, options)
set_locale user
mail(
:to => user.email,
:subject => I18n.t('notifications.subjects.update_code', :project_name => "#{options[:project_owner]}/#{options[:project_name]}")
to: user.email,
subject: I18n.t('notifications.subjects.update_code', project_name: "#{options[:project_owner]}/#{options[:project_name]}")
) do |format|
format.html { render 'git_new_push_notification', :locals => options }
format.html { render 'git_new_push_notification', locals: options }
end
end

View File

@ -12,21 +12,21 @@ class Ability
@user = user
# Shared rights between guests and registered users
can [:show, :archive], Project, :visibility => 'open'
can :get_id, Project, :visibility => 'open' # api
can [:show, :archive], Project, visibility: 'open'
can :get_id, Project, visibility: 'open' # api
can(:refs_list, Project) {|project| can? :show, project}
can :read, Issue, :project => {:visibility => 'open'}
can [:read, :commits, :files], PullRequest, :to_project => {:visibility => 'open'}
can [:read, :log, :everything], BuildList, :project => {:visibility => 'open'}
can [:read, :log], ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
can :read, Issue, project: {visibility: 'open'}
can [:read, :commits, :files], PullRequest, to_project: {visibility: 'open'}
can [:read, :log, :everything], BuildList, project: {visibility: 'open'}
can [:read, :log], ProductBuildList#, product: {platform: {visibility: 'open'}} # double nested hash don't work
can [:read, :search], Advisory
# Platforms block
can [:show, :members, :advisories], Platform, :visibility => 'open'
can :platforms_for_build, Platform, :visibility => 'open', :platform_type => 'main'
can [:show, :members, :advisories], Platform, visibility: 'open'
can :platforms_for_build, Platform, visibility: 'open', platform_type: 'main'
can([:read, :get_list], MassBuild) {|mass_build| can?(:show, mass_build.save_to_platform) }
can [:read, :projects_list, :projects], Repository, :platform => {:visibility => 'open'}
can :read, Product, :platform => {:visibility => 'open'}
can [:read, :projects_list, :projects], Repository, platform: {visibility: 'open'}
can :read, Product, platform: {visibility: 'open'}
can :show, Group
can :show, User
@ -38,32 +38,32 @@ class Ability
if user.admin?
can :manage, :all
# Protection
cannot :approve, RegisterRequest, :approved => true
cannot :reject, RegisterRequest, :rejected => true
cannot :approve, RegisterRequest, approved: true
cannot :reject, RegisterRequest, rejected: true
cannot [:destroy, :create], Subscribe
# Act admin as simple user
cannot :read, Product, :platform => {:platform_type => 'personal'}
cannot :read, Product, platform: {platform_type: 'personal'}
cannot [:owned, :related], [BuildList, Platform]
cannot :membered, Project # list products which user members
end
if user.user?
can :edit, User, :id => user.id
can :edit, User, id: user.id
can [:read, :create], Group
can [:update, :manage_members, :members, :add_member, :remove_member, :update_member], Group do |group|
group.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin') # or group.owner_id = user.id
group.actors.exists?(actor_type: 'User', actor_id: user.id, role: 'admin') # or group.owner_id = user.id
end
can :write, Group do |group|
group.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => ['writer', 'admin'])
group.actors.exists?(actor_type: 'User', actor_id: user.id, role: ['writer', 'admin'])
end
can :destroy, Group, :owner_id => user.id
can :destroy, Group, owner_id: user.id
can :remove_user, Group
can :create, Project
can([:mass_import, :run_mass_import], Project) if user.platforms.main.find{ |p| local_admin?(p) }.present?
can :read, Project, :visibility => 'open'
can [:read, :archive, :membered, :get_id], Project, :owner_type => 'User', :owner_id => user.id
can [:read, :archive, :membered, :get_id], Project, :owner_type => 'Group', :owner_id => user_group_ids
can :read, Project, visibility: 'open'
can [:read, :archive, :membered, :get_id], Project, owner_type: 'User', owner_id: user.id
can [:read, :archive, :membered, :get_id], Project, owner_type: 'Group', owner_id: user_group_ids
can([:read, :archive, :membered, :get_id], Project, read_relations_for('projects')) {|project| local_reader? project}
can(:write, Project) {|project| local_writer? project} # for grack
can [:update, :sections, :manage_collaborators, :autocomplete_maintainers, :add_member, :remove_member, :update_member, :members], Project do |project|
@ -72,15 +72,15 @@ class Ability
can(:fork, Project) {|project| can? :read, project}
can(:fork, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner}
can(:destroy, Project) {|project| owner? project}
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')}
can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(actor_type: 'User', actor_id: user.id, role: 'admin')}
can :remove_user, Project
can :preview, Project
can([:read, :create, :edit, :destroy, :update], Hook) {|hook| can?(:edit, hook.project)}
can [:read, :log, :owned, :everything], BuildList, :user_id => user.id
can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id}
can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user_group_ids}
can [:read, :log, :owned, :everything], BuildList, user_id: user.id
can [:read, :log, :related, :everything], BuildList, project: {owner_type: 'User', owner_id: user.id}
can [:read, :log, :related, :everything], BuildList, project: {owner_type: 'Group', owner_id: user_group_ids}
can([:read, :log, :everything, :list], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project}
can(:publish_into_testing, BuildList) { |build_list| can?(:create, build_list) && build_list.save_to_platform.main? }
@ -92,7 +92,7 @@ class Ability
can(:publish, BuildList) do |build_list|
if build_list.build_published?
local_admin?(build_list.save_to_platform) || build_list.save_to_repository.members.exists?(:id => user.id)
local_admin?(build_list.save_to_platform) || build_list.save_to_repository.members.exists?(id: user.id)
else
build_list.save_to_repository.publish_without_qa ?
can?(:write, build_list.project) : local_admin?(build_list.save_to_platform)
@ -107,23 +107,23 @@ class Ability
end
can([:cancel, :create_container], BuildList) {|build_list| can?(:write, build_list.project)}
can [:read, :owned, :related, :members], Platform, :owner_type => 'User', :owner_id => user.id
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user_group_ids
can [:read, :owned, :related, :members], Platform, owner_type: 'User', owner_id: user.id
can [:read, :related, :members], Platform, owner_type: 'Group', owner_id: user_group_ids
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
can [:read, :related], Platform, :id => user.repositories.pluck(:platform_id)
can [:read, :related], Platform, id: user.repositories.pluck(:platform_id)
can([:update, :destroy, :change_visibility], Platform) {|platform| owner?(platform) }
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
can([:create, :publish], MassBuild) {|mass_build| owner?(mass_build.save_to_platform) || local_admin?(mass_build.save_to_platform)}
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.save_to_platform) || local_admin?(mass_build.save_to_platform)) && !mass_build.stop_build}
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'Group', :owner_id => user_group_ids}
can [:read, :projects_list, :projects], Repository, platform: {owner_type: 'User', owner_id: user.id}
can [:read, :projects_list, :projects], Repository, platform: {owner_type: 'Group', owner_id: user_group_ids}
can([:read, :projects_list, :projects], Repository, read_relations_for('repositories')) {|repository| can? :show, repository.platform}
can([:read, :projects_list, :projects], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project, :regenerate_metadata, :sync_lock_file, :add_repo_lock_file, :remove_repo_lock_file], Repository) {|repository| local_admin? repository.platform}
can([:remove_members, :remove_member, :add_member, :signatures, :packages], Repository) {|repository| owner?(repository.platform) || local_admin?(repository.platform)}
can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(:id => user.id)}
can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(id: user.id)}
can(:clear, Platform) {|platform| owner?(platform) && platform.personal?}
can(:regenerate_metadata, Platform) {|platform| owner?(platform) || local_admin?(platform)}
can([:settings, :destroy, :edit, :update], Repository) {|repository| owner? repository.platform}
@ -132,26 +132,26 @@ class Ability
can([:read, :create, :withdraw], Token) {|token| local_admin?(token.subject)}
can :read, Product, :platform => {:owner_type => 'User', :owner_id => user.id, :platform_type => 'main'}
can :read, Product, :platform => {:owner_type => 'Group', :owner_id => user_group_ids, :platform_type => 'main'}
can :read, Product, platform: {owner_type: 'User', owner_id: user.id, platform_type: 'main'}
can :read, Product, platform: {owner_type: 'Group', owner_id: user_group_ids, platform_type: 'main'}
can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.main?}
can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.main?}
can([:create, :cancel, :update], ProductBuildList) {|pbl| can?(:update, pbl.product)}
can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)}
can [:read, :create], PrivateUser, :platform => {:owner_type => 'User', :owner_id => user.id}
can [:read, :create], PrivateUser, :platform => {:owner_type => 'Group', :owner_id => user_group_ids}
can [:read, :create], PrivateUser, platform: {owner_type: 'User', owner_id: user.id}
can [:read, :create], PrivateUser, platform: {owner_type: 'Group', owner_id: user_group_ids}
can :read, Issue, :project => {:owner_type => 'User', :owner_id => user.id}
can :read, Issue, :project => {:owner_type => 'Group', :owner_id => user_group_ids}
can :read, Issue, project: {owner_type: 'User', owner_id: user.id}
can :read, Issue, project: {owner_type: 'Group', owner_id: user_group_ids}
can(:read, Issue, read_relations_for('issues', 'projects')) {|issue| can? :read, issue.project rescue nil}
can(:create, Issue) {|issue| can? :read, issue.project}
can(:update, Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)}
cannot :manage, Issue, :project => {:has_issues => false} # switch off issues
cannot :manage, Issue, project: {has_issues: false} # switch off issues
can [:read, :commits, :files], PullRequest, :to_project => {:owner_type => 'User', :owner_id => user.id}
can [:read, :commits, :files], PullRequest, :to_project => {:owner_type => 'Group', :owner_id => user_group_ids}
can [:read, :commits, :files], PullRequest, to_project: {owner_type: 'User', owner_id: user.id}
can [:read, :commits, :files], PullRequest, to_project: {owner_type: 'Group', owner_id: user_group_ids}
can([:read, :commits, :files], PullRequest, read_relations_for('pull_requests', 'to_projects')) {|pull| can? :read, pull.to_project}
can :create, PullRequest
can(:update, PullRequest) {|pull| pull.user_id == user.id or local_admin?(pull.to_project)}
@ -165,24 +165,24 @@ class Ability
end
# Shared cannot rights for all users (registered, admin)
cannot [:regenerate_metadata, :destroy], Platform, :platform_type => 'personal'
cannot [:create, :destroy], Repository, :platform => {:platform_type => 'personal'}, :name => 'main'
cannot [:packages], Repository, :platform => {:platform_type => 'personal'}
cannot [:remove_members, :remove_member, :add_member, :sync_lock_file, :add_repo_lock_file, :remove_repo_lock_file], Repository, :platform => {:platform_type => 'personal'}
cannot [:regenerate_metadata, :destroy], Platform, platform_type: 'personal'
cannot [:create, :destroy], Repository, platform: {platform_type: 'personal'}, name: 'main'
cannot [:packages], Repository, platform: {platform_type: 'personal'}
cannot [:remove_members, :remove_member, :add_member, :sync_lock_file, :add_repo_lock_file, :remove_repo_lock_file], Repository, platform: {platform_type: 'personal'}
cannot :clear, Platform, :platform_type => 'main'
cannot :clear, Platform, platform_type: 'main'
cannot :destroy, Issue
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
cannot [:members, :add_member, :remove_member, :remove_members], Platform, platform_type: 'personal'
cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'}
cannot [:clone], Platform, :platform_type => 'personal'
cannot [:create, :update, :destroy, :clone], Product, platform: {platform_type: 'personal'}
cannot [:clone], Platform, platform_type: 'personal'
cannot [:publish, :publish_into_testing], BuildList, :new_core => false
cannot :create_container, BuildList, :new_core => false
cannot [:publish, :publish_into_testing], BuildList, new_core: false
cannot :create_container, BuildList, new_core: false
cannot(:publish, BuildList) {|build_list| !build_list.can_publish? }
cannot(:publish_into_testing, BuildList) {|build_list| !build_list.can_publish_into_testing? }
cannot :publish_into_testing, BuildList, :save_to_platform => {:platform_type => 'personal'}
cannot :publish_into_testing, BuildList, save_to_platform: {platform_type: 'personal'}
cannot(:cancel, MassBuild) {|mass_build| mass_build.stop_build}
@ -193,10 +193,10 @@ class Ability
end
can :create, Subscribe do |subscribe|
!subscribe.subscribeable.subscribes.exists?(:user_id => user.id)
!subscribe.subscribeable.subscribes.exists?(user_id: user.id)
end
can :destroy, Subscribe do |subscribe|
subscribe.subscribeable.subscribes.exists?(:user_id => user.id) && user.id == subscribe.user_id
subscribe.subscribeable.subscribes.exists?(user_id: user.id) && user.id == subscribe.user_id
end
end
end
@ -205,29 +205,6 @@ class Ability
key = parent ? "#{parent.singularize}_id" : 'id'
parent ||= table
# Removes duplicates from subquery
#
# ["#{table}.#{key} IN
# (
# SELECT target_id FROM relations
# INNER JOIN #{parent} ON relations.target_type = :target_type AND relations.target_id = #{parent}.id
# WHERE relations.target_type = :target_type AND
# (
# #{parent}.owner_type = 'User' AND #{parent}.owner_id != :user OR
# #{parent}.owner_type = 'Group' AND #{parent}.owner_id NOT IN (:groups)
# ) AND (
# relations.actor_type = 'User' AND relations.actor_id = :user OR
# relations.actor_type = 'Group' AND relations.actor_id IN (:groups)
# )
# )",
# {
# :target_type => parent.classify,
# :user => @user.id,
# :groups => @user.group_ids
# }
# ]
["#{table}.#{key} IN (
SELECT target_id FROM relations WHERE relations.target_type = ? AND
(relations.actor_type = 'User' AND relations.actor_id = ? OR
@ -257,5 +234,4 @@ class Ability
def user_group_ids
@user_group_ids ||= @user.group_ids
end
end

View File

@ -3,18 +3,18 @@ class Advisory < ActiveRecord::Base
has_and_belongs_to_many :projects
has_many :build_lists
validates :description, :update_type, :presence => true
validates :update_type, :inclusion => BuildList::RELEASE_UPDATE_TYPES
validates :description, :update_type, presence: true
validates :update_type, inclusion: BuildList::RELEASE_UPDATE_TYPES
after_create :generate_advisory_id
before_save :normalize_references, :if => :references_changed?
before_save :normalize_references, if: :references_changed?
ID_TEMPLATE = 'ROSA-%<type>s-%<year>d:%<id>04d'
ID_STRING_TEMPLATE = 'ROSA-%<type>s-%<year>04s:%<id>04s'
TYPES = {'security' => 'SA', 'bugfix' => 'A'}
scope :search_by_id, lambda { |aid| where("#{table_name}.advisory_id ILIKE ?", "%#{aid.to_s.strip}%") }
scope :by_update_type, lambda { |ut| where(:update_type => ut) }
scope :by_update_type, lambda { |ut| where(update_type: ut) }
default_scope order("#{table_name}.created_at DESC")
def to_param
@ -32,15 +32,15 @@ class Advisory < ActiveRecord::Base
# this method fetches and structurize packages attached to current advisory.
def fetch_packages_info
packages_info = Hash.new { |h, k| h[k] = {} } # maaagic, it's maaagic ;)
build_lists.find_in_batches(:include => [:save_to_platform, :packages, :project]) do |batch|
build_lists.find_in_batches(include: [:save_to_platform, :packages, :project]) do |batch|
batch.each do |build_list|
tmp = build_list.packages.inject({:srpm => nil, :rpm => []}) do |h, p|
tmp = build_list.packages.inject({srpm: nil, rpm: []}) do |h, p|
p.package_type == 'binary' ? h[:rpm] << p.fullname : h[:srpm] = p.fullname
h
end
h = { build_list.project => tmp }
packages_info[build_list.save_to_platform].merge!(h) do |pr, old, new|
{:srpm => new[:srpm], :rpm => old[:rpm].concat(new[:rpm]).uniq}
{srpm: new[:srpm], rpm: old[:rpm].concat(new[:rpm]).uniq}
end
end
end
@ -50,7 +50,7 @@ class Advisory < ActiveRecord::Base
protected
def generate_advisory_id
self.advisory_id = sprintf(ID_TEMPLATE, :type => TYPES[self.update_type], :year => Time.now.utc.year, :id => self.id)
self.advisory_id = sprintf(ID_TEMPLATE, type: TYPES[self.update_type], year: Time.now.utc.year, id: self.id)
self.save
end

View File

@ -1,9 +1,9 @@
class Arch < ActiveRecord::Base
DEFAULT = %w[i586 x86_64]
has_many :build_lists, :dependent => :destroy
has_many :build_lists, dependent: :destroy
validates :name, :presence => true, :uniqueness => true
validates :name, presence: true, uniqueness: true
scope :recent, order("#{table_name}.name ASC")
end

View File

@ -1,6 +1,6 @@
class Authentication < ActiveRecord::Base
belongs_to :user
validates :provider, :uid, :user_id, :presence => true
validates :uid, :uniqueness => {:scope => :provider, :case_sensitive => false}
validates :provider, :uid, :user_id, presence: true
validates :uid, uniqueness: {scope: :provider, case_sensitive: false}
end

View File

@ -2,15 +2,15 @@ class Avatar < ActiveRecord::Base
self.abstract_class = true
MAX_AVATAR_SIZE = 5.megabyte
AVATAR_SIZES = {:micro => 16, :small => 30, :medium => 40, :big => 81}
AVATAR_SIZES = {micro: 16, small: 30, medium: 40, big: 81}
AVATAR_SIZES_HASH = {}.tap do |styles|
AVATAR_SIZES.each do |name, size|
styles[name] = { :geometry => "#{size}x#{size}#", :format => :jpg, :convert_options => '-strip -background white -flatten -quality 70'}
styles[name] = { geometry: "#{size}x#{size}#", format: :jpg, convert_options: '-strip -background white -flatten -quality 70'}
end
end
has_attached_file :avatar, :styles => AVATAR_SIZES_HASH
validates_inclusion_of :avatar_file_size, :in => (0..MAX_AVATAR_SIZE), :allow_nil => true
has_attached_file :avatar, styles: AVATAR_SIZES_HASH
validates_inclusion_of :avatar_file_size, in: (0..MAX_AVATAR_SIZE), allow_nil: true
attr_accessible :avatar

View File

@ -6,17 +6,17 @@ class BuildList < ActiveRecord::Base
belongs_to :project
belongs_to :arch
belongs_to :save_to_platform, :class_name => 'Platform'
belongs_to :save_to_repository, :class_name => 'Repository'
belongs_to :build_for_platform, :class_name => 'Platform'
belongs_to :save_to_platform, class_name: 'Platform'
belongs_to :save_to_repository, class_name: 'Repository'
belongs_to :build_for_platform, class_name: 'Platform'
belongs_to :user
belongs_to :builder, :class_name => 'User'
belongs_to :publisher, :class_name => 'User'
belongs_to :builder, class_name: 'User'
belongs_to :publisher, class_name: 'User'
belongs_to :advisory
belongs_to :mass_build, :counter_cache => true
has_many :items, :class_name => '::BuildList::Item', :dependent => :destroy
has_many :packages, :class_name => '::BuildList::Package', :dependent => :destroy
has_many :source_packages, :class_name => '::BuildList::Package', :conditions => {:package_type => 'source'}
belongs_to :mass_build, counter_cache: true
has_many :items, class_name: '::BuildList::Item', dependent: :destroy
has_many :packages, class_name: '::BuildList::Package', dependent: :destroy
has_many :source_packages, class_name: '::BuildList::Package', conditions: {package_type: 'source'}
UPDATE_TYPES = %w[bugfix security enhancement recommended newpackage]
RELEASE_UPDATE_TYPES = %w[bugfix security]
@ -24,13 +24,13 @@ class BuildList < ActiveRecord::Base
EXTERNAL_NODES = %w[owned everything]
validates :project_id, :project_version, :arch, :include_repos,
:build_for_platform_id, :save_to_platform_id, :save_to_repository_id, :presence => true
validates_numericality_of :priority, :greater_than_or_equal_to => 0
validates :external_nodes, :inclusion => {:in => EXTERNAL_NODES}, :allow_blank => true
validates :update_type, :inclusion => UPDATE_TYPES,
:unless => Proc.new { |b| b.advisory.present? }
validates :update_type, :inclusion => {:in => RELEASE_UPDATE_TYPES, :message => I18n.t('flash.build_list.frozen_platform')},
:if => Proc.new { |b| b.advisory.present? }
:build_for_platform_id, :save_to_platform_id, :save_to_repository_id, presence: true
validates_numericality_of :priority, greater_than_or_equal_to: 0
validates :external_nodes, inclusion: {in: EXTERNAL_NODES}, allow_blank: true
validates :update_type, inclusion: UPDATE_TYPES,
unless: Proc.new { |b| b.advisory.present? }
validates :update_type, inclusion: {in: RELEASE_UPDATE_TYPES, message: I18n.t('flash.build_list.frozen_platform')},
if: Proc.new { |b| b.advisory.present? }
validate lambda {
errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.main? && save_to_platform_id != build_for_platform_id
}
@ -41,17 +41,17 @@ class BuildList < ActiveRecord::Base
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) if save_to_repository.platform_id != save_to_platform.id
}
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) if build_for_platform.repositories.where(:id => include_repos).count != include_repos.size
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) if build_for_platform.repositories.where(id: include_repos).count != include_repos.size
}
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
}
before_validation lambda { self.include_repos = include_repos.uniq if include_repos.present? }, :on => :create
before_validation :prepare_extra_repositories, :on => :create
before_validation :prepare_extra_build_lists, :on => :create
before_validation :prepare_extra_params, :on => :create
before_validation lambda { self.auto_publish = false if external_nodes.present?; true }, :on => :create
before_validation lambda { self.auto_create_container = false if auto_publish?; true }, :on => :create
before_validation lambda { self.include_repos = include_repos.uniq if include_repos.present? }, on: :create
before_validation :prepare_extra_repositories, on: :create
before_validation :prepare_extra_build_lists, on: :create
before_validation :prepare_extra_params, on: :create
before_validation lambda { self.auto_publish = false if external_nodes.present?; true }, on: :create
before_validation lambda { self.auto_create_container = false if auto_publish?; true }, on: :create
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
:arch_id, :project_id, :save_to_repository_id, :update_type,
@ -93,21 +93,21 @@ class BuildList < ActiveRecord::Base
scope :recent, order("#{table_name}.updated_at DESC")
scope :for_extra_build_lists, lambda {|ids, current_ability, save_to_platform|
s = scoped
s = s.where(:id => ids).published_container.accessible_by(current_ability, :read)
s = s.where(:save_to_platform_id => save_to_platform.id) if save_to_platform && save_to_platform.main?
s = s.where(id: ids).published_container.accessible_by(current_ability, :read)
s = s.where(save_to_platform_id: save_to_platform.id) if save_to_platform && save_to_platform.main?
s
}
scope :for_status, lambda {|status| where(:status => status) if status.present? }
scope :for_user, lambda { |user| where(:user_id => user.id) }
scope :for_status, lambda {|status| where(status: status) if status.present? }
scope :for_user, lambda { |user| where(user_id: user.id) }
scope :not_owned_external_nodes, where("#{table_name}.external_nodes is null OR #{table_name}.external_nodes != ?", :owned)
scope :external_nodes, lambda { |type| where("#{table_name}.external_nodes = ?", type) }
scope :oldest, lambda { where("#{table_name}.updated_at < ?", Time.zone.now - 15.seconds) }
scope :for_platform, lambda { |platform| where(:build_for_platform_id => platform) }
scope :by_mass_build, lambda { |mass_build| where(:mass_build_id => mass_build) }
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) if arch.present? }
scope :scoped_to_save_platform, lambda {|pl_id| where(:save_to_platform_id => pl_id) if pl_id.present? }
scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) if project_version.present? }
scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) }
scope :for_platform, lambda { |platform| where(build_for_platform_id: platform) }
scope :by_mass_build, lambda { |mass_build| where(mass_build_id: mass_build) }
scope :scoped_to_arch, lambda {|arch| where(arch_id: arch) if arch.present? }
scope :scoped_to_save_platform, lambda {|pl_id| where(save_to_platform_id: pl_id) if pl_id.present? }
scope :scoped_to_project_version, lambda {|project_version| where(project_version: project_version) if project_version.present? }
scope :scoped_to_is_circle, lambda {|is_circle| where(is_circle: is_circle) }
scope :for_creation_date_period, lambda{|start_date, end_date|
s = scoped
s = s.where(["#{table_name}.created_at >= ?", start_date]) if start_date
@ -121,9 +121,9 @@ class BuildList < ActiveRecord::Base
s
}
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%") if project_name.present? }
scope :scoped_to_new_core, lambda {|new_core| where(:new_core => new_core)}
scope :scoped_to_new_core, lambda {|new_core| where(new_core: new_core)}
scope :outdated, where("#{table_name}.created_at < ? AND #{table_name}.status NOT IN (?) OR #{table_name}.created_at < ?", Time.now - LIVE_TIME, [BUILD_PUBLISHED,BUILD_PUBLISHED_INTO_TESTING], Time.now - MAX_LIVE_TIME)
scope :published_container, where(:container_status => BUILD_PUBLISHED)
scope :published_container, where(container_status: BUILD_PUBLISHED)
serialize :additional_repos
serialize :include_repos
@ -132,10 +132,10 @@ class BuildList < ActiveRecord::Base
serialize :extra_build_lists, Array
serialize :extra_params, Hash
after_commit :place_build, :on => :create
after_commit :place_build, on: :create
after_destroy :remove_container
state_machine :status, :initial => :waiting_for_response do
state_machine :status, initial: :waiting_for_response do
# WTF? around_transition -> infinite loop
before_transition do |build_list, transition|
@ -152,36 +152,36 @@ class BuildList < ActiveRecord::Base
end
end
after_transition :on => :place_build, :do => :add_job_to_abf_worker_queue,
after_transition on: :place_build, do: :add_job_to_abf_worker_queue,
:if => lambda { |build_list| build_list.external_nodes.blank? }
after_transition :on => :published,
:do => [:set_version_and_tag, :actualize_packages]
after_transition :on => :publish, :do => :set_publisher
after_transition(:on => :publish) do |build_list, transition|
after_transition on: :published,
do: [:set_version_and_tag, :actualize_packages]
after_transition on: :publish, do: :set_publisher
after_transition(on: :publish) do |build_list, transition|
if transition.from == BUILD_PUBLISHED_INTO_TESTING
build_list.cleanup_packages_from_testing
end
end
after_transition :on => :cancel, :do => :cancel_job
after_transition on: :cancel, do: :cancel_job
after_transition :on => [:published, :fail_publish, :build_error, :tests_failed], :do => :notify_users
after_transition :on => :build_success, :do => :notify_users,
:unless => lambda { |build_list| build_list.auto_publish? }
after_transition on: [:published, :fail_publish, :build_error, :tests_failed], do: :notify_users
after_transition on: :build_success, do: :notify_users,
unless: lambda { |build_list| build_list.auto_publish? }
event :place_build do
transition :waiting_for_response => :build_pending
transition waiting_for_response: :build_pending
end
event :start_build do
transition :build_pending => :build_started
transition build_pending: :build_started
end
event :cancel do
transition [:build_pending, :build_started] => :build_canceling
end
# :build_canceling => :build_canceled - canceling from UI
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
# build_canceling: :build_canceled - canceling from UI
# build_started: :build_canceled - canceling from worker by time-out (time_living has been expired)
event :build_canceled do
transition [:build_canceling, :build_started] => :build_canceled
end
@ -250,11 +250,11 @@ class BuildList < ActiveRecord::Base
end
HUMAN_STATUSES.each do |code,name|
state name, :value => code
state name, value: code
end
end
later :publish, :queue => :clone_build
later :publish, queue: :clone_build
HUMAN_CONTAINER_STATUSES = { WAITING_FOR_RESPONSE => :waiting_for_publish,
@ -263,23 +263,23 @@ class BuildList < ActiveRecord::Base
FAILED_PUBLISH => :container_failed_publish
}.freeze
state_machine :container_status, :initial => :waiting_for_publish do
state_machine :container_status, initial: :waiting_for_publish do
after_transition :on => :publish_container, :do => :create_container
after_transition :on => [:fail_publish_container, :destroy_container],
:do => :remove_container
after_transition on: :publish_container, do: :create_container
after_transition on: [:fail_publish_container, :destroy_container],
do: :remove_container
event :publish_container do
transition [:waiting_for_publish, :container_failed_publish] => :container_publish,
:if => :can_create_container?
if: :can_create_container?
end
event :published_container do
transition :container_publish => :container_published
transition container_publish: :container_published
end
event :fail_publish_container do
transition :container_publish => :container_failed_publish
transition container_publish: :container_failed_publish
end
event :destroy_container do
@ -287,12 +287,12 @@ class BuildList < ActiveRecord::Base
end
HUMAN_CONTAINER_STATUSES.each do |code,name|
state name, :value => code
state name, value: code
end
end
def set_version_and_tag
pkg = self.packages.where(:package_type => 'source', :project_id => self.project_id).first
pkg = self.packages.where(package_type: 'source', project_id: self.project_id).first
# TODO: remove 'return' after deployment ABF kernel 2.0
return if pkg.nil? # For old client that does not sends data about packages
self.package_version = "#{pkg.platform.name}-#{pkg.version}-#{pkg.release}"
@ -303,8 +303,8 @@ class BuildList < ActiveRecord::Base
def actualize_packages
ActiveRecord::Base.transaction do
# packages from previous build_list
self.last_published.limit(2).last.packages.update_all :actual => false
self.packages.update_all :actual => true
self.last_published.limit(2).last.packages.update_all actual: false
self.packages.update_all actual: true
end
end
@ -316,11 +316,11 @@ class BuildList < ActiveRecord::Base
return true if !save_to_repository.synchronizing_publications? || save_to_platform.personal? || project.architecture_dependent?
arch_ids = save_to_platform.platform_arch_settings.by_default.pluck(:arch_id)
BuildList.where(
:project_id => project_id,
:save_to_repository_id => save_to_repository_id,
:arch_id => arch_ids,
:commit_hash => commit_hash,
:status => [
project_id: project_id,
save_to_repository_id: save_to_repository_id,
arch_id: arch_ids,
commit_hash: commit_hash,
status: [
SUCCESS,
BUILD_PUBLISHED,
BUILD_PUBLISH,
@ -345,7 +345,7 @@ class BuildList < ActiveRecord::Base
# - true if version of packages is equal to version of pubished packages (only if platform is not released).
# - true if version of packages is greater than version of pubished packages.
def has_new_packages?
if last_bl = last_published.joins(:source_packages).where(:build_list_packages => {:actual => true}).last
if last_bl = last_published.joins(:source_packages).where(build_list_packages: {actual: true}).last
source_packages.each do |nsp|
sp = last_bl.source_packages.find{ |sp| nsp.name == sp.name }
return true unless sp
@ -363,17 +363,17 @@ class BuildList < ActiveRecord::Base
end
def can_publish?
[SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(:id => project_id)
[SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && extra_build_lists_published? && save_to_repository.projects.exists?(id: project_id)
end
def extra_build_lists_published?
# All extra build lists should be published before publishing this build list for main platforms!
return true unless save_to_platform.main?
BuildList.where(:id => extra_build_lists).where('status != ?', BUILD_PUBLISHED).count == 0
BuildList.where(id: extra_build_lists).where('status != ?', BUILD_PUBLISHED).count == 0
end
def human_average_build_time
I18n.t('layout.project_statistics.human_average_build_time', {:hours => (average_build_time/3600).to_i, :minutes => (average_build_time%3600/60).to_i})
I18n.t('layout.project_statistics.human_average_build_time', {hours: (average_build_time/3600).to_i, minutes: (average_build_time%3600/60).to_i})
end
def formatted_average_build_time
@ -403,13 +403,13 @@ class BuildList < ActiveRecord::Base
items_hash.each do |level, items|
items.each do |item|
self.items << self.items.build(:name => item['name'], :version => item['version'], :level => level.to_i)
self.items << self.items.build(name: item['name'], version: item['version'], level: level.to_i)
end
end
end
def set_packages(pkg_hash, project_name)
prj = Project.joins(:repositories => :platform).where('platforms.id = ?', save_to_platform.id).find_by_name!(project_name)
prj = Project.joins(repositories: :platform).where('platforms.id = ?', save_to_platform.id).find_by_name!(project_name)
build_package(pkg_hash['srpm'], 'source', prj) {|p| p.save!}
pkg_hash['rpm'].each do |rpm_hash|
build_package(rpm_hash, 'binary', prj) {|p| p.save!}
@ -417,7 +417,7 @@ class BuildList < ActiveRecord::Base
end
def event_log_message
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
{project: project.name, version: project_version, arch: arch.name}.inspect
end
def current_duration
@ -425,11 +425,11 @@ class BuildList < ActiveRecord::Base
end
def human_current_duration
I18n.t("layout.build_lists.human_current_duration", {:hours => (current_duration/3600).to_i, :minutes => (current_duration%3600/60).to_i})
I18n.t("layout.build_lists.human_current_duration", {hours: (current_duration/3600).to_i, minutes: (current_duration%3600/60).to_i})
end
def human_duration
I18n.t("layout.build_lists.human_duration", {:hours => (duration.to_i/3600).to_i, :minutes => (duration.to_i%3600/60).to_i})
I18n.t("layout.build_lists.human_duration", {hours: (duration.to_i/3600).to_i, minutes: (duration.to_i%3600/60).to_i})
end
def in_work?
@ -454,8 +454,8 @@ class BuildList < ActiveRecord::Base
end
def last_published(testing = false)
BuildList.where(:project_id => self.project_id,
:save_to_repository_id => self.save_to_repository_id)
BuildList.where(project_id: self.project_id,
save_to_repository_id: self.save_to_repository_id)
.for_platform(self.build_for_platform_id)
.scoped_to_arch(self.arch_id)
.for_status(testing ? BUILD_PUBLISHED_INTO_TESTING : BUILD_PUBLISHED)
@ -469,7 +469,7 @@ class BuildList < ActiveRecord::Base
def abf_worker_args
repos = include_repos
include_repos_hash = {}.tap do |h|
Repository.where(:id => (repos | (extra_repositories || [])) ).each do |repo|
Repository.where(id: (repos | (extra_repositories || [])) ).each do |repo|
path, prefix = repo.platform.public_downloads_url(
repo.platform.main? ? nil : build_for_platform.name,
arch.name,
@ -481,7 +481,7 @@ class BuildList < ActiveRecord::Base
end
end
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
BuildList.where(:id => extra_build_lists).each do |bl|
BuildList.where(id: extra_build_lists).each do |bl|
path = "#{APP_CONFIG['downloads_url']}/#{bl.save_to_platform.name}/container/"
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
include_repos_hash["container_#{bl.id}"] = insert_token_to_path(path, bl.save_to_platform)
@ -500,17 +500,17 @@ class BuildList < ActiveRecord::Base
}.map{ |k, v| "#{k}='#{v}'" }.join(' ')
{
:id => id,
:time_living => (build_for_platform.platform_arch_settings.by_arch(arch).first.try(:time_living) || PlatformArchSetting::DEFAULT_TIME_LIVING),
:distrib_type => build_for_platform.distrib_type,
:cmd_params => cmd_params,
:include_repos => include_repos_hash,
:platform => {
:type => build_for_platform.distrib_type,
:name => build_for_platform.name,
:arch => arch.name
id: id,
time_living: (build_for_platform.platform_arch_settings.by_arch(arch).first.try(:time_living) || PlatformArchSetting::DEFAULT_TIME_LIVING),
distrib_type: build_for_platform.distrib_type,
cmd_params: cmd_params,
include_repos: include_repos_hash,
platform: {
type: build_for_platform.distrib_type,
name: build_for_platform.name,
arch: arch.name
},
:user => {:uname => user.uname, :email => user.email}
user: {uname: user.uname, email: user.email}
}
end
@ -583,7 +583,7 @@ class BuildList < ActiveRecord::Base
self.extra_repositories = nil
else
self.extra_repositories = Repository.joins(:platform).
where(:id => extra_repositories, :platforms => {:platform_type => 'personal'}).
where(id: extra_repositories, platforms: {platform_type: 'personal'}).
accessible_by(current_ability, :read).pluck('repositories.id')
end
end
@ -597,7 +597,7 @@ class BuildList < ActiveRecord::Base
(projects.publish_i686_into_x86_64 is true)
', arch_id).joins(:project)
else
bls = bls.where(:arch_id => arch_id)
bls = bls.where(arch_id: arch_id)
end
end
self.extra_build_lists = bls.pluck('build_lists.id')
@ -612,5 +612,4 @@ class BuildList < ActiveRecord::Base
self.extra_params = params.select{ |k,v| v.present? }
end
end
end

View File

@ -12,7 +12,7 @@ class BuildList::Filter
build_lists = @project ? @project.build_lists : BuildList.scoped
if @options[:id]
build_lists = build_lists.where(:id => @options[:id])
build_lists = build_lists.where(id: @options[:id])
else
build_lists = build_lists.scoped_to_new_core(@options[:new_core] == '0' ? nil : true) if @options[:new_core].present?
build_lists = build_lists.by_mass_build(@options[:mass_build_id]) if @options[:mass_build_id]
@ -42,18 +42,18 @@ class BuildList::Filter
def set_options(options)
@options = HashWithIndifferentAccess.new(options.reverse_merge({
:ownership => nil,
:status => nil,
:updated_at_start => nil,
:updated_at_end => nil,
:arch_id => nil,
:platform_id => nil,
:is_circle => nil,
:project_version => nil,
:id => nil,
:project_name => nil,
:mass_build_id => nil,
:new_core => nil
ownership: nil,
status: nil,
updated_at_start: nil,
updated_at_end: nil,
arch_id: nil,
platform_id: nil,
is_circle: nil,
project_version: nil,
id: nil,
project_name: nil,
mass_build_id: nil,
new_core: nil
}))
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned')

View File

@ -1,6 +1,6 @@
class BuildList::Item < ActiveRecord::Base
belongs_to :build_list, :touch => true
belongs_to :build_list, touch: true
attr_protected :build_list_id
@ -10,11 +10,11 @@ class BuildList::Item < ActiveRecord::Base
HUMAN_STATUSES = {
nil => :unknown,
GIT_ERROR => :git_error,
# BuildList::DEPENDENCIES_ERROR => :dependencies_error,
BuildList::SUCCESS => :success,
BuildList::BUILD_STARTED => :build_started,
BuildList::BUILD_ERROR => :build_error,
BuildList::BUILD_CANCELED => :build_canceled
# BuildList:DEPENDENCIES_ERROR: :dependencies_error,
BuildList:SUCCESS: :success,
BuildList:BUILD_STARTED: :build_started,
BuildList:BUILD_ERROR: :build_error,
BuildList:BUILD_CANCELED: :build_canceled
}
scope :recent, order("#{table_name}.level ASC, #{table_name}.name ASC")

View File

@ -9,17 +9,17 @@ class BuildList::Package < ActiveRecord::Base
validates :build_list_id, :project_id, :platform_id, :fullname,
:package_type, :name, :release, :version,
:presence => true
validates :package_type, :inclusion => PACKAGE_TYPES
validates :sha1, :presence => true, :if => Proc.new { |p| p.build_list.new_core? }
presence: true
validates :package_type, inclusion: PACKAGE_TYPES
validates :sha1, presence: true, if: Proc.new { |p| p.build_list.new_core? }
default_scope order("lower(#{table_name}.name) ASC, length(#{table_name}.name) ASC")
# Fetches only actual (last publised) packages.
scope :actual, where(:actual => true)
scope :by_platform, lambda {|platform| where(:platform_id => platform) }
scope :by_name, lambda {|name| where(:name => name) }
scope :by_package_type, lambda {|type| where(:package_type => type) }
scope :actual, where(actual: true)
scope :by_platform, lambda {|platform| where(platform_id: platform) }
scope :by_name, lambda {|name| where(name: name) }
scope :by_package_type, lambda {|type| where(package_type: type) }
scope :like_name, lambda {|name| where("#{table_name}.name ILIKE ?", "%#{name}%") if name.present?}
before_create :set_epoch

View File

@ -21,7 +21,7 @@ class BuildListObserver < ActiveRecord::Observer
end
build_count = statistic.build_count
new_av_time = ( statistic.average_build_time * build_count + record.duration ) / ( build_count + 1 )
statistic.update_attributes(:average_build_time => new_av_time, :build_count => build_count + 1)
statistic.update_attributes(average_build_time: new_av_time, build_count: build_count + 1)
end
end
end

View File

@ -10,7 +10,7 @@ class Collaborator
attr_accessible :role
delegate :new_record?, :to => :relation
delegate :new_record?, to: :relation
class << self
def find_by_project(project)
@ -128,7 +128,7 @@ class Collaborator
def from_relation(relation)
return nil unless relation.present?
return self.new(:relation => relation)
return self.new(relation: relation)
end
end
@ -139,7 +139,7 @@ class Collaborator
if @actor.present? and @project.present?
@relation = Relation.by_actor(@actor).by_target(@project).limit(1).first
@relation ||= Relation.new(:actor_id => @actor.id, :actor_type => @actor.class.to_s,
:target_id => @project.id, :target_type => 'Project')
target_id: @project.id, target_type: 'Project')
else
@relation = Relation.new
@relation.actor = @actor

View File

@ -7,17 +7,17 @@ class Comment < ActiveRecord::Base
# #Num
ISSUES_REGEX = /(?:[a-zA-Z0-9\-_]*\/)?(?:[a-zA-Z0-9\-_]*)?#[0-9]+/
belongs_to :commentable, :polymorphic => true, :touch => true
belongs_to :commentable, polymorphic: true, touch: true
belongs_to :user
belongs_to :project
serialize :data
validates :body, :user_id, :commentable_id, :commentable_type, :project_id, :presence => true
validates :body, :user_id, :commentable_id, :commentable_type, :project_id, presence: true
scope :for_commit, lambda {|c| where(:commentable_id => c.id.hex, :commentable_type => c.class)}
scope :for_commit, lambda {|c| where(commentable_id: c.id.hex, commentable_type: c.class)}
default_scope order("#{table_name}.created_at")
after_create :subscribe_on_reply, :unless => lambda {|c| c.commit_comment?}
after_create :subscribe_on_reply, unless: lambda {|c| c.commit_comment?}
after_create :subscribe_users
attr_accessible :body, :data
@ -91,11 +91,11 @@ class Comment < ActiveRecord::Base
def set_additional_data params
return true if params[:path].blank? && params[:line].blank? # not inline comment
if params[:in_reply].present? && reply = Comment.where(:id => params[:in_reply]).first
if params[:in_reply].present? && reply = Comment.where(id: params[:in_reply]).first
self.data = reply.data
return true
end
self.data = {:path => params[:path], :line => params[:line]}
self.data = {path: params[:path], line: params[:line]}
return actual_inline_comment?(nil, true) if commentable.is_a?(Grit::Commit)
if commentable.is_a?(Issue) && pull = commentable.pull_request
diff_path = pull.diff.select {|d| d.a_path == params[:path]}
@ -140,13 +140,13 @@ class Comment < ActiveRecord::Base
opts = {}
when item.is_a?(Issue)
elements = [[item, item.title], [item, item.body]]
opts = {:created_from_issue_id => item.id}
opts = {created_from_issue_id: item.id}
when item.commentable_type == 'Issue'
elements = [[item, item.body]]
opts = {:created_from_issue_id => item.commentable_id}
opts = {created_from_issue_id: item.commentable_id}
when item.commentable_type == 'Grit::Commit'
elements = [[item, item.body]]
opts = {:created_from_commit_hash => item.commentable_id}
opts = {created_from_commit_hash: item.commentable_id}
else
raise "Unsupported item type #{item.class.name}!"
end
@ -157,18 +157,18 @@ class Comment < ActiveRecord::Base
next unless issue
# dont create link to the same issue
next if opts[:created_from_issue_id] == issue.id
opts = {:created_from_commit_hash => element[0].hex} if item.is_a?(GitHook)
opts = {created_from_commit_hash: element[0].hex} if item.is_a?(GitHook)
# dont create duplicate link to issue
next if Comment.find_existing_automatic_comment issue, opts
# dont create link to outdated commit
next if item.is_a?(GitHook) && !item.project.repo.commit(element[0])
comment = linker.comments.new :body => 'automatic comment'
comment = linker.comments.new body: 'automatic comment'
comment.commentable, comment.project, comment.automatic = issue, issue.project, true
comment.data = {:from_project_id => item.project.id}
comment.data = {from_project_id: item.project.id}
if opts[:created_from_commit_hash]
comment.created_from_commit_hash = opts[:created_from_commit_hash]
elsif opts[:created_from_issue_id]
comment.data.merge!(:comment_id => item.id) if item.is_a? Comment
comment.data.merge!(comment_id: item.id) if item.is_a? Comment
comment.created_from_issue_id = opts[:created_from_issue_id]
else
raise 'Unsupported opts for automatic comment!'
@ -187,25 +187,25 @@ class Comment < ActiveRecord::Base
protected
def subscribe_on_reply
commentable.subscribes.create(:user_id => user_id) if !commentable.subscribes.exists?(:user_id => user_id)
commentable.subscribes.create(user_id: user_id) if !commentable.subscribes.exists?(user_id: user_id)
end
def subscribe_users
if issue_comment?
commentable.subscribes.create(:user => user) if !commentable.subscribes.exists?(:user_id => user.id)
commentable.subscribes.create(user: user) if !commentable.subscribes.exists?(user_id: user.id)
elsif commit_comment?
recipients = project.admins
recipients << user << User.where(:email => commentable.try(:committer).try(:email)).first # commentor and committer
recipients << user << User.where(email: commentable.try(:committer).try(:email)).first # commentor and committer
recipients.compact.uniq.each do |user|
options = {:project_id => project.id, :subscribeable_id => commentable_id, :subscribeable_type => commentable.class.name, :user_id => user.id}
options = {project_id: project.id, subscribeable_id: commentable_id, subscribeable_type: commentable.class.name, user_id: user.id}
Subscribe.subscribe_to_commit(options) if Subscribe.subscribed_to_commit?(project, user, commentable)
end
end
end
def self.find_existing_automatic_comment issue, opts
find_dup = opts.merge(:automatic => true, :commentable_type => issue.class.name,
:commentable_id => issue.id)
find_dup = opts.merge(automatic: true, commentable_type: issue.class.name,
commentable_id: issue.id)
Comment.exists? find_dup
end
end

View File

@ -1,6 +1,6 @@
class EventLog < ActiveRecord::Base
belongs_to :user
belongs_to :eventable, :polymorphic => true
belongs_to :eventable, polymorphic: true
# self.per_page = 1

View File

@ -2,24 +2,24 @@ class EventLogObserver < ActiveRecord::Observer
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :product_build_list
def after_create(record)
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
def before_update(record)
case record.class.to_s
when 'BuildList'
if record.status_changed? and [BuildList::BUILD_CANCELED, BuildList::BUILD_PUBLISHED].include?(record.status)
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
when 'Platform'
if record.visibility_changed?
ActiveSupport::Notifications.instrument "event_log.observer", :eventable => record,
:message => I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
ActiveSupport::Notifications.instrument "event_log.observer", eventable: record,
message: I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
end
end
end
def after_destroy(record)
ActiveSupport::Notifications.instrument("event_log.observer", :eventable => record)
ActiveSupport::Notifications.instrument("event_log.observer", eventable: record)
end
end

View File

@ -12,10 +12,10 @@ class Feedback
attr_accessible :name, :email, :subject, :message
validates :name, :subject, :message, :presence => true
validates :email, :presence => true,
:format => { :with => /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/,
:allow_blank => false }
validates :name, :subject, :message, presence: true
validates :email, presence: true,
format: { with: /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/,
allow_blank: false }
def initialize(args = {}, options = {})
return args.dup if args.is_a? Feedback

View File

@ -5,10 +5,10 @@ class FlashNotify < ActiveRecord::Base
STATUSES = %w[error success info]
validates :status, :inclusion => {:in => STATUSES}
validates :body_ru, :body_en, :status, :presence => true
validates :status, inclusion: {in: STATUSES}
validates :body_ru, :body_en, :status, presence: true
scope :published, where(:published => true)
scope :published, where(published: true)
def hash_id
@digest ||= Digest::MD5.hexdigest("#{self.id}-#{self.updated_at}")

View File

@ -13,8 +13,8 @@ class GitHook
def initialize(owner_uname, repo, newrev, oldrev, ref, newrev_type, user = nil, message = nil)
@repo, @newrev, @oldrev, @refname, @newrev_type, @user, @message = repo, newrev, oldrev, ref, newrev_type, user, message
if @owner = User.where(:uname => owner_uname).first || Group.where(:uname => owner_uname).first!
@project = @owner.own_projects.where(:name => repo).first!
if @owner = User.where(uname: owner_uname).first || Group.where(uname: owner_uname).first!
@project = @owner.own_projects.where(name: repo).first!
end
@change_type, @user = git_change_type, find_user(user)
git_revision_types

View File

@ -1,29 +1,29 @@
class Group < Avatar
belongs_to :owner, :class_name => 'User'
belongs_to :owner, class_name: 'User'
has_many :relations, :as => :actor, :dependent => :destroy, :dependent => :destroy
has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy
has_many :targets, :as => :actor, :class_name => 'Relation', :dependent => :destroy
has_many :relations, as: :actor, dependent: :destroy, dependent: :destroy
has_many :actors, as: :target, class_name: 'Relation', dependent: :destroy
has_many :targets, as: :actor, class_name: 'Relation', dependent: :destroy
has_many :members, :through => :actors, :source => :actor, :source_type => 'User', :autosave => true
has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true
has_many :members, through: :actors, source: :actor, source_type: 'User', autosave: true
has_many :projects, through: :targets, source: :target, source_type: 'Project', autosave: true
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
has_many :own_projects, as: :owner, class_name: 'Project', dependent: :destroy
has_many :own_platforms, as: :owner, class_name: 'Platform', dependent: :destroy
validates :owner, :presence => true
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /\A[a-z0-9_]+\z/}, :reserved_name => true
validates :owner, presence: true
validates :uname, presence: true, uniqueness: {case_sensitive: false}, format: {with: /\A[a-z0-9_]+\z/}, reserved_name: true
validate { errors.add(:uname, :taken) if User.by_uname(uname).present? }
scope :opened, where('1=1')
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)}
scope :by_owner, lambda {|owner| where(owner_id: owner.id)}
scope :by_admin, lambda {|admin| joins(:actors).where(:'relations.role' => 'admin', :'relations.actor_id' => admin.id, :'relations.actor_type' => 'User')}
scope :by_admin_and_writer, lambda {|actor| joins(:actors).where(:'relations.role' => ['admin', 'writer'], :'relations.actor_id' => actor.id, :'relations.actor_type' => 'User')}
attr_accessible :uname, :description
attr_readonly :uname
delegate :email, :to => :owner
delegate :email, to: :owner
after_create :add_owner_to_members
@ -58,6 +58,6 @@ class Group < Avatar
protected
def add_owner_to_members
Relation.create_with_role(self.owner, self, 'admin') # members << self.owner if !members.exists?(:id => self.owner.id)
Relation.create_with_role(self.owner, self, 'admin') # members << self.owner if !members.exists?(id: self.owner.id)
end
end

View File

@ -5,14 +5,14 @@ class Hook < ActiveRecord::Base
belongs_to :project
before_validation :cleanup_data
validates :project_id, :data, :presence => true
validates :name, :presence => true, :inclusion => {:in => NAMES}
validates :project_id, :data, presence: true
validates :name, presence: true, inclusion: {in: NAMES}
attr_accessible :data, :name
serialize :data, Hash
scope :for_name, lambda {|name| where(:name => name) if name.present? }
scope :for_name, lambda {|name| where(name: name) if name.present? }
def receive_issues(issue, action)
pull = issue.pull_request
@ -21,38 +21,38 @@ class Hook < ActiveRecord::Base
payload = meta(issue.project, issue.user)
base_params = {
:number => issue.serial_id,
:state => issue.status,
:title => issue.title,
:body => issue.body,
:user => {:login => issue.user.uname},
number: issue.serial_id,
state: issue.status,
title: issue.title,
body: issue.body,
user: {login: issue.user.uname},
}
if pull
total_commits = pull.repo.commits_between(pull.to_commit, pull.from_commit).count
repo_owner = pull.to_project.owner.uname
post 'pull_request', {
:payload => payload.merge(
:action => (pull.ready? ? 'opened' : pull.status),
:pull_request => base_params.merge(
:commits => total_commits,
:head => {:label => "#{pull.from_project.owner.uname}:#{pull.from_ref}"},
:base => {:label => "#{repo_owner}:#{pull.to_ref}"},
:html_url => project_pull_request_url(pull.to_project, pull)
payload: payload.merge(
action: (pull.ready? ? 'opened' : pull.status),
pull_request: base_params.merge(
commits: total_commits,
head: {label: "#{pull.from_project.owner.uname}:#{pull.from_ref}"},
base: {label: "#{repo_owner}:#{pull.to_ref}"},
html_url: project_pull_request_url(pull.to_project, pull)
)
).to_json
}
else
post 'issues', {
:payload => payload.merge(
:action => (issue.closed? ? 'closed' : 'opened'),
:issue => base_params.merge(
:html_url => project_issue_url(issue.project, issue)
payload: payload.merge(
action: (issue.closed? ? 'closed' : 'opened'),
issue: base_params.merge(
html_url: project_issue_url(issue.project, issue)
)
).to_json
}
end
end
later :receive_issues, :queue => :notification
later :receive_issues, queue: :notification
def receive_push(git_hook)
default_url_options
@ -62,7 +62,7 @@ class Hook < ActiveRecord::Base
oldrev, newrev, change_type = git_hook.values_at *%w(oldrev newrev change_type)
commits = []
payload.merge!(:before => oldrev, :after => newrev)
payload.merge!(before: oldrev, after: newrev)
if %w(delete create).exclude? change_type
payload.merge!(
:compare => diff_url(project, "#{oldrev[0..6]}...#{newrev[0..6]}")
@ -76,45 +76,45 @@ class Hook < ActiveRecord::Base
end
post 'push', {
:payload => payload.merge(
:ref => git_hook['refname'],
:commits => commits.map{ |commit|
payload: payload.merge(
ref: git_hook['refname'],
commits: commits.map{ |commit|
files = changed_files commit
{
:id => commit.id,
:message => commit.message,
:distinct => true,
:url => commit_url(project, commit),
:removed => files[:removed],
:added => files[:added],
:modified => files[:modified],
:timestamp => commit.committed_date,
:author => {:name => commit.committer.name, :email => commit.committer.email}
id: commit.id,
message: commit.message,
distinct: true,
url: commit_url(project, commit),
removed: files[:removed],
added: files[:added],
modified: files[:modified],
timestamp: commit.committed_date,
author: {name: commit.committer.name, email: commit.committer.email}
}
}
).to_json
}
end
later :receive_push, :queue => :notification
later :receive_push, queue: :notification
protected
def post(action, params)
github_services = APP_CONFIG['github_services']
uri = URI "http://#{github_services['ip']}:#{github_services['port']}/#{name}/#{action}"
Net::HTTP.post_form uri, params.merge(:data => data.to_json)
Net::HTTP.post_form uri, params.merge(data: data.to_json)
rescue # Dont care about it
end
def meta(project, user)
{
:repository => {
:name => project.name,
:url => project_url(project),
:owner => { :login => project.owner.uname }
repository: {
name: project.name,
url: project_url(project),
owner: { login: project.owner.uname }
},
:sender => {:login => user.uname},
:pusher => {:name => user.uname}
sender: {login: user.uname},
pusher: {name: user.uname}
}
end
@ -140,7 +140,7 @@ class Hook < ActiveRecord::Base
modified << diff.a_path
end
end
{:removed => removed, :added => added, :modified => modified}
{removed: removed, added: added, modified: modified}
end
end

View File

@ -4,30 +4,30 @@ class Issue < ActiveRecord::Base
belongs_to :project
belongs_to :user
belongs_to :assignee, :class_name => 'User', :foreign_key => 'assignee_id'
belongs_to :closer, :class_name => 'User', :foreign_key => 'closed_by'
belongs_to :assignee, class_name: 'User', foreign_key: 'assignee_id'
belongs_to :closer, class_name: 'User', foreign_key: 'closed_by'
has_many :comments, :as => :commentable, :dependent => :destroy
has_many :subscribes, :as => :subscribeable, :dependent => :destroy
has_many :labelings, :dependent => :destroy
has_many :labels, :through => :labelings, :uniq => true
has_one :pull_request, :dependent => :destroy
has_many :comments, as: :commentable, dependent: :destroy
has_many :subscribes, as: :subscribeable, dependent: :destroy
has_many :labelings, dependent: :destroy
has_many :labels, through: :labelings, uniq: true
has_one :pull_request, dependent: :destroy
validates :title, :body, :project_id, :presence => true
validates :title, :body, :project_id, presence: true
after_create :set_serial_id
after_create :subscribe_users
after_update :subscribe_issue_assigned_user
attr_accessible :labelings_attributes, :title, :body, :assignee_id
accepts_nested_attributes_for :labelings, :allow_destroy => true
accepts_nested_attributes_for :labelings, allow_destroy: true
scope :opened, where(:status => 'open')
scope :closed, where(:status => 'closed')
scope :opened, where(status: 'open')
scope :closed, where(status: 'closed')
scope :needed_checking, where(:issues => {:status => ['open', 'blocked', 'ready', 'already']})
scope :needed_checking, where(issues: {status: ['open', 'blocked', 'ready', 'already']})
scope :not_closed_or_merged, needed_checking
scope :closed_or_merged, where(:issues => {:status => ['closed', 'merged']})
scope :closed_or_merged, where(issues: {status: ['closed', 'merged']})
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
scope :search, lambda {|q| where("#{table_name}.title ILIKE ?", "%#{q.mb_chars.downcase}%") if q.present?}
scope :without_pull_requests, where('NOT EXISTS (select null from pull_requests as pr where pr.issue_id = issues.id)')
@ -41,8 +41,8 @@ class Issue < ActiveRecord::Base
end
def subscribe_creator(creator_id)
if !self.subscribes.exists?(:user_id => creator_id)
self.subscribes.create(:user_id => creator_id)
if !self.subscribes.exists?(user_id: creator_id)
self.subscribes.create(user_id: creator_id)
end
end
@ -75,7 +75,7 @@ class Issue < ActiveRecord::Base
project = Project.find_by_owner_and_name(owner_uname.chomp('/'), project_name)
return nil unless project
return nil unless current_ability.can? :show, project
project.issues.where(:serial_id => serial_id).first
project.issues.where(serial_id: serial_id).first
end
protected
@ -87,17 +87,17 @@ class Issue < ActiveRecord::Base
def subscribe_users
collect_recipients.each do |recipient|
if recipient.notifier.new_comment && !self.subscribes.exists?(:user_id => recipient.id)
ss = self.subscribes.create(:user_id => recipient.id)
if recipient.notifier.new_comment && !self.subscribes.exists?(user_id: recipient.id)
ss = self.subscribes.create(user_id: recipient.id)
end
end
end
def subscribe_issue_assigned_user
if self.assignee_id && self.assignee_id_changed?
self.subscribes.where(:user_id => self.assignee_id_was).first.destroy unless self.assignee_id_was.blank?
if self.assignee.notifier.issue_assign && !self.subscribes.exists?(:user_id => self.assignee_id)
self.subscribes.create(:user_id => self.assignee_id)
self.subscribes.where(user_id: self.assignee_id_was).first.destroy unless self.assignee_id_was.blank?
if self.assignee.notifier.issue_assign && !self.subscribes.exists?(user_id: self.assignee_id)
self.subscribes.create(user_id: self.assignee_id)
end
end
end

View File

@ -4,12 +4,12 @@ class KeyPair < ActiveRecord::Base
attr_accessor :fingerprint
attr_accessible :public, :secret, :repository_id
attr_encrypted :secret, :key => APP_CONFIG['keys']['key_pair_secret_key']
attr_encrypted :secret, key: APP_CONFIG['keys']['key_pair_secret_key']
validates :repository_id, :user_id, :presence => true
validates :secret, :public, :presence => true, :length => { :maximum => 10000 }, :on => :create
validates :repository_id, :user_id, presence: true
validates :secret, :public, presence: true, length: { maximum: 10000 }, on: :create
validates :repository_id, :uniqueness => {:message => I18n.t("activerecord.errors.key_pair.repo_key_exists")}
validates :repository_id, uniqueness: {message: I18n.t("activerecord.errors.key_pair.repo_key_exists")}
validate :check_keys
before_create { |record| record.key_id = @fingerprint }

View File

@ -1,10 +1,10 @@
class Label < ActiveRecord::Base
has_many :labelings, :dependent => :destroy
has_many :issues, :through => :labelings
has_many :labelings, dependent: :destroy
has_many :issues, through: :labelings
belongs_to :project
validates :name, :uniqueness => {:scope => :project_id}
validates :name, :color, :presence => true
validates :color, :format => { :with => /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, :message => I18n.t('layout.issues.invalid_labels')}
validates :name, uniqueness: {scope: :project_id}
validates :name, :color, presence: true
validates :color, format: { with: /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, message: I18n.t('layout.issues.invalid_labels')}
end

View File

@ -1,26 +1,26 @@
class MassBuild < ActiveRecord::Base
belongs_to :build_for_platform, :class_name => 'Platform', :conditions => {:platform_type => 'main'}
belongs_to :save_to_platform, :class_name => 'Platform'
belongs_to :build_for_platform, class_name: 'Platform', conditions: {platform_type: 'main'}
belongs_to :save_to_platform, class_name: 'Platform'
belongs_to :user
has_many :build_lists, :dependent => :destroy
has_many :build_lists, dependent: :destroy
serialize :extra_repositories, Array
serialize :extra_build_lists, Array
scope :recent, order("#{table_name}.created_at DESC")
scope :by_platform, lambda { |platform| where(:save_to_platform_id => platform.id) }
scope :by_platform, lambda { |platform| where(save_to_platform_id: platform.id) }
scope :outdated, where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME)
attr_accessor :arches
attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id,
:extra_repositories, :extra_build_lists, :increase_release_tag
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, :presence => true
validates :projects_list, :length => {:maximum => 500_000}, :presence => true
validates_inclusion_of :auto_publish, :increase_release_tag, :in => [true, false]
validates :save_to_platform_id, :build_for_platform_id, :arch_names, :name, :user_id, presence: true
validates :projects_list, length: {maximum: 500_000}, presence: true
validates_inclusion_of :auto_publish, :increase_release_tag, in: [true, false]
after_commit :build_all, :on => :create
before_validation :set_data, :on => :create
after_commit :build_all, on: :create
before_validation :set_data, on: :create
COUNT_STATUSES = [
:build_lists,
@ -35,7 +35,7 @@ class MassBuild < ActiveRecord::Base
def build_all
# later with resque
arches_list = arch_names ? Arch.where(:name => arch_names.split(', ')) : Arch.all
arches_list = arch_names ? Arch.where(name: arch_names.split(', ')) : Arch.all
projects_list.lines.each do |name|
next if name.blank?
@ -59,15 +59,15 @@ class MassBuild < ActiveRecord::Base
end
end
end
later :build_all, :queue => :clone_build
later :build_all, queue: :clone_build
def generate_failed_builds_list
report = ""
BuildList.select('build_lists.id, projects.name as project_name, arches.name as arch_name').
where(
:status => BuildList::BUILD_ERROR,
:mass_build_id => self.id
).joins(:project, :arch).find_in_batches(:batch_size => 100) do |build_lists|
status: BuildList::BUILD_ERROR,
mass_build_id: self.id
).joins(:project, :arch).find_in_batches(batch_size: 100) do |build_lists|
build_lists.each do |build_list|
report << "ID: #{build_list.id}; "
report << "PROJECT_NAME: #{build_list.project_name}; "
@ -79,28 +79,28 @@ class MassBuild < ActiveRecord::Base
def cancel_all
update_column(:stop_build, true)
build_lists.find_each(:batch_size => 100) do |bl|
build_lists.find_each(batch_size: 100) do |bl|
bl.cancel
end
end
later :cancel_all, :queue => :clone_build
later :cancel_all, queue: :clone_build
def publish_success_builds(user)
publish user, BuildList::SUCCESS, BuildList::FAILED_PUBLISH
end
later :publish_success_builds, :queue => :clone_build
later :publish_success_builds, queue: :clone_build
def publish_test_failed_builds(user)
publish user, BuildList::TESTS_FAILED
end
later :publish_test_failed_builds, :queue => :clone_build
later :publish_test_failed_builds, queue: :clone_build
private
def publish(user, *statuses)
builds = build_lists.where(:status => statuses)
builds.update_all(:publisher_id => user.id)
builds.order(:id).find_in_batches(:batch_size => 50) do |bls|
builds = build_lists.where(status: statuses)
builds.update_all(publisher_id: user.id)
builds.order(:id).find_in_batches(batch_size: 50) do |bls|
bls.each{ |bl| bl.can_publish? && bl.has_new_packages? && bl.now_publish }
end
end
@ -110,7 +110,7 @@ class MassBuild < ActiveRecord::Base
self.name = "#{Time.now.utc.to_date.strftime("%d.%b")}-#{save_to_platform.name}"
self.build_for_platform = save_to_platform if save_to_platform.main?
end
self.arch_names = Arch.where(:id => arches).map(&:name).join(", ")
self.arch_names = Arch.where(id: arches).map(&:name).join(", ")
self.projects_list = projects_list.lines.map do |name|
name.chomp.strip if name.present?

View File

@ -9,29 +9,29 @@ class Platform < ActiveRecord::Base
NAME_PATTERN = /[\w\-\.]+/
HUMAN_STATUSES = HUMAN_STATUSES.clone.freeze
belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id'
belongs_to :owner, :polymorphic => true
belongs_to :parent, class_name: 'Platform', foreign_key: 'parent_platform_id'
belongs_to :owner, polymorphic: true
has_many :repositories, :dependent => :destroy
has_many :products, :dependent => :destroy
has_many :tokens, :as => :subject, :dependent => :destroy
has_many :platform_arch_settings, :dependent => :destroy
has_many :repositories, dependent: :destroy
has_many :products, dependent: :destroy
has_many :tokens, as: :subject, dependent: :destroy
has_many :platform_arch_settings, dependent: :destroy
has_many :repository_statuses
has_many :relations, :as => :target, :dependent => :destroy
has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy
has_many :members, :through => :actors, :source => :actor, :source_type => 'User'
has_many :relations, as: :target, dependent: :destroy
has_many :actors, as: :target, class_name: 'Relation', dependent: :destroy
has_many :members, through: :actors, source: :actor, source_type: 'User'
has_and_belongs_to_many :advisories
has_many :packages, :class_name => "BuildList::Package", :dependent => :destroy
has_many :packages, class_name: "BuildList::Package", dependent: :destroy
has_many :mass_builds, :foreign_key => :save_to_platform_id
has_many :mass_builds, foreign_key: :save_to_platform_id
validates :description, :presence => true
validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES}
validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /\A#{NAME_PATTERN}\z/ }
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
validates :description, presence: true
validates :visibility, presence: true, inclusion: {in: VISIBILITIES}
validates :name, uniqueness: {case_sensitive: false}, presence: true, format: { with: /\A#{NAME_PATTERN}\z/ }
validates :distrib_type, presence: true, inclusion: {in: APP_CONFIG['distr_types']}
validate lambda {
if released_was && !released
errors.add(:released, I18n.t('flash.platform.released_status_can_not_be_changed'))
@ -41,7 +41,7 @@ class Platform < ActiveRecord::Base
if personal? && (owner_id_changed? || owner_type_changed?)
errors.add :owner, I18n.t('flash.platform.owner_can_not_be_changed')
end
}, :on => :update
}, on: :update
before_create :create_directory
before_destroy :detele_directory
@ -54,35 +54,35 @@ class Platform < ActiveRecord::Base
scope :search_order, order("CHAR_LENGTH(#{table_name}.name) ASC")
scope :search, lambda {|q| where("#{table_name}.name ILIKE ?", "%#{q.to_s.strip}%")}
scope :by_visibilities, lambda {|v| where(:visibility => v)}
scope :opened, where(:visibility => 'open')
scope :hidden, where(:visibility => 'hidden')
scope :by_type, lambda {|type| where(:platform_type => type) if type.present?}
scope :by_visibilities, lambda {|v| where(visibility: v)}
scope :opened, where(visibility: 'open')
scope :hidden, where(visibility: 'hidden')
scope :by_type, lambda {|type| where(platform_type: type) if type.present?}
scope :main, by_type('main')
scope :personal, by_type('personal')
scope :waiting_for_regeneration, where(:status => WAITING_FOR_REGENERATION)
scope :waiting_for_regeneration, where(status: WAITING_FOR_REGENERATION)
accepts_nested_attributes_for :platform_arch_settings, :allow_destroy => true
accepts_nested_attributes_for :platform_arch_settings, allow_destroy: true
attr_accessible :name, :distrib_type, :parent_platform_id, :platform_type, :owner, :visibility, :description, :released, :platform_arch_settings_attributes
attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type
include Modules::Models::Owner
state_machine :status, :initial => :ready do
state_machine :status, initial: :ready do
event :ready do
transition :regenerating => :ready
transition regenerating: :ready
end
event :regenerate do
transition :ready => :waiting_for_regeneration, :if => lambda{ |p| p.main? }
transition ready: :waiting_for_regeneration, if: lambda{ |p| p.main? }
end
event :start_regeneration do
transition :waiting_for_regeneration => :regenerating
transition waiting_for_regeneration: :regenerating
end
HUMAN_STATUSES.each do |code,name|
state name, :value => code
state name, value: code
end
end
@ -95,7 +95,7 @@ class Platform < ActiveRecord::Base
urpmi_commands = ActiveSupport::OrderedHash.new
# TODO: rename method or create separate methods for mdv and rhel
# Platform.main.opened.where(:distrib_type => APP_CONFIG['distr_types'].first).each do |pl|
# Platform.main.opened.where(distrib_type: APP_CONFIG['distr_types'].first).each do |pl|
Platform.main.opened.each do |pl|
urpmi_commands[pl.name] = {}
# FIXME should support restricting access to the hidden platform
@ -158,7 +158,7 @@ class Platform < ActiveRecord::Base
end
def clone_relations(from = parent)
self.repositories = from.repositories.map{|r| r.full_clone(:platform_id => id)}
self.repositories = from.repositories.map{|r| r.full_clone(platform_id: id)}
self.products = from.products.map(&:full_clone)
end
@ -170,9 +170,9 @@ class Platform < ActiveRecord::Base
def change_visibility
if !hidden?
update_attributes(:visibility => 'hidden')
update_attributes(visibility: 'hidden')
else
update_attributes(:visibility => 'open')
update_attributes(visibility: 'open')
end
end
@ -191,15 +191,15 @@ class Platform < ActiveRecord::Base
def update_owner_relation
if owner_id_was != owner_id
r = relations.where(:actor_id => owner_id_was, :actor_type => owner_type_was).first
r.update_attributes(:actor_id => owner_id, :actor_type => owner_type)
r = relations.where(actor_id: owner_id_was, actor_type: owner_type_was).first
r.update_attributes(actor_id: owner_id, actor_type: owner_type)
end
end
def destroy
with_skip {super} # avoid cascade XML RPC requests
end
later :destroy, :queue => :clone_build
later :destroy, queue: :clone_build
def default_host
EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
@ -217,12 +217,12 @@ class Platform < ActiveRecord::Base
token, pass = *ActionController::HttpAuthentication::Basic::user_name_and_password(request)
end
Rails.cache.fetch([platform_name, token, :platform_allowed], :expires_in => 2.minutes) do
Rails.cache.fetch([platform_name, token, :platform_allowed], expires_in: 2.minutes) do
platform = Platform.find_by_name platform_name
next false unless platform
next true unless platform.hidden?
next false unless token
next true if platform.tokens.by_active.where(:authentication_token => token).exists?
next true if platform.tokens.by_active.where(authentication_token: token).exists?
user = User.find_by_authentication_token token
current_ability = Ability.new(user)
@ -252,11 +252,11 @@ class Platform < ActiveRecord::Base
def fs_clone(old_name = parent.name, new_name = name)
FileUtils.cp_r "#{parent.path}/repository", path
end
later :fs_clone, :queue => :clone_build
later :fs_clone, queue: :clone_build
def freeze_platform_and_update_repos
if released_changed? && released == true
repositories.update_all(:publish_without_qa => false)
repositories.update_all(publish_without_qa: false)
end
end
end

View File

@ -7,11 +7,11 @@ class PlatformArchSetting < ActiveRecord::Base
belongs_to :arch
belongs_to :platform
validates :arch_id, :platform_id, :presence => true
validates :platform_id, :uniqueness => {:scope => :arch_id}
validates :arch_id, :platform_id, presence: true
validates :platform_id, :uniqueness => {scope: :arch_id}
scope :by_arch, lambda {|arch| where(:arch_id => arch) if arch.present?}
scope :by_default, where(:default => true)
scope :by_arch, lambda {|arch| where(arch_id: arch) if arch.present?}
scope :by_default, where(default: true)
attr_accessible :arch_id, :platform_id, :default

View File

@ -20,7 +20,7 @@ class PlatformContent
return nil unless repository_name = @path.match(/\/[\w]+\/(release|updates)\//)
repository_name = repository_name[0].gsub(/\/(release|updates)\/$/, '').gsub('/', '')
repository = @platform.repositories.where(:name => repository_name).first
repository = @platform.repositories.where(name: repository_name).first
return nil unless repository
if @platform.main?
@ -36,8 +36,8 @@ class PlatformContent
@build_list = BuildList.for_status(BuildList::BUILD_PUBLISHED)
.for_platform(build_for_platform)
.scoped_to_save_platform(@platform)
.where(:save_to_repository_id => repository)
.where(:build_list_packages => {:fullname => name, :actual => true})
.where(save_to_repository_id: repository)
.where(build_list_packages: {fullname: name, actual: true})
.joins(:packages)
.last

View File

@ -4,15 +4,15 @@ class PrivateUser < ActiveRecord::Base
belongs_to :platform
belongs_to :user
validate :login, :uniqueness => true
validate :login, uniqueness: true
def event_log_message
{:platform => platform.name, :user => user.uname}.inspect
{platform: platform.name, user: user.uname}.inspect
end
class << self
def can_generate_more?(user_id, platform_id)
!PrivateUser.exists?(:user_id => user_id, :platform_id => platform_id)
!PrivateUser.exists?(user_id: user_id, platform_id: platform_id)
end
def generate_pair(platform_id, user_id)
@ -20,13 +20,13 @@ class PrivateUser < ActiveRecord::Base
pass = "pass_#{ActiveSupport::SecureRandom.hex(16)}"
PrivateUser.create(
:login => login,
:password => Digest::SHA2.new.hexdigest(pass),
:platform_id => platform_id,
:user_id => user_id
login: login,
password: Digest::SHA2.new.hexdigest(pass),
platform_id: platform_id,
user_id: user_id
)
{:login => login, :pass => pass}
{login: login, pass: pass}
end
end
end

View File

@ -3,7 +3,7 @@ class Product < ActiveRecord::Base
belongs_to :platform
belongs_to :project
has_many :product_build_lists, :dependent => :destroy
has_many :product_build_lists, dependent: :destroy
ONCE_A_12_HOURS = 0
ONCE_A_DAY = 1
@ -16,11 +16,11 @@ class Product < ActiveRecord::Base
ONCE_A_WEEK => :once_a_week
}
validates :name, :presence => true, :uniqueness => {:scope => :platform_id}
validates :project_id, :presence => true
validates :main_script, :params, :length => { :maximum => 255 }
validates :autostart_status, :numericality => true,
:inclusion => {:in => AUTOSTART_STATUSES}, :allow_blank => true
validates :name, presence: true, uniqueness: {scope: :platform_id}
validates :project_id, presence: true
validates :main_script, :params, length: { maximum: 255 }
validates :autostart_status, numericality: true,
inclusion: {in: AUTOSTART_STATUSES}, allow_blank: true
scope :recent, order("#{table_name}.name ASC")
@ -61,7 +61,7 @@ class Product < ActiveRecord::Base
end
def self.autostart_iso_builds(autostart_status)
Product.where(:autostart_status => autostart_status).each do |product|
Product.where(autostart_status: autostart_status).each do |product|
pbl = product.product_build_lists.new
[:params, :main_script, :project, :project_version].each do |k|
pbl.send "#{k}=", product.send(k)

View File

@ -38,16 +38,16 @@ class ProductBuildList < ActiveRecord::Base
belongs_to :user
# see: Issue #6
before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }, :on => :create
before_validation lambda { self.arch_id = Arch.find_by_name('x86_64').id }, on: :create
# field "not_delete" can be changed only if build has been completed
before_validation lambda { self.not_delete = false unless build_completed?; true }
validates :product_id,
:status,
:project_id,
:main_script,
:arch_id, :presence => true
validates :status, :inclusion => { :in => STATUSES }
validates :main_script, :params, :length => { :maximum => 255 }
:arch_id, presence: true
validates :status, inclusion: { in: STATUSES }
validates :main_script, :params, length: { maximum: 255 }
attr_accessor :base_url
attr_accessible :status,
@ -65,45 +65,45 @@ class ProductBuildList < ActiveRecord::Base
scope :default_order, order("#{table_name}.updated_at DESC")
scope :for_status, lambda {|status| where(:status => status) }
scope :for_user, lambda { |user| where(:user_id => user.id) }
scope :for_status, lambda {|status| where(status: status) }
scope :for_user, lambda { |user| where(user_id: user.id) }
scope :scoped_to_product_name, lambda {|product_name| joins(:product).where('products.name LIKE ?', "%#{product_name}%")}
scope :recent, order("#{table_name}.updated_at DESC")
scope :outdated, where(:not_delete => false).
scope :outdated, where(not_delete: false).
where("(#{table_name}.created_at < ? AND #{table_name}.autostarted is TRUE) OR #{table_name}.created_at < ?", Time.now - LIVE_TIME, Time.now - MAX_LIVE_TIME)
after_create :add_job_to_abf_worker_queue
before_destroy :can_destroy?
state_machine :status, :initial => :build_pending do
state_machine :status, initial: :build_pending do
event :start_build do
transition :build_pending => :build_started
transition build_pending: :build_started
end
event :cancel do
transition [:build_pending, :build_started] => :build_canceling
end
after_transition :on => :cancel, :do => :cancel_job
after_transition on: :cancel, do: :cancel_job
# :build_canceling => :build_canceled - canceling from UI
# :build_started => :build_canceled - canceling from worker by time-out (time_living has been expired)
# build_canceling: :build_canceled - canceling from UI
# build_started: :build_canceled - canceling from worker by time-out (time_living has been expired)
event :build_canceled do
transition [:build_canceling, :build_started] => :build_canceled
end
# :build_canceling => :build_completed - Worker hasn't time to cancel building because build had been already completed
# build_canceling: :build_completed - Worker hasn't time to cancel building because build had been already completed
event :build_success do
transition [:build_started, :build_canceling] => :build_completed
end
# :build_canceling => :build_failed - Worker hasn't time to cancel building because build had been already failed
# build_canceling: :build_failed - Worker hasn't time to cancel building because build had been already failed
event :build_error do
transition [:build_started, :build_canceling] => :build_failed
end
HUMAN_STATUSES.each do |code,name|
state name, :value => code
state name, value: code
end
end
@ -120,7 +120,7 @@ class ProductBuildList < ActiveRecord::Base
end
def event_log_message
{:product => product.name}.inspect
{product: product.name}.inspect
end
def self.human_status(status)
@ -152,7 +152,7 @@ class ProductBuildList < ActiveRecord::Base
def abf_worker_args
file_name = "#{project.name}-#{commit_hash}"
opts = default_url_options
opts.merge!({:user => user.authentication_token, :password => ''}) if user.present?
opts.merge!({user: user.authentication_token, password: ''}) if user.present?
srcpath = url_helpers.archive_url(
project.owner,
project.name,
@ -161,19 +161,19 @@ class ProductBuildList < ActiveRecord::Base
opts
)
{
:id => id,
id: id,
# TODO: remove comment
# :srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz',
:srcpath => srcpath,
:params => params,
:time_living => time_living,
:main_script => main_script,
:platform => {
:type => product.platform.distrib_type,
:name => product.platform.name,
:arch => arch.name
# srcpath: 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz',
srcpath: srcpath,
params: params,
time_living: time_living,
main_script: main_script,
platform: {
type: product.platform.distrib_type,
name: product.platform.name,
arch: arch.name
},
:user => {:uname => user.try(:uname), :email => user.try(:email)}
user: {uname: user.try(:uname), email: user.try(:email)}
}
end
end

Some files were not shown because too many files have changed in this diff Show More