Commit e0d0c1b225e6d693b7a43b09b74f97dd70444433
Exists in
master
and in
4 other branches
Merge pull request #1570 from NARKOZ/refactoring
models cleanup
Showing
21 changed files
with
181 additions
and
284 deletions
Show diff stats
app/models/ability.rb
app/models/commit.rb
| @@ -4,24 +4,11 @@ class Commit | @@ -4,24 +4,11 @@ class Commit | ||
| 4 | include StaticModel | 4 | include StaticModel |
| 5 | extend ActiveModel::Naming | 5 | extend ActiveModel::Naming |
| 6 | 6 | ||
| 7 | - attr_accessor :commit | ||
| 8 | - attr_accessor :head | ||
| 9 | - attr_accessor :refs | ||
| 10 | - | ||
| 11 | - delegate :message, | ||
| 12 | - :authored_date, | ||
| 13 | - :committed_date, | ||
| 14 | - :parents, | ||
| 15 | - :sha, | ||
| 16 | - :date, | ||
| 17 | - :committer, | ||
| 18 | - :author, | ||
| 19 | - :message, | ||
| 20 | - :diffs, | ||
| 21 | - :tree, | ||
| 22 | - :id, | ||
| 23 | - :to_patch, | ||
| 24 | - to: :commit | 7 | + attr_accessor :commit, :head, :refs |
| 8 | + | ||
| 9 | + delegate :message, :authored_date, :committed_date, :parents, :sha, | ||
| 10 | + :date, :committer, :author, :message, :diffs, :tree, :id, | ||
| 11 | + :to_patch, to: :commit | ||
| 25 | 12 | ||
| 26 | class << self | 13 | class << self |
| 27 | def find_or_first(repo, commit_id = nil, root_ref) | 14 | def find_or_first(repo, commit_id = nil, root_ref) |
| @@ -30,6 +17,7 @@ class Commit | @@ -30,6 +17,7 @@ class Commit | ||
| 30 | else | 17 | else |
| 31 | repo.commits(root_ref).first | 18 | repo.commits(root_ref).first |
| 32 | end | 19 | end |
| 20 | + | ||
| 33 | Commit.new(commit) if commit | 21 | Commit.new(commit) if commit |
| 34 | end | 22 | end |
| 35 | 23 |
app/models/event.rb
| @@ -16,6 +16,10 @@ class Event < ActiveRecord::Base | @@ -16,6 +16,10 @@ class Event < ActiveRecord::Base | ||
| 16 | Joined = 8 # User joined project | 16 | Joined = 8 # User joined project |
| 17 | Left = 9 # User left project | 17 | Left = 9 # User left project |
| 18 | 18 | ||
| 19 | + delegate :name, :email, to: :author, prefix: true, allow_nil: true | ||
| 20 | + delegate :title, to: :issue, prefix: true, allow_nil: true | ||
| 21 | + delegate :title, to: :merge_request, prefix: true, allow_nil: true | ||
| 22 | + | ||
| 19 | belongs_to :project | 23 | belongs_to :project |
| 20 | belongs_to :target, polymorphic: true | 24 | belongs_to :target, polymorphic: true |
| 21 | 25 | ||
| @@ -134,25 +138,20 @@ class Event < ActiveRecord::Base | @@ -134,25 +138,20 @@ class Event < ActiveRecord::Base | ||
| 134 | "opened" | 138 | "opened" |
| 135 | end | 139 | end |
| 136 | end | 140 | end |
| 137 | - | ||
| 138 | - | ||
| 139 | - delegate :name, :email, to: :author, prefix: true, allow_nil: true | ||
| 140 | - delegate :title, to: :issue, prefix: true, allow_nil: true | ||
| 141 | - delegate :title, to: :merge_request, prefix: true, allow_nil: true | ||
| 142 | end | 141 | end |
| 142 | + | ||
| 143 | # == Schema Information | 143 | # == Schema Information |
| 144 | # | 144 | # |
| 145 | # Table name: events | 145 | # Table name: events |
| 146 | # | 146 | # |
| 147 | -# id :integer(4) not null, primary key | 147 | +# id :integer not null, primary key |
| 148 | # target_type :string(255) | 148 | # target_type :string(255) |
| 149 | -# target_id :integer(4) | 149 | +# target_id :integer |
| 150 | # title :string(255) | 150 | # title :string(255) |
| 151 | # data :text | 151 | # data :text |
| 152 | -# project_id :integer(4) | 152 | +# project_id :integer |
| 153 | # created_at :datetime not null | 153 | # created_at :datetime not null |
| 154 | # updated_at :datetime not null | 154 | # updated_at :datetime not null |
| 155 | -# action :integer(4) | ||
| 156 | -# author_id :integer(4) | 155 | +# action :integer |
| 156 | +# author_id :integer | ||
| 157 | # | 157 | # |
| 158 | - |
app/models/issue.rb
| @@ -9,8 +9,7 @@ class Issue < ActiveRecord::Base | @@ -9,8 +9,7 @@ class Issue < ActiveRecord::Base | ||
| 9 | 9 | ||
| 10 | belongs_to :milestone | 10 | belongs_to :milestone |
| 11 | 11 | ||
| 12 | - validates :description, | ||
| 13 | - length: { within: 0..2000 } | 12 | + validates :description, length: { within: 0..2000 } |
| 14 | 13 | ||
| 15 | def self.open_for(user) | 14 | def self.open_for(user) |
| 16 | opened.assigned(user) | 15 | opened.assigned(user) |
| @@ -32,22 +31,21 @@ class Issue < ActiveRecord::Base | @@ -32,22 +31,21 @@ class Issue < ActiveRecord::Base | ||
| 32 | closed_changed? && !closed | 31 | closed_changed? && !closed |
| 33 | end | 32 | end |
| 34 | end | 33 | end |
| 34 | + | ||
| 35 | # == Schema Information | 35 | # == Schema Information |
| 36 | # | 36 | # |
| 37 | # Table name: issues | 37 | # Table name: issues |
| 38 | # | 38 | # |
| 39 | -# id :integer(4) not null, primary key | 39 | +# id :integer not null, primary key |
| 40 | # title :string(255) | 40 | # title :string(255) |
| 41 | -# assignee_id :integer(4) | ||
| 42 | -# author_id :integer(4) | ||
| 43 | -# project_id :integer(4) | 41 | +# assignee_id :integer |
| 42 | +# author_id :integer | ||
| 43 | +# project_id :integer | ||
| 44 | # created_at :datetime not null | 44 | # created_at :datetime not null |
| 45 | # updated_at :datetime not null | 45 | # updated_at :datetime not null |
| 46 | -# closed :boolean(1) default(FALSE), not null | ||
| 47 | -# position :integer(4) default(0) | ||
| 48 | -# critical :boolean(1) default(FALSE), not null | 46 | +# closed :boolean default(FALSE), not null |
| 47 | +# position :integer default(0) | ||
| 49 | # branch_name :string(255) | 48 | # branch_name :string(255) |
| 50 | # description :text | 49 | # description :text |
| 51 | -# milestone_id :integer(4) | 50 | +# milestone_id :integer |
| 52 | # | 51 | # |
| 53 | - |
app/models/key.rb
| @@ -6,14 +6,10 @@ class Key < ActiveRecord::Base | @@ -6,14 +6,10 @@ class Key < ActiveRecord::Base | ||
| 6 | 6 | ||
| 7 | attr_accessible :key, :title | 7 | attr_accessible :key, :title |
| 8 | 8 | ||
| 9 | - validates :title, | ||
| 10 | - presence: true, | ||
| 11 | - length: { within: 0..255 } | ||
| 12 | - | ||
| 13 | - validates :key, | ||
| 14 | - presence: true, | ||
| 15 | - format: { :with => /ssh-.{3} / }, | ||
| 16 | - length: { within: 0..5000 } | 9 | + validates :title, presence: true, length: { within: 0..255 } |
| 10 | + validates :key, presence: true, | ||
| 11 | + length: { within: 0..5000 }, | ||
| 12 | + format: { :with => /ssh-.{3} / } | ||
| 17 | 13 | ||
| 18 | before_save :set_identifier | 14 | before_save :set_identifier |
| 19 | before_validation :strip_white_space | 15 | before_validation :strip_white_space |
| @@ -34,7 +30,7 @@ class Key < ActiveRecord::Base | @@ -34,7 +30,7 @@ class Key < ActiveRecord::Base | ||
| 34 | 30 | ||
| 35 | def set_identifier | 31 | def set_identifier |
| 36 | if is_deploy_key | 32 | if is_deploy_key |
| 37 | - self.identifier = "deploy_" + Digest::MD5.hexdigest(key) | 33 | + self.identifier = "deploy_#{Digest::MD5.hexdigest(key)}" |
| 38 | else | 34 | else |
| 39 | self.identifier = "#{user.identifier}_#{Time.now.to_i}" | 35 | self.identifier = "#{user.identifier}_#{Time.now.to_i}" |
| 40 | end | 36 | end |
| @@ -57,17 +53,17 @@ class Key < ActiveRecord::Base | @@ -57,17 +53,17 @@ class Key < ActiveRecord::Base | ||
| 57 | Key.where(identifier: identifier).count == 0 | 53 | Key.where(identifier: identifier).count == 0 |
| 58 | end | 54 | end |
| 59 | end | 55 | end |
| 56 | + | ||
| 60 | # == Schema Information | 57 | # == Schema Information |
| 61 | # | 58 | # |
| 62 | # Table name: keys | 59 | # Table name: keys |
| 63 | # | 60 | # |
| 64 | -# id :integer(4) not null, primary key | ||
| 65 | -# user_id :integer(4) | 61 | +# id :integer not null, primary key |
| 62 | +# user_id :integer | ||
| 66 | # created_at :datetime not null | 63 | # created_at :datetime not null |
| 67 | # updated_at :datetime not null | 64 | # updated_at :datetime not null |
| 68 | # key :text | 65 | # key :text |
| 69 | # title :string(255) | 66 | # title :string(255) |
| 70 | # identifier :string(255) | 67 | # identifier :string(255) |
| 71 | -# project_id :integer(4) | 68 | +# project_id :integer |
| 72 | # | 69 | # |
| 73 | - |
app/models/merge_request.rb
| @@ -18,8 +18,7 @@ class MergeRequest < ActiveRecord::Base | @@ -18,8 +18,7 @@ class MergeRequest < ActiveRecord::Base | ||
| 18 | 18 | ||
| 19 | attr_accessor :should_remove_source_branch | 19 | attr_accessor :should_remove_source_branch |
| 20 | 20 | ||
| 21 | - validates_presence_of :source_branch | ||
| 22 | - validates_presence_of :target_branch | 21 | + validates_presence_of :source_branch, :target_branch |
| 23 | validate :validate_branches | 22 | validate :validate_branches |
| 24 | 23 | ||
| 25 | def self.find_all_by_branch(branch_name) | 24 | def self.find_all_by_branch(branch_name) |
| @@ -187,23 +186,23 @@ class MergeRequest < ActiveRecord::Base | @@ -187,23 +186,23 @@ class MergeRequest < ActiveRecord::Base | ||
| 187 | patch_path | 186 | patch_path |
| 188 | end | 187 | end |
| 189 | end | 188 | end |
| 189 | + | ||
| 190 | # == Schema Information | 190 | # == Schema Information |
| 191 | # | 191 | # |
| 192 | # Table name: merge_requests | 192 | # Table name: merge_requests |
| 193 | # | 193 | # |
| 194 | -# id :integer(4) not null, primary key | 194 | +# id :integer not null, primary key |
| 195 | # target_branch :string(255) not null | 195 | # target_branch :string(255) not null |
| 196 | # source_branch :string(255) not null | 196 | # source_branch :string(255) not null |
| 197 | -# project_id :integer(4) not null | ||
| 198 | -# author_id :integer(4) | ||
| 199 | -# assignee_id :integer(4) | 197 | +# project_id :integer not null |
| 198 | +# author_id :integer | ||
| 199 | +# assignee_id :integer | ||
| 200 | # title :string(255) | 200 | # title :string(255) |
| 201 | -# closed :boolean(1) default(FALSE), not null | 201 | +# closed :boolean default(FALSE), not null |
| 202 | # created_at :datetime not null | 202 | # created_at :datetime not null |
| 203 | # updated_at :datetime not null | 203 | # updated_at :datetime not null |
| 204 | # st_commits :text(2147483647 | 204 | # st_commits :text(2147483647 |
| 205 | # st_diffs :text(2147483647 | 205 | # st_diffs :text(2147483647 |
| 206 | -# merged :boolean(1) default(FALSE), not null | ||
| 207 | -# state :integer(4) default(1), not null | 206 | +# merged :boolean default(FALSE), not null |
| 207 | +# state :integer default(1), not null | ||
| 208 | # | 208 | # |
| 209 | - |
app/models/milestone.rb
| 1 | -# == Schema Information | ||
| 2 | -# | ||
| 3 | -# Table name: milestones | ||
| 4 | -# | ||
| 5 | -# id :integer(4) not null, primary key | ||
| 6 | -# title :string(255) not null | ||
| 7 | -# project_id :integer(4) not null | ||
| 8 | -# description :text | ||
| 9 | -# due_date :date | ||
| 10 | -# closed :boolean(1) default(FALSE), not null | ||
| 11 | -# created_at :datetime not null | ||
| 12 | -# updated_at :datetime not null | ||
| 13 | -# | ||
| 14 | - | ||
| 15 | class Milestone < ActiveRecord::Base | 1 | class Milestone < ActiveRecord::Base |
| 16 | attr_accessible :title, :description, :due_date, :closed | 2 | attr_accessible :title, :description, :due_date, :closed |
| 17 | 3 | ||
| 18 | belongs_to :project | 4 | belongs_to :project |
| 19 | has_many :issues | 5 | has_many :issues |
| 20 | 6 | ||
| 21 | - validates_presence_of :project_id | ||
| 22 | - validates_presence_of :title | 7 | + validates_presence_of :title, :project_id |
| 23 | 8 | ||
| 24 | def self.active | 9 | def self.active |
| 25 | where("due_date > ? OR due_date IS NULL", Date.today) | 10 | where("due_date > ? OR due_date IS NULL", Date.today) |
| 26 | end | 11 | end |
| 27 | 12 | ||
| 28 | def participants | 13 | def participants |
| 29 | - User.where(id: issues.map(&:assignee_id)) | 14 | + User.where(id: issues.pluck(:assignee_id)) |
| 30 | end | 15 | end |
| 31 | 16 | ||
| 32 | def percent_complete | 17 | def percent_complete |
| @@ -39,3 +24,17 @@ class Milestone < ActiveRecord::Base | @@ -39,3 +24,17 @@ class Milestone < ActiveRecord::Base | ||
| 39 | "expires at #{due_date.stamp("Aug 21, 2011")}" if due_date | 24 | "expires at #{due_date.stamp("Aug 21, 2011")}" if due_date |
| 40 | end | 25 | end |
| 41 | end | 26 | end |
| 27 | + | ||
| 28 | +# == Schema Information | ||
| 29 | +# | ||
| 30 | +# Table name: milestones | ||
| 31 | +# | ||
| 32 | +# id :integer not null, primary key | ||
| 33 | +# title :string(255) not null | ||
| 34 | +# project_id :integer not null | ||
| 35 | +# description :text | ||
| 36 | +# due_date :date | ||
| 37 | +# closed :boolean default(FALSE), not null | ||
| 38 | +# created_at :datetime not null | ||
| 39 | +# updated_at :datetime not null | ||
| 40 | +# |
app/models/note.rb
| @@ -2,39 +2,26 @@ require 'carrierwave/orm/activerecord' | @@ -2,39 +2,26 @@ require 'carrierwave/orm/activerecord' | ||
| 2 | require 'file_size_validator' | 2 | require 'file_size_validator' |
| 3 | 3 | ||
| 4 | class Note < ActiveRecord::Base | 4 | class Note < ActiveRecord::Base |
| 5 | + mount_uploader :attachment, AttachmentUploader | ||
| 5 | attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, | 6 | attr_accessible :note, :noteable, :noteable_id, :noteable_type, :project_id, |
| 6 | :attachment, :line_code | 7 | :attachment, :line_code |
| 7 | 8 | ||
| 8 | belongs_to :project | 9 | belongs_to :project |
| 9 | belongs_to :noteable, polymorphic: true | 10 | belongs_to :noteable, polymorphic: true |
| 10 | - belongs_to :author, | ||
| 11 | - class_name: "User" | 11 | + belongs_to :author, class_name: "User" |
| 12 | 12 | ||
| 13 | - delegate :name, | ||
| 14 | - to: :project, | ||
| 15 | - prefix: true | ||
| 16 | - | ||
| 17 | - delegate :name, | ||
| 18 | - :email, | ||
| 19 | - to: :author, | ||
| 20 | - prefix: true | 13 | + delegate :name, to: :project, prefix: true |
| 14 | + delegate :name, :email, to: :author, prefix: true | ||
| 21 | 15 | ||
| 22 | attr_accessor :notify | 16 | attr_accessor :notify |
| 23 | attr_accessor :notify_author | 17 | attr_accessor :notify_author |
| 24 | 18 | ||
| 25 | validates_presence_of :project | 19 | validates_presence_of :project |
| 26 | 20 | ||
| 27 | - validates :note, | ||
| 28 | - presence: true, | ||
| 29 | - length: { within: 0..5000 } | ||
| 30 | - | ||
| 31 | - validates :attachment, | ||
| 32 | - file_size: { | ||
| 33 | - maximum: 10.megabytes.to_i | ||
| 34 | - } | 21 | + validates :note, presence: true, length: { within: 0..5000 } |
| 22 | + validates :attachment, file_size: { maximum: 10.megabytes.to_i } | ||
| 35 | 23 | ||
| 36 | scope :common, where(noteable_id: nil) | 24 | scope :common, where(noteable_id: nil) |
| 37 | - | ||
| 38 | scope :today, where("created_at >= :date", date: Date.today) | 25 | scope :today, where("created_at >= :date", date: Date.today) |
| 39 | scope :last_week, where("created_at >= :date", date: (Date.today - 7.days)) | 26 | scope :last_week, where("created_at >= :date", date: (Date.today - 7.days)) |
| 40 | scope :since, lambda { |day| where("created_at >= :date", date: (day)) } | 27 | scope :since, lambda { |day| where("created_at >= :date", date: (day)) } |
| @@ -42,14 +29,13 @@ class Note < ActiveRecord::Base | @@ -42,14 +29,13 @@ class Note < ActiveRecord::Base | ||
| 42 | scope :inc_author_project, includes(:project, :author) | 29 | scope :inc_author_project, includes(:project, :author) |
| 43 | scope :inc_author, includes(:author) | 30 | scope :inc_author, includes(:author) |
| 44 | 31 | ||
| 45 | - mount_uploader :attachment, AttachmentUploader | ||
| 46 | - | ||
| 47 | def self.create_status_change_note(noteable, author, status) | 32 | def self.create_status_change_note(noteable, author, status) |
| 48 | - create({ noteable: noteable, | ||
| 49 | - project: noteable.project, | ||
| 50 | - author: author, | ||
| 51 | - note: "_Status changed to #{status}_" }, | ||
| 52 | - without_protection: true) | 33 | + create({ |
| 34 | + noteable: noteable, | ||
| 35 | + project: noteable.project, | ||
| 36 | + author: author, | ||
| 37 | + note: "_Status changed to #{status}_" | ||
| 38 | + }, without_protection: true) | ||
| 53 | end | 39 | end |
| 54 | 40 | ||
| 55 | def notify | 41 | def notify |
| @@ -114,19 +100,19 @@ class Note < ActiveRecord::Base | @@ -114,19 +100,19 @@ class Note < ActiveRecord::Base | ||
| 114 | note.start_with?('-1') || note.start_with?(':-1:') | 100 | note.start_with?('-1') || note.start_with?(':-1:') |
| 115 | end | 101 | end |
| 116 | end | 102 | end |
| 103 | + | ||
| 117 | # == Schema Information | 104 | # == Schema Information |
| 118 | # | 105 | # |
| 119 | # Table name: notes | 106 | # Table name: notes |
| 120 | # | 107 | # |
| 121 | -# id :integer(4) not null, primary key | 108 | +# id :integer not null, primary key |
| 122 | # note :text | 109 | # note :text |
| 123 | # noteable_id :string(255) | 110 | # noteable_id :string(255) |
| 124 | # noteable_type :string(255) | 111 | # noteable_type :string(255) |
| 125 | -# author_id :integer(4) | 112 | +# author_id :integer |
| 126 | # created_at :datetime not null | 113 | # created_at :datetime not null |
| 127 | # updated_at :datetime not null | 114 | # updated_at :datetime not null |
| 128 | -# project_id :integer(4) | 115 | +# project_id :integer |
| 129 | # attachment :string(255) | 116 | # attachment :string(255) |
| 130 | # line_code :string(255) | 117 | # line_code :string(255) |
| 131 | # | 118 | # |
| 132 | - |
app/models/project.rb
| @@ -8,10 +8,9 @@ class Project < ActiveRecord::Base | @@ -8,10 +8,9 @@ class Project < ActiveRecord::Base | ||
| 8 | 8 | ||
| 9 | attr_accessible :name, :path, :description, :code, :default_branch, :issues_enabled, | 9 | attr_accessible :name, :path, :description, :code, :default_branch, :issues_enabled, |
| 10 | :wall_enabled, :merge_requests_enabled, :wiki_enabled | 10 | :wall_enabled, :merge_requests_enabled, :wiki_enabled |
| 11 | + attr_accessor :error_code | ||
| 11 | 12 | ||
| 12 | - # | ||
| 13 | # Relations | 13 | # Relations |
| 14 | - # | ||
| 15 | belongs_to :owner, class_name: "User" | 14 | belongs_to :owner, class_name: "User" |
| 16 | has_many :users, through: :users_projects | 15 | has_many :users, through: :users_projects |
| 17 | has_many :events, dependent: :destroy | 16 | has_many :events, dependent: :destroy |
| @@ -26,11 +25,7 @@ class Project < ActiveRecord::Base | @@ -26,11 +25,7 @@ class Project < ActiveRecord::Base | ||
| 26 | has_many :wikis, dependent: :destroy | 25 | has_many :wikis, dependent: :destroy |
| 27 | has_many :protected_branches, dependent: :destroy | 26 | has_many :protected_branches, dependent: :destroy |
| 28 | 27 | ||
| 29 | - attr_accessor :error_code | ||
| 30 | - | ||
| 31 | - # | ||
| 32 | # Scopes | 28 | # Scopes |
| 33 | - # | ||
| 34 | scope :public_only, where(private_flag: false) | 29 | scope :public_only, where(private_flag: false) |
| 35 | scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) } | 30 | scope :without_user, lambda { |user| where("id not in (:ids)", ids: user.projects.map(&:id) ) } |
| 36 | 31 | ||
| @@ -47,7 +42,6 @@ class Project < ActiveRecord::Base | @@ -47,7 +42,6 @@ class Project < ActiveRecord::Base | ||
| 47 | 42 | ||
| 48 | Project.transaction do | 43 | Project.transaction do |
| 49 | project.owner = user | 44 | project.owner = user |
| 50 | - | ||
| 51 | project.save! | 45 | project.save! |
| 52 | 46 | ||
| 53 | # Add user as project master | 47 | # Add user as project master |
| @@ -76,36 +70,19 @@ class Project < ActiveRecord::Base | @@ -76,36 +70,19 @@ class Project < ActiveRecord::Base | ||
| 76 | id && valid? | 70 | id && valid? |
| 77 | end | 71 | end |
| 78 | 72 | ||
| 79 | - # | ||
| 80 | # Validations | 73 | # Validations |
| 81 | - # | ||
| 82 | - validates :name, | ||
| 83 | - uniqueness: true, | ||
| 84 | - presence: true, | ||
| 85 | - length: { within: 0..255 } | ||
| 86 | - | ||
| 87 | - validates :path, | ||
| 88 | - uniqueness: true, | ||
| 89 | - presence: true, | ||
| 90 | - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, | ||
| 91 | - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }, | ||
| 92 | - length: { within: 0..255 } | ||
| 93 | - | ||
| 94 | - validates :description, | ||
| 95 | - length: { within: 0..2000 } | ||
| 96 | - | ||
| 97 | - validates :code, | ||
| 98 | - presence: true, | ||
| 99 | - uniqueness: true, | ||
| 100 | - format: { with: /^[a-zA-Z][a-zA-Z0-9_\-\.]*$/, | ||
| 101 | - message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" }, | ||
| 102 | - length: { within: 1..255 } | ||
| 103 | - | ||
| 104 | validates :owner, presence: true | 74 | validates :owner, presence: true |
| 75 | + validates :description, length: { within: 0..2000 } | ||
| 76 | + validates :name, uniqueness: true, presence: true, length: { within: 0..255 } | ||
| 77 | + validates :path, uniqueness: true, presence: true, length: { within: 0..255 }, | ||
| 78 | + format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, | ||
| 79 | + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | ||
| 80 | + validates :code, presence: true, uniqueness: true, length: { within: 1..255 }, | ||
| 81 | + format: { with: /\A[a-zA-Z][a-zA-Z0-9_\-\.]*\z/, | ||
| 82 | + message: "only letters, digits & '_' '-' '.' allowed. Letter should be first" } | ||
| 105 | validates :issues_enabled, :wall_enabled, :merge_requests_enabled, | 83 | validates :issues_enabled, :wall_enabled, :merge_requests_enabled, |
| 106 | :wiki_enabled, inclusion: { in: [true, false] } | 84 | :wiki_enabled, inclusion: { in: [true, false] } |
| 107 | - validate :check_limit | ||
| 108 | - validate :repo_name | 85 | + validate :check_limit, :repo_name |
| 109 | 86 | ||
| 110 | def check_limit | 87 | def check_limit |
| 111 | unless owner.can_create_project? | 88 | unless owner.can_create_project? |
| @@ -170,7 +147,7 @@ class Project < ActiveRecord::Base | @@ -170,7 +147,7 @@ class Project < ActiveRecord::Base | ||
| 170 | end | 147 | end |
| 171 | 148 | ||
| 172 | def wiki_notes | 149 | def wiki_notes |
| 173 | - Note.where(noteable_id: wikis.map(&:id), noteable_type: 'Wiki', project_id: self.id) | 150 | + Note.where(noteable_id: wikis.pluck(:id), noteable_type: 'Wiki', project_id: self.id) |
| 174 | end | 151 | end |
| 175 | 152 | ||
| 176 | def project_id | 153 | def project_id |
| @@ -182,19 +159,18 @@ end | @@ -182,19 +159,18 @@ end | ||
| 182 | # | 159 | # |
| 183 | # Table name: projects | 160 | # Table name: projects |
| 184 | # | 161 | # |
| 185 | -# id :integer(4) not null, primary key | 162 | +# id :integer not null, primary key |
| 186 | # name :string(255) | 163 | # name :string(255) |
| 187 | # path :string(255) | 164 | # path :string(255) |
| 188 | # description :text | 165 | # description :text |
| 189 | # created_at :datetime not null | 166 | # created_at :datetime not null |
| 190 | # updated_at :datetime not null | 167 | # updated_at :datetime not null |
| 191 | -# private_flag :boolean(1) default(TRUE), not null | 168 | +# private_flag :boolean default(TRUE), not null |
| 192 | # code :string(255) | 169 | # code :string(255) |
| 193 | -# owner_id :integer(4) | 170 | +# owner_id :integer |
| 194 | # default_branch :string(255) | 171 | # default_branch :string(255) |
| 195 | -# issues_enabled :boolean(1) default(TRUE), not null | ||
| 196 | -# wall_enabled :boolean(1) default(TRUE), not null | ||
| 197 | -# merge_requests_enabled :boolean(1) default(TRUE), not null | ||
| 198 | -# wiki_enabled :boolean(1) default(TRUE), not null | 172 | +# issues_enabled :boolean default(TRUE), not null |
| 173 | +# wall_enabled :boolean default(TRUE), not null | ||
| 174 | +# merge_requests_enabled :boolean default(TRUE), not null | ||
| 175 | +# wiki_enabled :boolean default(TRUE), not null | ||
| 199 | # | 176 | # |
| 200 | - |
app/models/project_hook.rb
| 1 | class ProjectHook < WebHook | 1 | class ProjectHook < WebHook |
| 2 | belongs_to :project | 2 | belongs_to :project |
| 3 | end | 3 | end |
| 4 | + | ||
| 5 | +# == Schema Information | ||
| 6 | +# | ||
| 7 | +# Table name: web_hooks | ||
| 8 | +# | ||
| 9 | +# id :integer not null, primary key | ||
| 10 | +# url :string(255) | ||
| 11 | +# project_id :integer | ||
| 12 | +# created_at :datetime not null | ||
| 13 | +# updated_at :datetime not null | ||
| 14 | +# type :string(255) default("ProjectHook") | ||
| 15 | +# |
app/models/protected_branch.rb
| @@ -4,8 +4,7 @@ class ProtectedBranch < ActiveRecord::Base | @@ -4,8 +4,7 @@ class ProtectedBranch < ActiveRecord::Base | ||
| 4 | attr_accessible :name | 4 | attr_accessible :name |
| 5 | 5 | ||
| 6 | belongs_to :project | 6 | belongs_to :project |
| 7 | - validates_presence_of :project_id | ||
| 8 | - validates_presence_of :name | 7 | + validates_presence_of :name, :project_id |
| 9 | 8 | ||
| 10 | after_save :update_repository | 9 | after_save :update_repository |
| 11 | after_destroy :update_repository | 10 | after_destroy :update_repository |
| @@ -18,14 +17,14 @@ class ProtectedBranch < ActiveRecord::Base | @@ -18,14 +17,14 @@ class ProtectedBranch < ActiveRecord::Base | ||
| 18 | project.commit(self.name) | 17 | project.commit(self.name) |
| 19 | end | 18 | end |
| 20 | end | 19 | end |
| 20 | + | ||
| 21 | # == Schema Information | 21 | # == Schema Information |
| 22 | # | 22 | # |
| 23 | # Table name: protected_branches | 23 | # Table name: protected_branches |
| 24 | # | 24 | # |
| 25 | -# id :integer(4) not null, primary key | ||
| 26 | -# project_id :integer(4) not null | 25 | +# id :integer not null, primary key |
| 26 | +# project_id :integer not null | ||
| 27 | # name :string(255) not null | 27 | # name :string(255) not null |
| 28 | # created_at :datetime not null | 28 | # created_at :datetime not null |
| 29 | # updated_at :datetime not null | 29 | # updated_at :datetime not null |
| 30 | # | 30 | # |
| 31 | - |
app/models/snippet.rb
| @@ -7,25 +7,12 @@ class Snippet < ActiveRecord::Base | @@ -7,25 +7,12 @@ class Snippet < ActiveRecord::Base | ||
| 7 | belongs_to :author, class_name: "User" | 7 | belongs_to :author, class_name: "User" |
| 8 | has_many :notes, as: :noteable, dependent: :destroy | 8 | has_many :notes, as: :noteable, dependent: :destroy |
| 9 | 9 | ||
| 10 | - delegate :name, | ||
| 11 | - :email, | ||
| 12 | - to: :author, | ||
| 13 | - prefix: true | 10 | + delegate :name, :email, to: :author, prefix: true |
| 14 | 11 | ||
| 15 | - validates_presence_of :project_id | ||
| 16 | - validates_presence_of :author_id | ||
| 17 | - | ||
| 18 | - validates :title, | ||
| 19 | - presence: true, | ||
| 20 | - length: { within: 0..255 } | ||
| 21 | - | ||
| 22 | - validates :file_name, | ||
| 23 | - presence: true, | ||
| 24 | - length: { within: 0..255 } | ||
| 25 | - | ||
| 26 | - validates :content, | ||
| 27 | - presence: true, | ||
| 28 | - length: { within: 0..10000 } | 12 | + validates_presence_of :author_id, :project_id |
| 13 | + validates :title, presence: true, length: { within: 0..255 } | ||
| 14 | + validates :file_name, presence: true, length: { within: 0..255 } | ||
| 15 | + validates :content, presence: true, length: { within: 0..10000 } | ||
| 29 | 16 | ||
| 30 | scope :fresh, order("created_at DESC") | 17 | scope :fresh, order("created_at DESC") |
| 31 | scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) | 18 | scope :non_expired, where(["expires_at IS NULL OR expires_at > ?", Time.current]) |
| @@ -59,18 +46,18 @@ class Snippet < ActiveRecord::Base | @@ -59,18 +46,18 @@ class Snippet < ActiveRecord::Base | ||
| 59 | expires_at && expires_at < Time.current | 46 | expires_at && expires_at < Time.current |
| 60 | end | 47 | end |
| 61 | end | 48 | end |
| 49 | + | ||
| 62 | # == Schema Information | 50 | # == Schema Information |
| 63 | # | 51 | # |
| 64 | # Table name: snippets | 52 | # Table name: snippets |
| 65 | # | 53 | # |
| 66 | -# id :integer(4) not null, primary key | 54 | +# id :integer not null, primary key |
| 67 | # title :string(255) | 55 | # title :string(255) |
| 68 | # content :text | 56 | # content :text |
| 69 | -# author_id :integer(4) not null | ||
| 70 | -# project_id :integer(4) not null | 57 | +# author_id :integer not null |
| 58 | +# project_id :integer not null | ||
| 71 | # created_at :datetime not null | 59 | # created_at :datetime not null |
| 72 | # updated_at :datetime not null | 60 | # updated_at :datetime not null |
| 73 | # file_name :string(255) | 61 | # file_name :string(255) |
| 74 | # expires_at :datetime | 62 | # expires_at :datetime |
| 75 | # | 63 | # |
| 76 | - |
app/models/system_hook.rb
| 1 | class SystemHook < WebHook | 1 | class SystemHook < WebHook |
| 2 | - | ||
| 3 | def async_execute(data) | 2 | def async_execute(data) |
| 4 | Resque.enqueue(SystemHookWorker, id, data) | 3 | Resque.enqueue(SystemHookWorker, id, data) |
| 5 | end | 4 | end |
| @@ -9,5 +8,16 @@ class SystemHook < WebHook | @@ -9,5 +8,16 @@ class SystemHook < WebHook | ||
| 9 | sh.async_execute data | 8 | sh.async_execute data |
| 10 | end | 9 | end |
| 11 | end | 10 | end |
| 12 | - | ||
| 13 | end | 11 | end |
| 12 | + | ||
| 13 | +# == Schema Information | ||
| 14 | +# | ||
| 15 | +# Table name: web_hooks | ||
| 16 | +# | ||
| 17 | +# id :integer not null, primary key | ||
| 18 | +# url :string(255) | ||
| 19 | +# project_id :integer | ||
| 20 | +# created_at :datetime not null | ||
| 21 | +# updated_at :datetime not null | ||
| 22 | +# type :string(255) default("ProjectHook") | ||
| 23 | +# |
app/models/tree.rb
| @@ -2,16 +2,8 @@ class Tree | @@ -2,16 +2,8 @@ class Tree | ||
| 2 | include Linguist::BlobHelper | 2 | include Linguist::BlobHelper |
| 3 | attr_accessor :path, :tree, :project, :ref | 3 | attr_accessor :path, :tree, :project, :ref |
| 4 | 4 | ||
| 5 | - delegate :contents, | ||
| 6 | - :basename, | ||
| 7 | - :name, | ||
| 8 | - :data, | ||
| 9 | - :mime_type, | ||
| 10 | - :mode, | ||
| 11 | - :size, | ||
| 12 | - :text?, | ||
| 13 | - :colorize, | ||
| 14 | - to: :tree | 5 | + delegate :contents, :basename, :name, :data, :mime_type, |
| 6 | + :mode, :size, :text?, :colorize, to: :tree | ||
| 15 | 7 | ||
| 16 | def initialize(raw_tree, project, ref = nil, path = nil) | 8 | def initialize(raw_tree, project, ref = nil, path = nil) |
| 17 | @project, @ref, @path = project, ref, path | 9 | @project, @ref, @path = project, ref, path |
app/models/user.rb
| 1 | class User < ActiveRecord::Base | 1 | class User < ActiveRecord::Base |
| 2 | - | ||
| 3 | include Account | 2 | include Account |
| 4 | 3 | ||
| 5 | devise :database_authenticatable, :token_authenticatable, :lockable, | 4 | devise :database_authenticatable, :token_authenticatable, :lockable, |
| 6 | :recoverable, :rememberable, :trackable, :validatable, :omniauthable | 5 | :recoverable, :rememberable, :trackable, :validatable, :omniauthable |
| 7 | 6 | ||
| 8 | - attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, | ||
| 9 | - :name, :skype, :linkedin, :twitter, :dark_scheme, | ||
| 10 | - :theme_id, :force_random_password, :extern_uid, :provider, :as => [:default, :admin] | 7 | + attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, |
| 8 | + :skype, :linkedin, :twitter, :dark_scheme, :theme_id, :force_random_password, | ||
| 9 | + :extern_uid, :provider, :as => [:default, :admin] | ||
| 11 | attr_accessible :projects_limit, :as => :admin | 10 | attr_accessible :projects_limit, :as => :admin |
| 12 | 11 | ||
| 13 | attr_accessor :force_random_password | 12 | attr_accessor :force_random_password |
| 14 | 13 | ||
| 15 | - has_many :users_projects, dependent: :destroy | 14 | + has_many :keys, dependent: :destroy |
| 16 | has_many :projects, through: :users_projects | 15 | has_many :projects, through: :users_projects |
| 16 | + has_many :users_projects, dependent: :destroy | ||
| 17 | + has_many :issues, foreign_key: :author_id, dependent: :destroy | ||
| 18 | + has_many :notes, foreign_key: :author_id, dependent: :destroy | ||
| 19 | + has_many :merge_requests, foreign_key: :author_id, dependent: :destroy | ||
| 17 | has_many :my_own_projects, class_name: "Project", foreign_key: :owner_id | 20 | has_many :my_own_projects, class_name: "Project", foreign_key: :owner_id |
| 18 | - has_many :keys, dependent: :destroy | ||
| 19 | - | ||
| 20 | - has_many :events, | ||
| 21 | - class_name: "Event", | ||
| 22 | - foreign_key: :author_id, | ||
| 23 | - dependent: :destroy | ||
| 24 | - | ||
| 25 | - has_many :recent_events, | ||
| 26 | - class_name: "Event", | ||
| 27 | - foreign_key: :author_id, | ||
| 28 | - order: "id DESC" | ||
| 29 | - | ||
| 30 | - has_many :issues, | ||
| 31 | - foreign_key: :author_id, | ||
| 32 | - dependent: :destroy | ||
| 33 | - | ||
| 34 | - has_many :notes, | ||
| 35 | - foreign_key: :author_id, | ||
| 36 | - dependent: :destroy | ||
| 37 | - | ||
| 38 | - has_many :assigned_issues, | ||
| 39 | - class_name: "Issue", | ||
| 40 | - foreign_key: :assignee_id, | ||
| 41 | - dependent: :destroy | ||
| 42 | - | ||
| 43 | - has_many :merge_requests, | ||
| 44 | - foreign_key: :author_id, | ||
| 45 | - dependent: :destroy | ||
| 46 | - | ||
| 47 | - has_many :assigned_merge_requests, | ||
| 48 | - class_name: "MergeRequest", | ||
| 49 | - foreign_key: :assignee_id, | ||
| 50 | - dependent: :destroy | ||
| 51 | - | ||
| 52 | - validates :projects_limit, | ||
| 53 | - presence: true, | ||
| 54 | - numericality: {greater_than_or_equal_to: 0} | 21 | + has_many :events, class_name: "Event", foreign_key: :author_id, dependent: :destroy |
| 22 | + has_many :recent_events, class_name: "Event", foreign_key: :author_id, order: "id DESC" | ||
| 23 | + has_many :assigned_issues, class_name: "Issue", foreign_key: :assignee_id, dependent: :destroy | ||
| 24 | + has_many :assigned_merge_requests, class_name: "MergeRequest", foreign_key: :assignee_id, dependent: :destroy | ||
| 55 | 25 | ||
| 56 | validates :bio, length: { within: 0..255 } | 26 | validates :bio, length: { within: 0..255 } |
| 57 | - | ||
| 58 | validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider} | 27 | validates :extern_uid, :allow_blank => true, :uniqueness => {:scope => :provider} |
| 59 | - | ||
| 60 | - before_save :ensure_authentication_token | ||
| 61 | - alias_attribute :private_token, :authentication_token | 28 | + validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} |
| 62 | 29 | ||
| 63 | scope :not_in_project, lambda { |project| where("id not in (:ids)", ids: project.users.map(&:id) ) } | 30 | scope :not_in_project, lambda { |project| where("id not in (:ids)", ids: project.users.map(&:id) ) } |
| 64 | scope :admins, where(admin: true) | 31 | scope :admins, where(admin: true) |
| @@ -66,6 +33,8 @@ class User < ActiveRecord::Base | @@ -66,6 +33,8 @@ class User < ActiveRecord::Base | ||
| 66 | scope :active, where(blocked: false) | 33 | scope :active, where(blocked: false) |
| 67 | 34 | ||
| 68 | before_validation :generate_password, on: :create | 35 | before_validation :generate_password, on: :create |
| 36 | + before_save :ensure_authentication_token | ||
| 37 | + alias_attribute :private_token, :authentication_token | ||
| 69 | 38 | ||
| 70 | def generate_password | 39 | def generate_password |
| 71 | if self.force_random_password | 40 | if self.force_random_password |
| @@ -107,17 +76,18 @@ class User < ActiveRecord::Base | @@ -107,17 +76,18 @@ class User < ActiveRecord::Base | ||
| 107 | where("name like :query or email like :query", query: "%#{query}%") | 76 | where("name like :query or email like :query", query: "%#{query}%") |
| 108 | end | 77 | end |
| 109 | end | 78 | end |
| 79 | + | ||
| 110 | # == Schema Information | 80 | # == Schema Information |
| 111 | # | 81 | # |
| 112 | # Table name: users | 82 | # Table name: users |
| 113 | # | 83 | # |
| 114 | -# id :integer(4) not null, primary key | 84 | +# id :integer not null, primary key |
| 115 | # email :string(255) default(""), not null | 85 | # email :string(255) default(""), not null |
| 116 | # encrypted_password :string(128) default(""), not null | 86 | # encrypted_password :string(128) default(""), not null |
| 117 | # reset_password_token :string(255) | 87 | # reset_password_token :string(255) |
| 118 | # reset_password_sent_at :datetime | 88 | # reset_password_sent_at :datetime |
| 119 | # remember_created_at :datetime | 89 | # remember_created_at :datetime |
| 120 | -# sign_in_count :integer(4) default(0) | 90 | +# sign_in_count :integer default(0) |
| 121 | # current_sign_in_at :datetime | 91 | # current_sign_in_at :datetime |
| 122 | # last_sign_in_at :datetime | 92 | # last_sign_in_at :datetime |
| 123 | # current_sign_in_ip :string(255) | 93 | # current_sign_in_ip :string(255) |
| @@ -125,14 +95,18 @@ end | @@ -125,14 +95,18 @@ end | ||
| 125 | # created_at :datetime not null | 95 | # created_at :datetime not null |
| 126 | # updated_at :datetime not null | 96 | # updated_at :datetime not null |
| 127 | # name :string(255) | 97 | # name :string(255) |
| 128 | -# admin :boolean(1) default(FALSE), not null | ||
| 129 | -# projects_limit :integer(4) default(10) | 98 | +# admin :boolean default(FALSE), not null |
| 99 | +# projects_limit :integer default(10) | ||
| 130 | # skype :string(255) default(""), not null | 100 | # skype :string(255) default(""), not null |
| 131 | # linkedin :string(255) default(""), not null | 101 | # linkedin :string(255) default(""), not null |
| 132 | # twitter :string(255) default(""), not null | 102 | # twitter :string(255) default(""), not null |
| 133 | # authentication_token :string(255) | 103 | # authentication_token :string(255) |
| 134 | -# dark_scheme :boolean(1) default(FALSE), not null | ||
| 135 | -# theme_id :integer(4) default(1), not null | 104 | +# dark_scheme :boolean default(FALSE), not null |
| 105 | +# theme_id :integer default(1), not null | ||
| 136 | # bio :string(255) | 106 | # bio :string(255) |
| 137 | -# blocked :boolean(1) default(FALSE), not null | 107 | +# blocked :boolean default(FALSE), not null |
| 108 | +# failed_attempts :integer default(0) | ||
| 109 | +# locked_at :datetime | ||
| 110 | +# extern_uid :string(255) | ||
| 111 | +# provider :string(255) | ||
| 138 | # | 112 | # |
app/models/users_project.rb
| @@ -88,15 +88,15 @@ class UsersProject < ActiveRecord::Base | @@ -88,15 +88,15 @@ class UsersProject < ActiveRecord::Base | ||
| 88 | self.class.access_roles.invert[self.project_access] | 88 | self.class.access_roles.invert[self.project_access] |
| 89 | end | 89 | end |
| 90 | end | 90 | end |
| 91 | + | ||
| 91 | # == Schema Information | 92 | # == Schema Information |
| 92 | # | 93 | # |
| 93 | # Table name: users_projects | 94 | # Table name: users_projects |
| 94 | # | 95 | # |
| 95 | -# id :integer(4) not null, primary key | ||
| 96 | -# user_id :integer(4) not null | ||
| 97 | -# project_id :integer(4) not null | 96 | +# id :integer not null, primary key |
| 97 | +# user_id :integer not null | ||
| 98 | +# project_id :integer not null | ||
| 98 | # created_at :datetime not null | 99 | # created_at :datetime not null |
| 99 | # updated_at :datetime not null | 100 | # updated_at :datetime not null |
| 100 | -# project_access :integer(4) default(0), not null | 101 | +# project_access :integer default(0), not null |
| 101 | # | 102 | # |
| 102 | - |
app/models/web_hook.rb
| @@ -6,34 +6,31 @@ class WebHook < ActiveRecord::Base | @@ -6,34 +6,31 @@ class WebHook < ActiveRecord::Base | ||
| 6 | # HTTParty timeout | 6 | # HTTParty timeout |
| 7 | default_timeout 10 | 7 | default_timeout 10 |
| 8 | 8 | ||
| 9 | - validates :url, | ||
| 10 | - presence: true, | ||
| 11 | - format: { | ||
| 12 | - with: URI::regexp(%w(http https)), | ||
| 13 | - message: "should be a valid url" } | 9 | + validates :url, presence: true, |
| 10 | + format: { with: URI::regexp(%w(http https)), message: "should be a valid url" } | ||
| 14 | 11 | ||
| 15 | def execute(data) | 12 | def execute(data) |
| 16 | parsed_url = URI.parse(url) | 13 | parsed_url = URI.parse(url) |
| 17 | if parsed_url.userinfo.blank? | 14 | if parsed_url.userinfo.blank? |
| 18 | WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" }) | 15 | WebHook.post(url, body: data.to_json, headers: { "Content-Type" => "application/json" }) |
| 19 | else | 16 | else |
| 20 | - post_url = url.gsub(parsed_url.userinfo+"@", "") | 17 | + post_url = url.gsub("#{parsed_url.userinfo}@", "") |
| 21 | WebHook.post(post_url, | 18 | WebHook.post(post_url, |
| 22 | body: data.to_json, | 19 | body: data.to_json, |
| 23 | - headers: { "Content-Type" => "application/json" }, | 20 | + headers: {"Content-Type" => "application/json"}, |
| 24 | basic_auth: {username: parsed_url.user, password: parsed_url.password}) | 21 | basic_auth: {username: parsed_url.user, password: parsed_url.password}) |
| 25 | end | 22 | end |
| 26 | end | 23 | end |
| 27 | - | ||
| 28 | end | 24 | end |
| 25 | + | ||
| 29 | # == Schema Information | 26 | # == Schema Information |
| 30 | # | 27 | # |
| 31 | # Table name: web_hooks | 28 | # Table name: web_hooks |
| 32 | # | 29 | # |
| 33 | -# id :integer(4) not null, primary key | 30 | +# id :integer not null, primary key |
| 34 | # url :string(255) | 31 | # url :string(255) |
| 35 | -# project_id :integer(4) | 32 | +# project_id :integer |
| 36 | # created_at :datetime not null | 33 | # created_at :datetime not null |
| 37 | # updated_at :datetime not null | 34 | # updated_at :datetime not null |
| 35 | +# type :string(255) default("ProjectHook") | ||
| 38 | # | 36 | # |
| 39 | - |
app/models/wiki.rb
| @@ -32,17 +32,17 @@ class Wiki < ActiveRecord::Base | @@ -32,17 +32,17 @@ class Wiki < ActiveRecord::Base | ||
| 32 | end | 32 | end |
| 33 | end | 33 | end |
| 34 | end | 34 | end |
| 35 | + | ||
| 35 | # == Schema Information | 36 | # == Schema Information |
| 36 | # | 37 | # |
| 37 | # Table name: wikis | 38 | # Table name: wikis |
| 38 | # | 39 | # |
| 39 | -# id :integer(4) not null, primary key | 40 | +# id :integer not null, primary key |
| 40 | # title :string(255) | 41 | # title :string(255) |
| 41 | # content :text | 42 | # content :text |
| 42 | -# project_id :integer(4) | 43 | +# project_id :integer |
| 43 | # created_at :datetime not null | 44 | # created_at :datetime not null |
| 44 | # updated_at :datetime not null | 45 | # updated_at :datetime not null |
| 45 | # slug :string(255) | 46 | # slug :string(255) |
| 46 | -# user_id :integer(4) | 47 | +# user_id :integer |
| 47 | # | 48 | # |
| 48 | - |
config/database.yml.example
| @@ -9,12 +9,11 @@ production: | @@ -9,12 +9,11 @@ production: | ||
| 9 | pool: 5 | 9 | pool: 5 |
| 10 | username: root | 10 | username: root |
| 11 | password: "secure password" | 11 | password: "secure password" |
| 12 | + # host: localhost | ||
| 12 | # socket: /tmp/mysql.sock | 13 | # socket: /tmp/mysql.sock |
| 13 | 14 | ||
| 14 | - | ||
| 15 | -# | ||
| 16 | -# Development specific | ||
| 17 | # | 15 | # |
| 16 | +# Development specific | ||
| 18 | # | 17 | # |
| 19 | development: | 18 | development: |
| 20 | adapter: mysql2 | 19 | adapter: mysql2 |
| @@ -38,6 +37,3 @@ test: &test | @@ -38,6 +37,3 @@ test: &test | ||
| 38 | username: root | 37 | username: root |
| 39 | password: "secure password" | 38 | password: "secure password" |
| 40 | # socket: /tmp/mysql.sock | 39 | # socket: /tmp/mysql.sock |
| 41 | - | ||
| 42 | -cucumber: | ||
| 43 | - <<: *test |
config/database.yml.mysql
| @@ -9,12 +9,11 @@ production: | @@ -9,12 +9,11 @@ production: | ||
| 9 | pool: 5 | 9 | pool: 5 |
| 10 | username: root | 10 | username: root |
| 11 | password: "secure password" | 11 | password: "secure password" |
| 12 | + # host: localhost | ||
| 12 | # socket: /tmp/mysql.sock | 13 | # socket: /tmp/mysql.sock |
| 13 | 14 | ||
| 14 | - | ||
| 15 | -# | ||
| 16 | -# Development specific | ||
| 17 | # | 15 | # |
| 16 | +# Development specific | ||
| 18 | # | 17 | # |
| 19 | development: | 18 | development: |
| 20 | adapter: mysql2 | 19 | adapter: mysql2 |
| @@ -38,6 +37,3 @@ test: &test | @@ -38,6 +37,3 @@ test: &test | ||
| 38 | username: root | 37 | username: root |
| 39 | password: | 38 | password: |
| 40 | # socket: /tmp/mysql.sock | 39 | # socket: /tmp/mysql.sock |
| 41 | - | ||
| 42 | -cucumber: | ||
| 43 | - <<: *test |
config/database.yml.sqlite
| @@ -12,11 +12,8 @@ production: | @@ -12,11 +12,8 @@ production: | ||
| 12 | pool: 5 | 12 | pool: 5 |
| 13 | timeout: 5000 | 13 | timeout: 5000 |
| 14 | 14 | ||
| 15 | - | ||
| 16 | -# | ||
| 17 | -# Development specific | ||
| 18 | -# | ||
| 19 | # | 15 | # |
| 16 | +# Development specific | ||
| 20 | # | 17 | # |
| 21 | development: | 18 | development: |
| 22 | adapter: sqlite3 | 19 | adapter: sqlite3 |
| @@ -32,6 +29,3 @@ test: &test | @@ -32,6 +29,3 @@ test: &test | ||
| 32 | database: db/test.sqlite3 | 29 | database: db/test.sqlite3 |
| 33 | pool: 5 | 30 | pool: 5 |
| 34 | timeout: 5000 | 31 | timeout: 5000 |
| 35 | - | ||
| 36 | -cucumber: | ||
| 37 | - <<: *test |