Add name to board model

parent 95b511d0
......@@ -3,7 +3,7 @@ class Board < ActiveRecord::Base
has_many :lists, -> { order(:list_type, :position) }, dependent: :delete_all
validates :project, presence: true
validates :name, :project, presence: true
def backlog_list
lists.merge(List.backlog).take
......
class AddNameToBoards < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :boards, :name, :string, default: 'Development'
end
def down
remove_column :boards, :name
end
end
......@@ -167,6 +167,7 @@ ActiveRecord::Schema.define(version: 20161007133303) do
t.integer "project_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "name", default: "Development", null: false
end
add_index "boards", ["project_id"], name: "index_boards_on_project_id", using: :btree
......
FactoryGirl.define do
factory :board do
sequence(:name) { |n| "board#{n}" }
project factory: :empty_project
after(:create) do |board|
......
......@@ -7,6 +7,7 @@ describe Board do
end
describe 'validations' do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_presence_of(:project) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment