Commit 77541891 authored by Robert Speicher's avatar Robert Speicher

Fully embrace Ruby 1.9 hash syntax

Didn't bother with files in db/, config/, or features/
parent 1413c23c
class CommitLoad < BaseContext
def execute
result = {
:commit => nil,
:suppress_diff => false,
:line_notes => [],
:notes_count => 0,
:note => nil
commit: nil,
suppress_diff: false,
line_notes: [],
notes_count: 0,
note: nil
}
commit = project.commit(params[:id])
......
......@@ -12,12 +12,12 @@ class IssuesBulkUpdateContext < BaseContext
opts[:assignee_id] = assignee_id if assignee_id.present?
opts[:closed] = (status == "closed") if status.present?
issues = Issue.where(:id => issues_ids).all
issues = Issue.where(id: issues_ids).all
issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
issues.each { |issue| issue.update_attributes(opts) }
{
:count => issues.count,
:success => !issues.count.zero?
count: issues.count,
success: !issues.count.zero?
}
end
end
......
......@@ -2,7 +2,7 @@ class Admin::ProjectsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :authenticate_admin!
before_filter :admin_project, :only => [:edit, :show, :update, :destroy, :team_update]
before_filter :admin_project, only: [:edit, :show, :update, :destroy, :team_update]
def index
@admin_projects = Project.scoped
......@@ -36,7 +36,7 @@ class Admin::ProjectsController < ApplicationController
if @admin_project.save
redirect_to [:admin, @admin_project], notice: 'Project was successfully created.'
else
render :action => "new"
render action: "new"
end
end
......@@ -50,7 +50,7 @@ class Admin::ProjectsController < ApplicationController
if @admin_project.update_attributes(params[:project])
redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
else
render :action => "edit"
render action: "edit"
end
end
......
......@@ -34,7 +34,7 @@ class Admin::UsersController < ApplicationController
def new
@admin_user = User.new(:projects_limit => Gitlab.config.default_projects_limit)
@admin_user = User.new(projects_limit: Gitlab.config.default_projects_limit)
end
def edit
......
......@@ -11,15 +11,15 @@ class ApplicationController < ActionController::Base
helper_method :abilities, :can?
rescue_from Gitlab::Gitolite::AccessDenied do |exception|
render "errors/gitolite", :layout => "error"
render "errors/gitolite", layout: "error"
end
rescue_from Encoding::CompatibilityError do |exception|
render "errors/encoding", :layout => "error", :status => 404
render "errors/encoding", layout: "error", status: 404
end
rescue_from ActiveRecord::RecordNotFound do |exception|
render "errors/not_found", :layout => "error", :status => 404
render "errors/not_found", layout: "error", status: 404
end
layout :layout_by_resource
......@@ -97,15 +97,15 @@ class ApplicationController < ActionController::Base
end
def access_denied!
render "errors/access_denied", :layout => "error", :status => 404
render "errors/access_denied", layout: "error", status: 404
end
def not_found!
render "errors/not_found", :layout => "error", :status => 404
render "errors/not_found", layout: "error", status: 404
end
def git_not_found!
render "errors/git_not_found", :layout => "error", :status => 404
render "errors/git_not_found", layout: "error", status: 404
end
def method_missing(method_sym, *arguments, &block)
......@@ -127,7 +127,7 @@ class ApplicationController < ActionController::Base
end
def render_404
render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404"
render file: File.join(Rails.root, "public", "404"), layout: false, status: "404"
end
def require_non_empty_project
......
......@@ -9,7 +9,7 @@ class CommitsController < ApplicationController
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
before_filter :load_refs, :only => :index # load @branch, @tag & @ref
before_filter :load_refs, only: :index # load @branch, @tag & @ref
before_filter :render_full_content
def index
......@@ -22,7 +22,7 @@ class CommitsController < ApplicationController
respond_to do |format|
format.html # index.html.erb
format.js
format.atom { render :layout => false }
format.atom { render layout: false }
end
end
......@@ -61,9 +61,9 @@ class CommitsController < ApplicationController
send_data(
@commit.to_patch,
:type => "text/plain",
:disposition => 'attachment',
:filename => (@commit.id.to_s + ".patch")
type: "text/plain",
disposition: 'attachment',
filename: (@commit.id.to_s + ".patch")
)
end
end
......@@ -9,7 +9,7 @@ class DashboardController < ApplicationController
respond_to do |format|
format.html
format.js
format.atom { render :layout => false }
format.atom { render layout: false }
end
end
......@@ -28,7 +28,7 @@ class DashboardController < ApplicationController
respond_to do |format|
format.html
format.atom { render :layout => false }
format.atom { render layout: false }
end
end
end
......@@ -40,7 +40,7 @@ class DeployKeysController < ApplicationController
respond_to do |format|
format.html { redirect_to project_deploy_keys_url }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
end
......@@ -6,7 +6,7 @@ class HooksController < ApplicationController
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, :only => [:new, :create, :destroy]
before_filter :authorize_admin_project!, only: [:new, :create, :destroy]
respond_to :html
......
......@@ -2,7 +2,7 @@ class IssuesController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :module_enabled
before_filter :issue, :only => [:edit, :update, :destroy, :show]
before_filter :issue, only: [:edit, :update, :destroy, :show]
helper_method :issues_filter
layout "project"
......@@ -14,13 +14,13 @@ class IssuesController < ApplicationController
before_filter :authorize_read_issue!
# Allow write(create) issue
before_filter :authorize_write_issue!, :only => [:new, :create]
before_filter :authorize_write_issue!, only: [:new, :create]
# Allow modify issue
before_filter :authorize_modify_issue!, :only => [:close, :edit, :update]
before_filter :authorize_modify_issue!, only: [:close, :edit, :update]
# Allow destroy issue
before_filter :authorize_admin_issue!, :only => [:destroy]
before_filter :authorize_admin_issue!, only: [:destroy]
respond_to :js, :html
......@@ -32,7 +32,7 @@ class IssuesController < ApplicationController
respond_to do |format|
format.html # index.html.erb
format.js
format.atom { render :layout => false }
format.atom { render layout: false }
end
end
......@@ -46,7 +46,7 @@ class IssuesController < ApplicationController
end
def show
@note = @project.notes.new(:noteable => @issue)
@note = @project.notes.new(noteable: @issue)
respond_to do |format|
format.html
......@@ -66,7 +66,7 @@ class IssuesController < ApplicationController
end
def update
@issue.update_attributes(params[:issue].merge(:author_id_of_changes => current_user.id))
@issue.update_attributes(params[:issue].merge(author_id_of_changes: current_user.id))
respond_to do |format|
format.js
......@@ -87,20 +87,20 @@ class IssuesController < ApplicationController
respond_to do |format|
format.html { redirect_to project_issues_path }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
def sort
return render_404 unless can?(current_user, :admin_issue, @project)
@issues = @project.issues.where(:id => params['issue'])
@issues = @project.issues.where(id: params['issue'])
@issues.each do |issue|
issue.position = params['issue'].index(issue.id.to_s) + 1
issue.save
end
render :nothing => true
render nothing: true
end
def search
......@@ -110,12 +110,12 @@ class IssuesController < ApplicationController
@issues = @issues.where("title LIKE ?", "%#{terms}%") unless terms.blank?
@issues = @issues.page(params[:page]).per(100)
render :partial => 'issues'
render partial: 'issues'
end
def bulk_update
result = IssuesBulkUpdateContext.new(project, current_user, params).execute
redirect_to :back, :notice => "#{result[:count]} issues updated"
redirect_to :back, notice: "#{result[:count]} issues updated"
end
protected
......@@ -144,8 +144,8 @@ class IssuesController < ApplicationController
else @project.issues.opened
end
@issues = @issues.where(:assignee_id => params[:assignee_id]) if params[:assignee_id].present?
@issues = @issues.where(:milestone_id => params[:milestone_id]) if params[:milestone_id].present?
@issues = @issues.where(assignee_id: params[:assignee_id]) if params[:assignee_id].present?
@issues = @issues.where(milestone_id: params[:milestone_id]) if params[:milestone_id].present?
@issues = @issues.tagged_with(params[:label_name]) if params[:label_name].present?
@issues = @issues.includes(:author, :project).order("updated_at")
@issues
......
......@@ -29,7 +29,7 @@ class KeysController < ApplicationController
respond_to do |format|
format.html { redirect_to keys_url }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
end
......@@ -2,9 +2,9 @@ class MergeRequestsController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :module_enabled
before_filter :merge_request, :only => [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw]
before_filter :validates_merge_request, :only => [:show, :diffs, :raw]
before_filter :define_show_vars, :only => [:show, :diffs]
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw]
before_filter :validates_merge_request, only: [:show, :diffs, :raw]
before_filter :define_show_vars, only: [:show, :diffs]
layout "project"
# Authorize
......@@ -14,13 +14,13 @@ class MergeRequestsController < ApplicationController
before_filter :authorize_read_merge_request!
# Allow write(create) merge_request
before_filter :authorize_write_merge_request!, :only => [:new, :create]
before_filter :authorize_write_merge_request!, only: [:new, :create]
# Allow modify merge_request
before_filter :authorize_modify_merge_request!, :only => [:close, :edit, :update, :sort]
before_filter :authorize_modify_merge_request!, only: [:close, :edit, :update, :sort]
# Allow destroy merge_request
before_filter :authorize_admin_merge_request!, :only => [:destroy]
before_filter :authorize_admin_merge_request!, only: [:destroy]
def index
......@@ -66,7 +66,7 @@ class MergeRequestsController < ApplicationController
end
def update
if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
if @merge_request.update_attributes(params[:merge_request].merge(author_id_of_changes: current_user.id))
@merge_request.reload_code
@merge_request.mark_as_unchecked
redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.'
......@@ -79,7 +79,7 @@ class MergeRequestsController < ApplicationController
if @merge_request.unchecked?
@merge_request.check_if_can_be_merged
end
render :json => {:state => @merge_request.human_state}
render json: {state: @merge_request.human_state}
end
def automerge
......@@ -138,7 +138,7 @@ class MergeRequestsController < ApplicationController
def define_show_vars
# Build a note object for comment form
@note = @project.notes.new(:noteable => @merge_request)
@note = @project.notes.new(noteable: @merge_request)
# Get commits from repository
# or from cache if already merged
......
......@@ -2,7 +2,7 @@ class MilestonesController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :module_enabled
before_filter :milestone, :only => [:edit, :update, :destroy, :show]
before_filter :milestone, only: [:edit, :update, :destroy, :show]
layout "project"
# Authorize
......@@ -12,7 +12,7 @@ class MilestonesController < ApplicationController
before_filter :authorize_read_milestone!
# Allow admin milestone
before_filter :authorize_admin_milestone!, :except => [:index, :show]
before_filter :authorize_admin_milestone!, except: [:index, :show]
respond_to :html
......@@ -77,7 +77,7 @@ class MilestonesController < ApplicationController
respond_to do |format|
format.html { redirect_to project_milestones_path }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
......
......@@ -5,7 +5,7 @@ class NotesController < ApplicationController
before_filter :add_project_abilities
before_filter :authorize_read_note!
before_filter :authorize_write_note!, :only => [:create]
before_filter :authorize_write_note!, only: [:create]
respond_to :js
......@@ -29,12 +29,12 @@ class NotesController < ApplicationController
@note.destroy
respond_to do |format|
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
def preview
render :text => view_context.markdown(params[:note])
render text: view_context.markdown(params[:note])
end
protected
......
......@@ -26,7 +26,7 @@ class ProfileController < ApplicationController
flash[:notice] = "Password was successfully updated. Please login with it"
redirect_to new_user_session_path
else
render :action => "password"
render action: "password"
end
end
......
require File.join(Rails.root, 'lib', 'graph_commit')
class ProjectsController < ApplicationController
before_filter :project, :except => [:index, :new, :create]
before_filter :project, except: [:index, :new, :create]
layout :determine_layout
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!, :except => [:index, :new, :create]
before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
before_filter :require_non_empty_project, :only => [:blob, :tree, :graph]
before_filter :authorize_read_project!, except: [:index, :new, :create]
before_filter :authorize_admin_project!, only: [:edit, :update, :destroy]
before_filter :require_non_empty_project, only: [:blob, :tree, :graph]
def new
@project = Project.new
......@@ -35,7 +35,7 @@ class ProjectsController < ApplicationController
def update
respond_to do |format|
if project.update_attributes(params[:project])
format.html { redirect_to edit_project_path(project), :notice => 'Project was successfully updated.' }
format.html { redirect_to edit_project_path(project), notice: 'Project was successfully updated.' }
format.js
else
format.html { render action: "edit" }
......
......@@ -6,7 +6,7 @@ class ProtectedBranchesController < ApplicationController
before_filter :authorize_read_project!
before_filter :require_non_empty_project
before_filter :authorize_admin_project!, :only => [:destroy, :create]
before_filter :authorize_admin_project!, only: [:destroy, :create]
before_filter :render_full_content
layout "project"
......@@ -26,7 +26,7 @@ class ProtectedBranchesController < ApplicationController
respond_to do |format|
format.html { redirect_to project_protected_branches_path }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
end
......@@ -9,7 +9,7 @@ class RefsController < ApplicationController
before_filter :require_non_empty_project
before_filter :ref
before_filter :define_tree_vars, :only => [:tree, :blob, :blame, :logs_tree]
before_filter :define_tree_vars, only: [:tree, :blob, :blame, :logs_tree]
before_filter :render_full_content
layout "project"
......@@ -20,7 +20,7 @@ class RefsController < ApplicationController
new_path = if params[:destination] == "tree"
tree_project_ref_path(@project, params[:ref])
else
project_commits_path(@project, :ref => params[:ref])
project_commits_path(@project, ref: params[:ref])
end
redirect_to new_path
......@@ -53,8 +53,8 @@ class RefsController < ApplicationController
last_commit = @project.commits(@commit.id, file, 1).last
last_commit = CommitDecorator.decorate(last_commit)
{
:file_name => content.name,
:commit => last_commit
file_name: content.name,
commit: last_commit
}
end
end
......@@ -70,9 +70,9 @@ class RefsController < ApplicationController
send_data(
@tree.data,
:type => mime_type,
:disposition => 'inline',
:filename => @tree.name
type: mime_type,
disposition: 'inline',
filename: @tree.name
)
else
head(404)
......
......@@ -8,8 +8,8 @@ class SearchController < ApplicationController
if query.present?
@projects = current_user.projects.search(query).limit(10)
@merge_requests = MergeRequest.where(:project_id => current_user.project_ids).search(query).limit(10)
@issues = Issue.where(:project_id => current_user.project_ids).search(query).limit(10)
@merge_requests = MergeRequest.where(project_id: current_user.project_ids).search(query).limit(10)
@issues = Issue.where(project_id: current_user.project_ids).search(query).limit(10)
end
end
end
class SnippetsController < ApplicationController
before_filter :authenticate_user!
before_filter :project
before_filter :snippet, :only => [:show, :edit, :destroy, :update, :raw]
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
layout "project"
# Authorize
......@@ -11,13 +11,13 @@ class SnippetsController < ApplicationController
before_filter :authorize_read_snippet!
# Allow write(create) snippet
before_filter :authorize_write_snippet!, :only => [:new, :create]
before_filter :authorize_write_snippet!, only: [:new, :create]
# Allow modify snippet
before_filter :authorize_modify_snippet!, :only => [:edit, :update]
before_filter :authorize_modify_snippet!, only: [:edit, :update]
# Allow destroy snippet
before_filter :authorize_admin_snippet!, :only => [:destroy]
before_filter :authorize_admin_snippet!, only: [:destroy]
respond_to :html
......@@ -55,7 +55,7 @@ class SnippetsController < ApplicationController
end
def show
@note = @project.notes.new(:noteable => @snippet)
@note = @project.notes.new(noteable: @snippet)
render_full_content
end
......@@ -70,9 +70,9 @@ class SnippetsController < ApplicationController
def raw
send_data(
@snippet.content,
:type => "text/plain",
:disposition => 'inline',
:filename => @snippet.file_name
type: "text/plain",
disposition: 'inline',
filename: @snippet.file_name
)
end
......
......@@ -5,7 +5,7 @@ class TeamMembersController < ApplicationController
# Authorize
before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, :except => [:show]
before_filter :authorize_admin_project!, except: [:show]
def show
@team_member = project.users_projects.find(params[:id])
......@@ -41,7 +41,7 @@ class TeamMembersController < ApplicationController
respond_to do |format|
format.html { redirect_to team_project_path(@project) }
format.js { render :nothing => true }
format.js { render nothing: true }
end
end
end
......@@ -2,8 +2,8 @@ class WikisController < ApplicationController
before_filter :project
before_filter :add_project_abilities
before_filter :authorize_read_wiki!
before_filter :authorize_write_wiki!, :only => [:edit, :create, :history]
before_filter :authorize_admin_wiki!, :only => :destroy
before_filter :authorize_write_wiki!, only: [:edit, :create, :history]
before_filter :authorize_admin_wiki!, only: :destroy
layout "project"
def pages
......@@ -14,16 +14,16 @@ class WikisController < ApplicationController
if params[:old_page_id]
@wiki = @project.wikis.find(params[:old_page_id])
else
@wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
@wiki = @project.wikis.where(slug: params[:id]).order("created_at").last
end
<