From 1a09d0feade8d27c7b34cbec99008ced4c3372b1 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 19 Feb 2015 02:34:07 +0300 Subject: [PATCH] #456: add default_branch to Group --- app/models/concerns/default_branchable.rb | 11 +++++++++++ app/models/group.rb | 1 + app/models/platform.rb | 7 +++---- app/models/project.rb | 3 ++- app/views/groups/profile/_form.html.slim | 1 + .../20150218231015_add_default_branch_to_groups.rb | 5 +++++ db/schema.rb | 3 ++- 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/models/concerns/default_branchable.rb create mode 100644 db/migrate/20150218231015_add_default_branch_to_groups.rb diff --git a/app/models/concerns/default_branchable.rb b/app/models/concerns/default_branchable.rb new file mode 100644 index 000000000..ef66954a7 --- /dev/null +++ b/app/models/concerns/default_branchable.rb @@ -0,0 +1,11 @@ +module DefaultBranchable + extend ActiveSupport::Concern + + included do + validates :default_branch, + length: { maximum: 100 } + + attr_accessible :default_branch + end + +end diff --git a/app/models/group.rb b/app/models/group.rb index 0339c34c5..76a7ab2f2 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,6 +1,7 @@ class Group < Avatar include ActsLikeMember include PersonalRepository + include DefaultBranchable belongs_to :owner, class_name: 'User' diff --git a/app/models/platform.rb b/app/models/platform.rb index 8769cc82a..dcddaa29f 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -7,6 +7,7 @@ class Platform < ActiveRecord::Base include Owner include EventLoggable include EmptyMetadata + include DefaultBranchable self.per_page = 20 @@ -68,8 +69,7 @@ class Platform < ActiveRecord::Base length: { maximum: 100 } validates :default_branch, - presence: true, - length: { maximum: 100 } + presence: true validates :distrib_type, presence: true, @@ -118,8 +118,7 @@ class Platform < ActiveRecord::Base :platform_arch_settings_attributes, :automatic_metadata_regeneration, :admin_id, - :term, - :default_branch + :term attr_accessor :admin_id, :term diff --git a/app/models/project.rb b/app/models/project.rb index a2b41ffec..666937619 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -7,6 +7,7 @@ class Project < ActiveRecord::Base include Wiki include UrlHelper include EventLoggable + include DefaultBranchable VISIBILITIES = ['open', 'hidden'] MAX_OWN_PROJECTS = 32000 @@ -61,7 +62,7 @@ class Project < ActiveRecord::Base errors.delete :project_to_repositories end - attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, + attr_accessible :name, :description, :visibility, :srpm, :is_package, :has_issues, :has_wiki, :maintainer_id, :publish_i686_into_x86_64, :url, :srpms_list, :mass_import, :add_to_repository_id, :architecture_dependent, :autostart_status diff --git a/app/views/groups/profile/_form.html.slim b/app/views/groups/profile/_form.html.slim index e23371c1b..2429f27b9 100644 --- a/app/views/groups/profile/_form.html.slim +++ b/app/views/groups/profile/_form.html.slim @@ -2,5 +2,6 @@ - if [:new, :create].include? act = f.input :uname = f.input :description, as: :text += f.input :default_branch = render 'shared/avatar_form', subject: @group, f: f = submit_button_tag \ No newline at end of file diff --git a/db/migrate/20150218231015_add_default_branch_to_groups.rb b/db/migrate/20150218231015_add_default_branch_to_groups.rb new file mode 100644 index 000000000..ecb36ee7d --- /dev/null +++ b/db/migrate/20150218231015_add_default_branch_to_groups.rb @@ -0,0 +1,5 @@ +class AddDefaultBranchToGroups < ActiveRecord::Migration + def change + add_column :groups, :default_branch, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 586ebd187..51a4cfb3d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150217215529) do +ActiveRecord::Schema.define(version: 20150218231015) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -246,6 +246,7 @@ ActiveRecord::Schema.define(version: 20150217215529) do t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" + t.string "default_branch" end create_table "hooks", force: true do |t|