Merge branch 'fix-db-after-updating-rails' of https://github.com/Undev/gitlabhq into Undev-fix-db-after-updating-rails

This commit is contained in:
Dmitriy Zaporozhets 2013-02-12 11:13:25 +02:00
commit 4bf63212d7
10 changed files with 23 additions and 23 deletions

View file

@ -19,12 +19,12 @@ module Issuable
validates :title, presence: true, length: { within: 0..255 }
validates :closed, inclusion: { in: [true, false] }
scope :opened, where(closed: false)
scope :closed, where(closed: true)
scope :opened, -> { where(closed: false) }
scope :closed, -> { where(closed: true) }
scope :of_group, ->(group) { where(project_id: group.project_ids) }
scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) }
scope :assigned, ->(u) { where(assignee_id: u.id)}
scope :recent, order("created_at DESC")
scope :recent, -> { order("created_at DESC") }
delegate :name,
:email,

View file

@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
serialize :data
# Scopes
scope :recent, order("created_at DESC")
scope :code_push, where(action: Pushed)
scope :recent, -> { order("created_at DESC") }
scope :code_push, -> { where(action: Pushed) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent }
class << self

View file

@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
has_many :issues
has_many :merge_requests
scope :active, where(closed: false)
scope :closed, where(closed: true)
scope :active, -> { where(closed: false) }
scope :closed, -> { where(closed: true) }
validates :title, presence: true
validates :project, presence: true

View file

@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
after_update :move_dir
after_destroy :rm_dir
scope :root, where('type IS NULL')
scope :root, -> { where('type IS NULL') }
def self.search query
where("name LIKE :query OR path LIKE :query", query: "%#{query}%")

View file

@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
# Scopes
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, where("line_code IS NOT NULL")
scope :not_inline, where("line_code IS NULL")
scope :inline, -> { where("line_code IS NOT NULL") }
scope :not_inline, -> { where("line_code IS NULL") }
scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, ->{ order("created_at ASC, id ASC") }

View file

@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public, where(public: true)
scope :public, -> { where(public: true) }
class << self
def abandoned

View file

@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true
# Scopes
scope :fresh, order("created_at DESC")
scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current])
scope :expired, where(["expires_at IS NOT NULL AND expires_at < ?", Time.current])
scope :fresh, -> { order("created_at DESC") }
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
def self.content_types
[

View file

@ -87,10 +87,10 @@ class User < ActiveRecord::Base
delegate :path, to: :namespace, allow_nil: true, prefix: true
# Scopes
scope :admins, where(admin: true)
scope :blocked, where(blocked: true)
scope :active, where(blocked: false)
scope :alphabetically, order('name ASC')
scope :admins, -> { where(admin: true) }
scope :blocked, -> { where(blocked: true) }
scope :active, -> { where(blocked: false) }
scope :alphabetically, -> { order('name ASC') }
scope :in_team, ->(team){ where(id: team.member_ids) }
scope :not_in_team, ->(team){ where('users.id NOT IN (:ids)', ids: team.member_ids) }
scope :potential_team_members, ->(team) { team.members.any? ? active.not_in_team(team) : active }

View file

@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
delegate :name, :username, :email, to: :user, prefix: true
scope :guests, where(project_access: GUEST)
scope :reporters, where(project_access: REPORTER)
scope :developers, where(project_access: DEVELOPER)
scope :masters, where(project_access: MASTER)
scope :guests, -> { where(project_access: GUEST) }
scope :reporters, -> { where(project_access: REPORTER) }
scope :developers, -> { where(project_access: DEVELOPER) }
scope :masters, -> { where(project_access: MASTER) }
scope :in_project, ->(project) { where(project_id: project.id) }
scope :in_projects, ->(projects) { where(project_id: project_ids) }

View file

@ -123,7 +123,7 @@ FactoryGirl.define do
factory :event do
factory :closed_issue_event do
project
action Event::Closed
action { Event::Closed }
target factory: :closed_issue
author factory: :user
end