Skip to content
Snippets Groups Projects
Commit 77541891 authored by Robert Speicher's avatar Robert Speicher
Browse files

Fully embrace Ruby 1.9 hash syntax

Didn't bother with files in db/, config/, or features/
parent 1413c23c
No related branches found
No related tags found
1 merge request!1219Fully embrace Ruby 1.9 hash syntax
Showing
with 155 additions and 155 deletions
Loading
Loading
@@ -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])
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
@note = @project.notes.new(:noteable => @wiki)
@note = @project.notes.new(noteable: @wiki)
 
if @wiki
render 'show'
else
if can?(current_user, :write_wiki, @project)
@wiki = @project.wikis.new(:slug => params[:id])
@wiki = @project.wikis.new(slug: params[:id])
render 'edit'
else
render 'empty'
Loading
Loading
@@ -32,7 +32,7 @@ class WikisController < ApplicationController
end
 
def edit
@wiki = @project.wikis.where(:slug => params[:id]).order("created_at").last
@wiki = @project.wikis.where(slug: params[:id]).order("created_at").last
@wiki = Wiki.regenerate_from @wiki
end
 
Loading
Loading
@@ -50,11 +50,11 @@ class WikisController < ApplicationController
end
 
def history
@wikis = @project.wikis.where(:slug => params[:id]).order("created_at")
@wikis = @project.wikis.where(slug: params[:id]).order("created_at")
end
def destroy
@wikis = @project.wikis.where(:slug => params[:id]).delete_all
@wikis = @project.wikis.where(slug: params[:id]).delete_all
 
respond_to do |format|
format.html { redirect_to project_wiki_path(@project, :index), notice: "Page was successfully deleted" }
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ class ApplicationDecorator < Drapper::Base
#
# def formatted_timestamp(time)
# h.content_tag :span, time.strftime("%a %m/%d/%y"),
# :class => 'timestamp'
# class: 'timestamp'
# end
#
# def created_at
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ class EventDecorator < ApplicationDecorator
elsif self.merge_request?
h.project_merge_request_url(self.project, self.merge_request)
elsif self.push?
h.project_commits_url(self.project, :ref => self.ref_name)
h.project_commits_url(self.project, ref: self.ref_name)
end
end
end
Loading
Loading
@@ -8,14 +8,14 @@ class TreeDecorator < ApplicationDecorator
 
#parts = parts[0...-1] if is_blob?
 
yield(h.link_to("..", "#", :remote => :true)) if parts.count > max_links
yield(h.link_to("..", "#", remote: :true)) if parts.count > max_links
 
parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty?
part_path = part if part_path.empty?
 
next unless parts.last(2).include?(part) if parts.count > max_links
yield(h.link_to(h.truncate(part, :length => 40), h.tree_file_project_ref_path(project, ref, :path => part_path), :remote => :true))
yield(h.link_to(h.truncate(part, length: 40), h.tree_file_project_ref_path(project, ref, path: part_path), remote: :true))
end
end
end
Loading
Loading
@@ -30,7 +30,7 @@ class TreeDecorator < ApplicationDecorator
end
 
def history_path
h.project_commits_path(project, :path => path, :ref => ref)
h.project_commits_path(project, path: path, ref: ref)
end
 
def mb_size
Loading
Loading
Loading
Loading
@@ -43,23 +43,23 @@ module ApplicationHelper
end
 
def search_autocomplete_source
projects = current_user.projects.map{ |p| { :label => p.name, :url => project_path(p) } }
projects = current_user.projects.map{ |p| { label: p.name, url: project_path(p) } }
default_nav = [
{ :label => "Profile", :url => profile_path },
{ :label => "Keys", :url => keys_path },
{ :label => "Dashboard", :url => root_path },
{ :label => "Admin", :url => admin_root_path }
{ label: "Profile", url: profile_path },
{ label: "Keys", url: keys_path },
{ label: "Dashboard", url: root_path },
{ label: "Admin", url: admin_root_path }
]
 
project_nav = []
 
if @project && !@project.new_record?
project_nav = [
{ :label => "#{@project.name} / Issues", :url => project_issues_path(@project) },
{ :label => "#{@project.name} / Wall", :url => wall_project_path(@project) },
{ :label => "#{@project.name} / Tree", :url => tree_project_ref_path(@project, @project.root_ref) },
{ :label => "#{@project.name} / Commits", :url => project_commits_path(@project) },
{ :label => "#{@project.name} / Team", :url => team_project_path(@project) }
{ label: "#{@project.name} / Issues", url: project_issues_path(@project) },
{ label: "#{@project.name} / Wall", url: wall_project_path(@project) },
{ label: "#{@project.name} / Tree", url: tree_project_ref_path(@project, @project.root_ref) },
{ label: "#{@project.name} / Commits", url: project_commits_path(@project) },
{ label: "#{@project.name} / Team", url: team_project_path(@project) }
]
end
 
Loading
Loading
@@ -89,7 +89,7 @@ module ApplicationHelper
when :wall; wall_tab?
when :wiki; controller.controller_name == "wikis"
when :issues; issues_tab?
when :network; current_page?(:controller => "projects", :action => "graph", :id => @project)
when :network; current_page?(controller: "projects", action: "graph", id: @project)
when :merge_requests; controller.controller_name == "merge_requests"
 
# Dashboard Area
Loading
Loading
@@ -100,10 +100,10 @@ module ApplicationHelper
when :root; current_page?(dashboard_path) || current_page?(root_path)
 
# Profile Area
when :profile; current_page?(:controller => "profile", :action => :show)
when :password; current_page?(:controller => "profile", :action => :password)
when :token; current_page?(:controller => "profile", :action => :token)
when :design; current_page?(:controller => "profile", :action => :design)
when :profile; current_page?(controller: "profile", action: :show)
when :password; current_page?(controller: "profile", action: :password)
when :token; current_page?(controller: "profile", action: :token)
when :design; current_page?(controller: "profile", action: :design)
when :ssh_keys; controller.controller_name == "keys"
 
# Admin Area
Loading
Loading
Loading
Loading
@@ -28,32 +28,32 @@ module GitlabMarkdownHelper
 
# team member: @foo
when /^@/
user = @project.users.where(:name => user_name).first
member = @project.users_projects.where(:user_id => user).first if user
link_to("@#{user_name}", project_team_member_path(@project, member), html_options.merge(:class => "gfm gfm-team_member #{html_options[:class]}")) if member
user = @project.users.where(name: user_name).first
member = @project.users_projects.where(user_id: user).first if user
link_to("@#{user_name}", project_team_member_path(@project, member), html_options.merge(class: "gfm gfm-team_member #{html_options[:class]}")) if member
 
# issue: #123
when /^#/
# avoid HTML entities
unless prefix.try(:end_with?, "&") && suffix.try(:start_with?, ";")
issue = @project.issues.where(:id => issue_id).first
link_to("##{issue_id}", project_issue_path(@project, issue), html_options.merge(:title => "Issue: #{issue.title}", :class => "gfm gfm-issue #{html_options[:class]}")) if issue
issue = @project.issues.where(id: issue_id).first
link_to("##{issue_id}", project_issue_path(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) if issue
end
 
# merge request: !123
when /^!/
merge_request = @project.merge_requests.where(:id => merge_request_id).first
link_to("!#{merge_request_id}", project_merge_request_path(@project, merge_request), html_options.merge(:title => "Merge Request: #{merge_request.title}", :class => "gfm gfm-merge_request #{html_options[:class]}")) if merge_request
merge_request = @project.merge_requests.where(id: merge_request_id).first
link_to("!#{merge_request_id}", project_merge_request_path(@project, merge_request), html_options.merge(title: "Merge Request: #{merge_request.title}", class: "gfm gfm-merge_request #{html_options[:class]}")) if merge_request
 
# snippet: $123
when /^\$/
snippet = @project.snippets.where(:id => snippet_id).first
link_to("$#{snippet_id}", project_snippet_path(@project, snippet), html_options.merge(:title => "Snippet: #{snippet.title}", :class => "gfm gfm-snippet #{html_options[:class]}")) if snippet
snippet = @project.snippets.where(id: snippet_id).first
link_to("$#{snippet_id}", project_snippet_path(@project, snippet), html_options.merge(title: "Snippet: #{snippet.title}", class: "gfm gfm-snippet #{html_options[:class]}")) if snippet
 
# commit: 123456...
when /^\h/
commit = @project.commit(commit_id)
link_to(commit_id, project_commit_path(@project, :id => commit.id), html_options.merge(:title => "Commit: #{commit.author_name} - #{CommitDecorator.new(commit).title}", :class => "gfm gfm-commit #{html_options[:class]}")) if commit
link_to(commit_id, project_commit_path(@project, id: commit.id), html_options.merge(title: "Commit: #{commit.author_name} - #{CommitDecorator.new(commit).title}", class: "gfm gfm-commit #{html_options[:class]}")) if commit
 
end # case
 
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@ module IssuesHelper
 
tm = project.team_member_by_id(issue.assignee_id)
if tm
link_to issue.assignee_name, project_team_member_path(project, tm), :class => "author_link"
link_to issue.assignee_name, project_team_member_path(project, tm), class: "author_link"
else
issue.assignee_name
end
Loading
Loading
@@ -20,7 +20,7 @@ module IssuesHelper
 
tm = project.team_member_by_id(issue.author_id)
if tm
link_to issue.author_name, project_team_member_path(project, tm), :class => "author_link"
link_to issue.author_name, project_team_member_path(project, tm), class: "author_link"
else
issue.author_name
end
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ module MergeRequestsHelper
 
tm = project.team_member_by_id(merge_request.assignee_id)
if tm
link_to merge_request.assignee_name, project_team_member_path(project, tm), :class => "author_link"
link_to merge_request.assignee_name, project_team_member_path(project, tm), class: "author_link"
else
merge_request.assignee_name
end
Loading
Loading
@@ -15,7 +15,7 @@ module MergeRequestsHelper
 
tm = project.team_member_by_id(merge_request.author_id)
if tm
link_to merge_request.author_name, project_team_member_path(project, tm), :class => "author_link"
link_to merge_request.author_name, project_team_member_path(project, tm), class: "author_link"
else
merge_request.author_name
end
Loading
Loading
@@ -24,10 +24,10 @@ module MergeRequestsHelper
def new_mr_path_from_push_event(event)
new_project_merge_request_path(
event.project,
:merge_request => {
:source_branch => event.branch_name,
:target_branch => event.project.root_ref,
:title => event.branch_name.titleize
merge_request: {
source_branch: event.branch_name,
target_branch: event.project.root_ref,
title: event.branch_name.titleize
}
)
end
Loading
Loading
Loading
Loading
@@ -4,12 +4,12 @@ module TabHelper
end
 
def wall_tab?
current_page?(:controller => "projects", :action => "wall", :id => @project)
current_page?(controller: "projects", action: "wall", id: @project)
end
 
def project_tab_class
[:show, :files, :team, :edit, :update].each do |action|
return "current" if current_page?(:controller => "projects", :action => action, :id => @project)
return "current" if current_page?(controller: "projects", action: action, id: @project)
end
 
if ['snippets', 'hooks', 'deploy_keys', 'team_members'].include? controller.controller_name
Loading
Loading
Loading
Loading
@@ -12,20 +12,20 @@ class Notify < ActionMailer::Base
def new_user_email(user_id, password)
@user = User.find(user_id)
@password = password
mail(:to => @user.email, :subject => "gitlab | Account was created for you")
mail(to: @user.email, subject: "gitlab | Account was created for you")
end
 
def new_issue_email(issue_id)
@issue = Issue.find(issue_id)
@project = @issue.project
mail(:to => @issue.assignee_email, :subject => "gitlab | new issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
mail(to: @issue.assignee_email, subject: "gitlab | new issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
end
 
def note_wall_email(recipient_id, note_id)
recipient = User.find(recipient_id)
@note = Note.find(note_id)
@project = @note.project
mail(:to => recipient.email, :subject => "gitlab | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | #{@project.name}")
end
 
def note_commit_email(recipient_id, note_id)
Loading
Loading
@@ -34,7 +34,7 @@ class Notify < ActionMailer::Base
@commit = @note.target
@commit = CommitDecorator.decorate(@commit)
@project = @note.project
mail(:to => recipient.email, :subject => "gitlab | note for commit #{@commit.short_id} | #{@commit.title} | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | note for commit #{@commit.short_id} | #{@commit.title} | #{@project.name}")
end
 
def note_merge_request_email(recipient_id, note_id)
Loading
Loading
@@ -42,7 +42,7 @@ class Notify < ActionMailer::Base
@note = Note.find(note_id)
@merge_request = @note.noteable
@project = @note.project
mail(:to => recipient.email, :subject => "gitlab | note for merge request !#{@merge_request.id} | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | note for merge request !#{@merge_request.id} | #{@project.name}")
end
 
def note_issue_email(recipient_id, note_id)
Loading
Loading
@@ -50,7 +50,7 @@ class Notify < ActionMailer::Base
@note = Note.find(note_id)
@issue = @note.noteable
@project = @note.project
mail(:to => recipient.email, :subject => "gitlab | note for issue ##{@issue.id} | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | note for issue ##{@issue.id} | #{@project.name}")
end
 
def note_wiki_email(recipient_id, note_id)
Loading
Loading
@@ -58,13 +58,13 @@ class Notify < ActionMailer::Base
@note = Note.find(note_id)
@wiki = @note.noteable
@project = @note.project
mail(:to => recipient.email, :subject => "gitlab | note for wiki | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | note for wiki | #{@project.name}")
end
 
def new_merge_request_email(merge_request_id)
@merge_request = MergeRequest.find(merge_request_id)
@project = @merge_request.project
mail(:to => @merge_request.assignee_email, :subject => "gitlab | new merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
mail(to: @merge_request.assignee_email, subject: "gitlab | new merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
end
 
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id)
Loading
Loading
@@ -72,7 +72,7 @@ class Notify < ActionMailer::Base
@merge_request = MergeRequest.find(merge_request_id)
@previous_assignee ||= User.find(previous_assignee_id)
@project = @merge_request.project
mail(:to => recipient.email, :subject => "gitlab | changed merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | changed merge request !#{@merge_request.id} | #{@merge_request.title} | #{@project.name}")
end
 
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id)
Loading
Loading
@@ -80,6 +80,6 @@ class Notify < ActionMailer::Base
@issue = Issue.find(issue_id)
@previous_assignee ||= User.find(previous_assignee_id)
@project = @issue.project
mail(:to => recipient.email, :subject => "gitlab | changed issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
mail(to: recipient.email, subject: "gitlab | changed issue ##{@issue.id} | #{@issue.title} | #{@project.name}")
end
end
Loading
Loading
@@ -20,7 +20,7 @@ class Commit
:tree,
:id,
:to_patch,
:to => :commit
to: :commit
 
 
class << self
Loading
Loading
@@ -57,7 +57,7 @@ class Commit
 
def commits_since(repo, date)
commits = repo.heads.map do |h|
repo.log(h.name, nil, :since => date).each { |c| Commit.new(c, h) }
repo.log(h.name, nil, since: date).each { |c| Commit.new(c, h) }
end.flatten.uniq { |c| c.id }
 
commits.sort! do |x, y|
Loading
Loading
@@ -69,7 +69,7 @@ class Commit
 
def commits(repo, ref, path = nil, limit = nil, offset = nil)
if path
repo.log(ref, path, :max_count => limit, :skip => offset)
repo.log(ref, path, max_count: limit, skip: offset)
elsif limit && offset
repo.commits(ref, limit, offset)
else
Loading
Loading
@@ -86,9 +86,9 @@ class Commit
last = project.commit(from.try(:strip))
 
result = {
:commits => [],
:diffs => [],
:commit => nil
commits: [],
diffs: [],
commit: nil
}
 
if first && last
Loading
Loading
Loading
Loading
@@ -12,13 +12,13 @@ class Event < ActiveRecord::Base
Merged = 7
 
belongs_to :project
belongs_to :target, :polymorphic => true
belongs_to :target, polymorphic: true
 
# For Hash only
serialize :data
 
scope :recent, order("created_at DESC")
scope :code_push, where(:action => Pushed)
scope :code_push, where(action: Pushed)
 
def self.determine_action(record)
if [Issue, MergeRequest].include? record.class
Loading
Loading
@@ -29,7 +29,7 @@ class Event < ActiveRecord::Base
end
 
def self.recent_for_user user
where(:project_id => user.projects.map(&:id)).recent
where(project_id: user.projects.map(&:id)).recent
end
 
# Next events currently enabled for system
Loading
Loading
@@ -106,9 +106,9 @@ class Event < ActiveRecord::Base
end
end
 
delegate :name, :email, :to => :author, :prefix => true, :allow_nil => true
delegate :title, :to => :issue, :prefix => true, :allow_nil => true
delegate :title, :to => :merge_request, :prefix => true, :allow_nil => true
delegate :name, :email, to: :author, prefix: true, allow_nil: true
delegate :title, to: :issue, prefix: true, allow_nil: true
delegate :title, to: :merge_request, prefix: true, allow_nil: true
end
# == Schema Information
#
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class Issue < ActiveRecord::Base
belongs_to :milestone
 
validates :description,
:length => { :within => 0..2000 }
length: { within: 0..2000 }
 
acts_as_list
 
Loading
Loading
Loading
Loading
@@ -6,16 +6,16 @@ class Key < ActiveRecord::Base
belongs_to :project
 
validates :title,
:presence => true,
:length => { :within => 0..255 }
presence: true,
length: { within: 0..255 }
 
validates :key,
:presence => true,
:length => { :within => 0..5000 }
presence: true,
length: { within: 0..5000 }
 
before_save :set_identifier
before_validation :strip_white_space
delegate :name, :email, :to => :user, :prefix => true
delegate :name, :email, to: :user, prefix: true
validate :unique_key
 
def strip_white_space
Loading
Loading
@@ -23,7 +23,7 @@ class Key < ActiveRecord::Base
end
 
def unique_key
query = Key.where(:key => key)
query = Key.where(key: key)
query = query.where('(project_id IS NULL OR project_id = ?)', project_id) if project_id
if (query.count > 0)
errors.add :key, 'already exist.'
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ class MergeRequest < ActiveRecord::Base
validate :validate_branches
 
def self.find_all_by_branch(branch_name)
where("source_branch like :branch or target_branch like :branch", :branch => branch_name)
where("source_branch like :branch or target_branch like :branch", branch: branch_name)
end
 
def human_state
Loading
Loading
@@ -48,7 +48,7 @@ class MergeRequest < ActiveRecord::Base
end
 
def mark_as_unchecked
self.update_attributes(:state => UNCHECKED)
self.update_attributes(state: UNCHECKED)
end
 
def can_be_merged?
Loading
Loading
@@ -101,11 +101,11 @@ class MergeRequest < ActiveRecord::Base
end
 
def merge_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Merged).last
self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Merged).last
end
 
def closed_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Closed).last
self.project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::Closed).last
end
 
def commits
Loading
Loading
@@ -128,7 +128,7 @@ class MergeRequest < ActiveRecord::Base
end
 
def mark_as_unmergable
self.update_attributes :state => CANNOT_BE_MERGED
self.update_attributes state: CANNOT_BE_MERGED
end
 
def reloaded_commits
Loading
Loading
@@ -150,11 +150,11 @@ class MergeRequest < ActiveRecord::Base
def merge!(user_id)
self.mark_as_merged!
Event.create(
:project => self.project,
:action => Event::Merged,
:target_id => self.id,
:target_type => "MergeRequest",
:author_id => user_id
project: self.project,
action: Event::Merged,
target_id: self.id,
target_type: "MergeRequest",
author_id: user_id
)
end
 
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ class Milestone < ActiveRecord::Base
end
 
def participants
User.where(:id => issues.map(&:assignee_id))
User.where(id: issues.map(&:assignee_id))
end
 
def percent_complete
Loading
Loading
Loading
Loading
@@ -3,18 +3,18 @@ require 'file_size_validator'
 
class Note < ActiveRecord::Base
belongs_to :project
belongs_to :noteable, :polymorphic => true
belongs_to :noteable, polymorphic: true
belongs_to :author,
:class_name => "User"
class_name: "User"
 
delegate :name,
:to => :project,
:prefix => true
to: :project,
prefix: true
 
delegate :name,
:email,
:to => :author,
:prefix => true
to: :author,
prefix: true
 
attr_protected :author, :author_id
attr_accessor :notify
Loading
Loading
@@ -23,19 +23,19 @@ class Note < ActiveRecord::Base
validates_presence_of :project
 
validates :note,
:presence => true,
:length => { :within => 0..5000 }
presence: true,
length: { within: 0..5000 }
 
validates :attachment,
:file_size => {
:maximum => 10.megabytes.to_i
file_size: {
maximum: 10.megabytes.to_i
}
 
scope :common, where(:noteable_id => nil)
scope :common, where(noteable_id: nil)
 
scope :today, where("created_at >= :date", :date => Date.today)
scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
scope :since, lambda { |day| where("created_at >= :date", :date => (day)) }
scope :today, where("created_at >= :date", date: Date.today)
scope :last_week, where("created_at >= :date", date: (Date.today - 7.days))
scope :since, lambda { |day| where("created_at >= :date", date: (day)) }
scope :fresh, order("created_at DESC")
scope :inc_author_project, includes(:project, :author)
scope :inc_author, includes(:author)
Loading
Loading
@@ -43,11 +43,11 @@ class Note < ActiveRecord::Base
mount_uploader :attachment, AttachmentUploader
 
def self.create_status_change_note(noteable, author, status)
create({ :noteable => noteable,
:project => noteable.project,
:author => author,
:note => "_Status changed to #{status}_" },
:without_protection => true)
create({ noteable: noteable,
project: noteable.project,
author: author,
note: "_Status changed to #{status}_" },
without_protection: true)
end
 
def notify
Loading
Loading
Loading
Loading
@@ -9,19 +9,19 @@ class Project < ActiveRecord::Base
#
# Relations
#
belongs_to :owner, :class_name => "User"
has_many :users, :through => :users_projects
has_many :events, :dependent => :destroy
has_many :merge_requests, :dependent => :destroy
has_many :issues, :dependent => :destroy, :order => "closed, created_at DESC"
has_many :milestones, :dependent => :destroy
has_many :users_projects, :dependent => :destroy
has_many :notes, :dependent => :destroy
has_many :snippets, :dependent => :destroy
has_many :deploy_keys, :dependent => :destroy, :foreign_key => "project_id", :class_name => "Key"
has_many :hooks, :dependent => :destroy, :class_name => "ProjectHook"
has_many :wikis, :dependent => :destroy
has_many :protected_branches, :dependent => :destroy
belongs_to :owner, class_name: "User"
has_many :users, through: :users_projects
has_many :events, dependent: :destroy
has_many :merge_requests, dependent: :destroy
has_many :issues, dependent: :destroy, order: "closed, created_at DESC"
has_many :milestones, dependent: :destroy
has_many :users_projects, dependent: :destroy
has_many :notes, dependent: :destroy
has_many :snippets, dependent: :destroy
has_many :deploy_keys, dependent: :destroy, foreign_key: "project_id", class_name: "Key"
has_many :hooks, dependent: :destroy, class_name: "ProjectHook"
has_many :wikis, dependent: :destroy
has_many :protected_branches, dependent: :destroy
 
attr_accessor :error_code
 
Loading
Loading
@@ -33,15 +33,15 @@ class Project < ActiveRecord::Base
#
# Scopes
#
scope :public_only, where(:private_flag => false)
scope :without_user, lambda { |user| where("id not in (:ids)", :ids => user.projects.map(&:id) ) }
scope :public_only, where(private_flag: false)
scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) }
 
def self.active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
end
 
def self.search query
where("name like :query or code like :query or path like :query", :query => "%#{query}%")
where("name like :query or code like :query or path like :query", query: "%#{query}%")
end
 
def self.create_by_user(params, user)
Loading
Loading
@@ -53,7 +53,7 @@ class Project < ActiveRecord::Base
project.save!
 
# Add user as project master
project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user)
project.users_projects.create!(project_access: UsersProject::MASTER, user: user)
 
# when project saved no team member exist so
# project repository should be updated after first user add
Loading
Loading
@@ -82,28 +82,28 @@ class Project < ActiveRecord::Base
# Validations
#
validates :name,
:uniqueness => true,
:presence => true,
:length => { :within => 0..255 }
uniqueness: true,
presence: true,
length: { within: 0..255 }
 
validates :path,
:uniqueness => true,
:presence => true,
:format => { :with => /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/,
:message => "only letters, digits & '_' '-' '.' allowed. Letter should be first" },
:length => { :within => 0..255 }
uniqueness: true,
presence: true,
format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/,
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" },
length: { within: 0..255 }
 
validates :description,
:length => { :within => 0..2000 }
length: { within: 0..2000 }
 
validates :code,
:presence => true,
:uniqueness => true,
:format => { :with => /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/,
:message => "only letters, digits & '_' '-' '.' allowed. Letter should be first" },
:length => { :within => 1..255 }
presence: true,
uniqueness: true,
format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/,
message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" },
length: { within: 1..255 }
 
validates :owner, :presence => true
validates :owner, presence: true
validate :check_limit
validate :repo_name
 
Loading
Loading
@@ -134,19 +134,19 @@ class Project < ActiveRecord::Base
end
 
def common_notes
notes.where(:noteable_type => ["", nil]).inc_author_project
notes.where(noteable_type: ["", nil]).inc_author_project
end
 
def build_commit_note(commit)
notes.new(:noteable_id => commit.id, :noteable_type => "Commit")
notes.new(noteable_id: commit.id, noteable_type: "Commit")
end
 
def commit_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit", :line_code => nil)
notes.where(noteable_id: commit.id, noteable_type: "Commit", line_code: nil)
end
 
def commit_line_notes(commit)
notes.where(:noteable_id => commit.id, :noteable_type => "Commit").where("line_code is not null")
notes.where(noteable_id: commit.id, noteable_type: "Commit").where("line_code is not null")
end
 
def public?
Loading
Loading
Loading
Loading
@@ -2,29 +2,29 @@ class Snippet < ActiveRecord::Base
include Linguist::BlobHelper
 
belongs_to :project
belongs_to :author, :class_name => "User"
has_many :notes, :as => :noteable, :dependent => :destroy
belongs_to :author, class_name: "User"
has_many :notes, as: :noteable, dependent: :destroy
 
delegate :name,
:email,
:to => :author,
:prefix => true
to: :author,
prefix: true
attr_protected :author, :author_id, :project, :project_id
 
validates_presence_of :project_id
validates_presence_of :author_id
 
validates :title,
:presence => true,
:length => { :within => 0..255 }
presence: true,
length: { within: 0..255 }
 
validates :file_name,
:presence => true,
:length => { :within => 0..255 }
presence: true,
length: { within: 0..255 }
 
validates :content,
:presence => true,
:length => { :within => 0..10000 }
presence: true,
length: { within: 0..10000 }
 
scope :fresh, order("created_at DESC")
scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current])
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment