From 099120e71ba025f7bb5b60c9b3e7a4f395ba3c7c Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Mon, 17 Oct 2011 19:07:53 +0300 Subject: [PATCH 1/2] Fix bugs. Refs #1858 --- app/controllers/projects_controller.rb | 5 +++-- app/views/platforms/show.html.haml | 2 +- app/views/projects/show.html.haml | 2 +- app/views/repositories/_sidebar.html.haml | 2 +- app/views/repositories/show.html.haml | 20 ++++++++++---------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 839442128..171aea246 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -46,11 +46,12 @@ class ProjectsController < ApplicationController def create @project = Project.new params[:project] - @project.owner = get_acter + # @project.owner = get_acter if @project.save flash[:notice] = t('flash.project.saved') - redirect_to @project.owner + # redirect_to @project.owner + redirect_to @project else flash[:error] = t('flash.project.save_error') render :action => :new diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index 3cd62b70a..7ec858e89 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -33,7 +33,7 @@ %b = t('layout.platforms.owner') \: - = link_to @platform.owner.name, url_for(@platform.owner) + = link_to @platform.owner.try(:name), url_for(@platform.owner) %p %b diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index a8198dc0f..9ae1c755a 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -23,7 +23,7 @@ %b = t("activerecord.attributes.project.owner") \: - = link_to @project.owner.name, url_for(@project.owner) + = link_to @project.owner.try(:name), url_for(@project.owner) %p %b = t("activerecord.attributes.project.visibility") diff --git a/app/views/repositories/_sidebar.html.haml b/app/views/repositories/_sidebar.html.haml index a40e867f8..d4101628f 100644 --- a/app/views/repositories/_sidebar.html.haml +++ b/app/views/repositories/_sidebar.html.haml @@ -1,4 +1,4 @@ .block.notice %h3= t("layout.platforms.current_platform_header") .content - %p= link_to @platform.name, platform_path(@platform) \ No newline at end of file + / %p= link_to @platform.name, platform_path(@platform) \ No newline at end of file diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml index 1237c8ab7..9273e6a4c 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/repositories/show.html.haml @@ -3,7 +3,7 @@ %ul.wat-cf %li.first= link_to t("layout.repositories.list"), platform_path(@platform) + "#repositories" %li= link_to t("layout.repositories.new"), new_platform_repository_path(@platform) - %li.active= link_to t("layout.repositories.show"), platform_repository_path(@platform, @repository) + / %li.active= link_to t("layout.repositories.show"), platform_repository_path(@platform, @repository) .content .inner %p @@ -21,25 +21,25 @@ = t("activerecord.attributes.repository.platform") \: = link_to @repository.platform.name, platform_path(@platform) - .wat-cf - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_path(@platform, @repository), :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") + / .wat-cf + / = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_repository_path(@platform, @repository), :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") %a{ :name => "projects" } .block .secondary-navigation %ul.wat-cf - %li.first.active= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" + / %li.first.active= link_to t("layout.projects.list"), platform_repository_path(@platform, @repository) + "#projects" %li= link_to t("layout.projects.new"), new_project_path(@platform, @repository) .content %h2.title = t("layout.projects.list_header") .inner - = form_tag platform_repository_path(@platform, @repository), :method => :get do - .group - = label_tag :query, t("layout.search_by_name"), :class => :label - = text_field_tag :query - %button.search{:type => "submit"} - = t("layout.search") + / = form_tag platform_repository_path(@platform, @repository), :method => :get do + / .group + / = label_tag :query, t("layout.search_by_name"), :class => :label + / = text_field_tag :query + / %button.search{:type => "submit"} + / = t("layout.search") %table.table %tr %th.first= t("activerecord.attributes.project.name") From 5291752419ac8a89f1c75a2e74410d5e5eb62357 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Wed, 19 Oct 2011 23:58:31 +0300 Subject: [PATCH 2/2] Add categories and apply basic CRUD actions. Add category link and description to project. Apply category assign to project. Apply categorization with platforms. Integrate to common design and layout. Import basic categories structure. Refs #1858 --- Gemfile | 2 + Gemfile.lock | 3 + app/controllers/categories_controller.rb | 71 ++++++++++ app/models/category.rb | 9 ++ app/models/project.rb | 1 + app/views/categories/_category.html.haml | 9 ++ app/views/categories/_form.html.haml | 15 ++ app/views/categories/_sidebar.html.haml | 0 app/views/categories/edit.html.haml | 11 ++ app/views/categories/index.html.haml | 17 +++ app/views/categories/index2.html.haml | 14 ++ app/views/categories/new.html.haml | 9 ++ app/views/categories/platforms.html.haml | 13 ++ app/views/categories/show.html.haml | 15 ++ app/views/layouts/application.html.haml | 3 + app/views/projects/_form.html.haml | 6 + app/views/projects/_project.html.haml | 4 + config/locales/ru.yml | 23 +++ config/routes.rb | 6 + .../20111017152936_create_categories.rb | 15 ++ ...category_id_and_description_to_projects.rb | 14 ++ db/schema.rb | 16 ++- db/seeds.rb | 134 ++++++++++++++++++ spec/models/category_spec.rb | 5 + 24 files changed, 413 insertions(+), 2 deletions(-) create mode 100644 app/controllers/categories_controller.rb create mode 100644 app/models/category.rb create mode 100644 app/views/categories/_category.html.haml create mode 100644 app/views/categories/_form.html.haml create mode 100644 app/views/categories/_sidebar.html.haml create mode 100644 app/views/categories/edit.html.haml create mode 100644 app/views/categories/index.html.haml create mode 100644 app/views/categories/index2.html.haml create mode 100644 app/views/categories/new.html.haml create mode 100644 app/views/categories/platforms.html.haml create mode 100644 app/views/categories/show.html.haml create mode 100644 app/views/projects/_project.html.haml create mode 100644 db/migrate/20111017152936_create_categories.rb create mode 100644 db/migrate/20111017172701_add_category_id_and_description_to_projects.rb create mode 100644 spec/models/category_spec.rb diff --git a/Gemfile b/Gemfile index 400fd1879..e263e0600 100644 --- a/Gemfile +++ b/Gemfile @@ -55,3 +55,5 @@ gem 'delayed_job' gem 'paperclip', "~> 2.3" gem 'jammit' + +gem 'ancestry', '~> 1.2.4' diff --git a/Gemfile.lock b/Gemfile.lock index 2c4ef8509..d1e83fab9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,8 @@ GEM airbrake (3.0.4) activesupport builder + ancestry (1.2.4) + activerecord (>= 2.2.2) arel (2.0.9) bcrypt-ruby (2.1.4) builder (2.1.2) @@ -148,6 +150,7 @@ PLATFORMS DEPENDENCIES airbrake + ancestry (~> 1.2.4) capistrano capistrano-ext compass (>= 0.10.6) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb new file mode 100644 index 000000000..f3ed3b6fd --- /dev/null +++ b/app/controllers/categories_controller.rb @@ -0,0 +1,71 @@ +class CategoriesController < ApplicationController + before_filter :authenticate_user! + before_filter :find_category, :only => [:show, :edit, :update, :destroy] + before_filter :find_platform, :only => [:show, :index] + + def platforms + @platforms = Platform.all + @platforms_count = Platform.joins(:repositories => :projects).group('platforms.id').count + end + + def index + if @platform + @categories = Category.joins(:projects => :repositories).where('repositories.platform_id = ?', @platform.id). + having('count(projects.id) > 0').group('categories.id').default_order + @categories_count = @categories.count + render 'index2' + else + @categories = Category.default_order.paginate(:page => params[:page]) + end + end + + def show + @projects = @category.projects + @projects = @projects.joins(:repositories).where("repositories.platform_id = ?", @platform.id) if @platform + @projects = @projects.paginate :page => params[:page] + end + + def new + @category = Category.new + end + + def edit + end + + def destroy + @category.destroy + flash[:notice] = t("flash.category.destroyed") + redirect_to categories_path + end + + def create + @category = Category.new params[:category] + if @category.save + flash[:notice] = t('flash.category.saved') + redirect_to categories_path + else + flash[:error] = t('flash.category.save_error') + render :action => :new + end + end + + def update + if @category.update_attributes(params[:category]) + flash[:notice] = t('flash.category.saved') + redirect_to categories_path + else + flash[:error] = t('flash.category.save_error') + render :action => :edit + end + end + + protected + + def find_category + @category = Category.find(params[:id]) + end + + def find_platform + @platform = Platform.find(params[:platform_id]) if params[:platform_id] + end +end diff --git a/app/models/category.rb b/app/models/category.rb new file mode 100644 index 000000000..31e8001df --- /dev/null +++ b/app/models/category.rb @@ -0,0 +1,9 @@ +class Category < ActiveRecord::Base + has_many :projects, :dependent => :nullify + + validates :name, :presence => true + + scope :default_order, order('categories.name') + + has_ancestry +end diff --git a/app/models/project.rb b/app/models/project.rb index 3d4936d8e..183598b1b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,4 +1,5 @@ class Project < ActiveRecord::Base + belongs_to :category, :counter_cache => true belongs_to :owner, :polymorphic => true has_many :build_lists, :dependent => :destroy diff --git a/app/views/categories/_category.html.haml b/app/views/categories/_category.html.haml new file mode 100644 index 000000000..013dc5310 --- /dev/null +++ b/app/views/categories/_category.html.haml @@ -0,0 +1,9 @@ +%tr{:class => cycle("odd", "even")} + %td + = link_to category.name, category + (#{category.projects_count}) + %td= category.parent.try(:name) + %td.last + = link_to t("layout.edit"), edit_category_path(category) + | + = link_to t("layout.delete"), category_path(category), :method => :delete, :confirm => t("layout.categories.confirm_delete") \ No newline at end of file diff --git a/app/views/categories/_form.html.haml b/app/views/categories/_form.html.haml new file mode 100644 index 000000000..8f1649444 --- /dev/null +++ b/app/views/categories/_form.html.haml @@ -0,0 +1,15 @@ += form_for @category, :html => { :class => :form } do |f| + .group + = f.label :parent_id, :class => :label + = f.collection_select :parent_id, Category.roots, :id, :name, :include_blank => true + + .group + = f.label :name, :class => :label + = f.text_field :name, :class => 'text_field' + + .group.navform.wat-cf + %button.button{:type => "submit"} + = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) + = t("layout.save") + %span.text_button_padding= t("layout.or") + = link_to t("layout.cancel"), categories_path, :class => "text_button_padding link_button" diff --git a/app/views/categories/_sidebar.html.haml b/app/views/categories/_sidebar.html.haml new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/categories/edit.html.haml b/app/views/categories/edit.html.haml new file mode 100644 index 000000000..c279e42ac --- /dev/null +++ b/app/views/categories/edit.html.haml @@ -0,0 +1,11 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to t("layout.categories.list"), categories_path + %li= link_to t("layout.categories.platforms"), platforms_categories_path + %li= link_to t("layout.categories.new"), new_category_path + %li.active= link_to t("layout.categories.edit"), edit_category_path + .content + %h2.title= t("layout.categories.edit_header") + .inner= render "form" +- content_for :sidebar, render('sidebar') diff --git a/app/views/categories/index.html.haml b/app/views/categories/index.html.haml new file mode 100644 index 000000000..52700aad1 --- /dev/null +++ b/app/views/categories/index.html.haml @@ -0,0 +1,17 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first.active= link_to t("layout.categories.list"), categories_path + %li= link_to t("layout.categories.platforms"), platforms_categories_path + %li= link_to t("layout.categories.new"), new_category_path + .content + %h2.title= t("layout.categories.list_header") + .inner + %table.table + %tr + %th= t("activerecord.attributes.category.name") + %th= t("activerecord.attributes.category.parent_id") + %th.last   + = render @categories + .actions-bar.wat-cf + .actions= will_paginate @categories diff --git a/app/views/categories/index2.html.haml b/app/views/categories/index2.html.haml new file mode 100644 index 000000000..47abb3b04 --- /dev/null +++ b/app/views/categories/index2.html.haml @@ -0,0 +1,14 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to t("layout.categories.list"), categories_path + %li.active= link_to t("layout.categories.platforms"), platforms_categories_path + .content + %h2.title= @platform.name + .inner + %table.table + - @categories.each do |category| + %tr{:class => cycle("odd", "even")} + %td= link_to category.name, [@platform, category] + %td= category.parent.name + %td.last= @categories_count[category.id].to_i \ No newline at end of file diff --git a/app/views/categories/new.html.haml b/app/views/categories/new.html.haml new file mode 100644 index 000000000..a7c6611db --- /dev/null +++ b/app/views/categories/new.html.haml @@ -0,0 +1,9 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to "#{t("layout.categories.list")}", @categories_path + %li= link_to t("layout.categories.platforms"), platforms_categories_path + %li.active= link_to "#{t("layout.categories.new")}", @new_category_path + .content + %h2.title= t("layout.categories.new_header") + .inner= render "form" diff --git a/app/views/categories/platforms.html.haml b/app/views/categories/platforms.html.haml new file mode 100644 index 000000000..16fe5938f --- /dev/null +++ b/app/views/categories/platforms.html.haml @@ -0,0 +1,13 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to t("layout.categories.list"), categories_path + %li.active= link_to t("layout.categories.platforms"), platforms_categories_path + .content + %h2.title= t("layout.platforms.list_header") + .inner + %table.table + - @platforms.each do |platform| + %tr{:class => cycle("odd", "even")} + %td= link_to platform.name, platform_categories_path(platform) + %td.last= @platforms_count[platform.id].to_i diff --git a/app/views/categories/show.html.haml b/app/views/categories/show.html.haml new file mode 100644 index 000000000..0ee654296 --- /dev/null +++ b/app/views/categories/show.html.haml @@ -0,0 +1,15 @@ +.block + .secondary-navigation + %ul.wat-cf + %li.first= link_to t("layout.categories.list"), categories_path + %li= link_to t("layout.categories.platforms"), platforms_categories_path + - if @platform + %li.active= link_to @platform.name, platform_categories_path(@platform) + .content + %h2.title + = @category.name + (#{@category.parent.name}) + .inner + %table.table= render @projects + .actions-bar.wat-cf + .actions= will_paginate @projects diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f03c87859..9a91df604 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -24,6 +24,9 @@ %a{:href => groups_path}= t("layout.menu.groups") %li{:class => controller.controller_path == 'platforms' ? 'active' : '' } %a{:href => platforms_path}= t("layout.menu.platforms") + %li{:class => controller.controller_path == 'categories' ? 'active' : '' } + %a{:href => categories_path}= t("layout.menu.categories") + #wrapper.wat-cf = render :partial => "layouts/flashes" #main diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 51a3bf29e..c299f49d0 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -1,9 +1,15 @@ +.group + = f.label :category_id, t("activerecord.attributes.project.category_id"), :class => :label + = f.grouped_collection_select :category_id, Category.roots, :children, :name, :id, :name, :include_blank => true .group = f.label :name, t("activerecord.attributes.project.name"), :class => :label = f.text_field :name, :class => 'text_field' .group = f.label :unixname, t("activerecord.attributes.project.unixname"), :class => :label = f.text_field :unixname, :class => 'text_field' +.group + = f.label :description, t("activerecord.attributes.project.description"), :class => :label + = f.text_area :description, :class => 'text_field', :cols => 80 .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/app/views/projects/_project.html.haml b/app/views/projects/_project.html.haml new file mode 100644 index 000000000..9be9a1ddd --- /dev/null +++ b/app/views/projects/_project.html.haml @@ -0,0 +1,4 @@ +%tr{:class => cycle("odd", "even")} + %td= link_to project.name, project_path(project) + %td= project.unixname + %td= project.description \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 40ffe378f..f68fa8721 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -35,10 +35,21 @@ ru: users: Пользователи platforms: Платформы groups: Группы + categories: Категории sessions: sign_in_header: Вход в систему + categories: + list: Список + new: Создать + edit: Редактировать + platforms: По платформам + list_header: Категории + new_header: Новая категория + edit_header: Редактировать категорию + confirm_delete: Вы уверены, что хотите удалить эту категорию? + platforms: list: Список new: Создать @@ -189,6 +200,11 @@ ru: branch_not_found: бранч не найден flash: + category: + saved: Категория успешно сохранена + save_error: Не удалось сохранить категорию + destroyed: Категория успешно удалена + project: saved: Проект успешно сохранен save_error: Не удалось сохранить проект @@ -242,6 +258,7 @@ ru: activerecord: models: + category: Категория repository: Репозиторий arch: Arch container: Container @@ -255,6 +272,10 @@ ru: build_list_item: Элемент сборочного листа attributes: + category: + parent_id: Родитель + name: Название + repository: name: Название platform_id: Платформа @@ -304,8 +325,10 @@ ru: updated_at: Обновлена project: + category_id: Категория name: Название unixname: Unixname + description: Описание owner: Владелец visibility: Видимость repository_id: Репозиторий diff --git a/config/routes.rb b/config/routes.rb index 54d8d0a3f..29dc267e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,10 @@ Rosa::Application.routes.draw do devise_for :users + resources :categories do + get :platforms, :on => :collection + end + # resources :platforms do # member do # get 'freeze' @@ -53,6 +57,8 @@ Rosa::Application.routes.draw do resources :repositories do end + + resources :categories, :only => [:index, :show] end resources :projects do diff --git a/db/migrate/20111017152936_create_categories.rb b/db/migrate/20111017152936_create_categories.rb new file mode 100644 index 000000000..438dc11f5 --- /dev/null +++ b/db/migrate/20111017152936_create_categories.rb @@ -0,0 +1,15 @@ +class CreateCategories < ActiveRecord::Migration + def self.up + create_table :categories do |t| + t.string :name + t.string :ancestry + t.integer :projects_count, :default => 0, :null => false + + t.timestamps + end + end + + def self.down + drop_table :categories + end +end diff --git a/db/migrate/20111017172701_add_category_id_and_description_to_projects.rb b/db/migrate/20111017172701_add_category_id_and_description_to_projects.rb new file mode 100644 index 000000000..327374f48 --- /dev/null +++ b/db/migrate/20111017172701_add_category_id_and_description_to_projects.rb @@ -0,0 +1,14 @@ +class AddCategoryIdAndDescriptionToProjects < ActiveRecord::Migration + def self.up + change_table :projects do |t| + t.references :category + t.text :description + end + add_index :projects, :category_id + end + + def self.down + remove_column :projects, :description + remove_column :projects, :category_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f8e3e5745..f78e6c973 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111016225240) do +ActiveRecord::Schema.define(:version => 20111017172701) do create_table "arches", :force => true do |t| t.string "name", :null => false @@ -50,6 +50,14 @@ ActiveRecord::Schema.define(:version => 20111016225240) do add_index "build_lists", ["bs_id"], :name => "index_build_lists_on_bs_id", :unique => true add_index "build_lists", ["project_id"], :name => "index_build_lists_on_project_id" + create_table "categories", :force => true do |t| + t.string "name" + t.string "ancestry" + t.integer "projects_count", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "containers", :force => true do |t| t.string "name", :null => false t.integer "project_id", :null => false @@ -137,9 +145,13 @@ ActiveRecord::Schema.define(:version => 20111016225240) do t.datetime "updated_at" t.integer "owner_id" t.string "owner_type" - t.string "visibility", :default => "open" + t.string "visibility", :default => "open" + t.integer "category_id" + t.text "description" end + add_index "projects", ["category_id"], :name => "index_projects_on_category_id" + create_table "relations", :force => true do |t| t.integer "object_id" t.string "object_type" diff --git a/db/seeds.rb b/db/seeds.rb index 496bd8f19..eb5a4f02d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -37,3 +37,137 @@ ARCHES = %w(i586 i686 x86_64 mips powerpc) ARCHES.each do |arch| Arch.find_or_create_by_name arch end + +CATEGORIES = { + :mandriva => + %(Accessibility +Archiving/Backup +Archiving/Cd burning +Archiving/Compression +Archiving/Other +Books/Computer books +Books/Faqs +Books/Howtos +Books/Literature +Books/Other +Communications +Databases +Development/C +Development/C++ +Development/Databases +Development/GNOME and GTK+ +Development/Java +Development/KDE and Qt +Development/Kernel +Development/Other +Development/Perl +Development/PHP +Development/Python +Development/Ruby +Development/X11 +Editors +Education +Emulators +File tools +Games/Adventure +Games/Arcade +Games/Boards +Games/Cards +Games/Other +Games/Puzzles +Games/Sports +Games/Strategy +Graphical desktop/Enlightenment +Graphical desktop/FVWM based +Graphical desktop/GNOME +Graphical desktop/Icewm +Graphical desktop/KDE +Graphical desktop/Other +Graphical desktop/Sawfish +Graphical desktop/WindowMaker +Graphical desktop/Xfce +Graphics +Monitoring +Networking/Chat +Networking/File transfer +Networking/Instant messaging +Networking/IRC +Networking/Mail +Networking/News +Networking/Other +Networking/Remote access +Networking/WWW +Office +Publishing +Sciences/Astronomy +Sciences/Biology +Sciences/Chemistry +Sciences/Computer science +Sciences/Geosciences +Sciences/Mathematics +Sciences/Other +Sciences/Physics +Shells +Sound +System/Base +System/Cluster +System/Configuration/Boot and Init +System/Configuration/Hardware +System/Configuration/Networking +System/Configuration/Other +System/Configuration/Packaging +System/Configuration/Printing +System/Fonts/Console +System/Fonts/True type +System/Fonts/Type1 +System/Fonts/X11 bitmap +System/Internationalization +System/Kernel and hardware +System/Libraries +System/Printing +System/Servers +System/X11 +Terminals +Text tools +Toys +Video), + :naulinux => +%(Amusements/Games +Amusements/Graphics +Applications/Archiving +Applications/Communications +Applications/Databases +Applications/Editors +Applications/Emulators +Applications/Engineering +Applications/File +Applications/Internet +Applications/Multimedia +Applications/Productivity +Applications/Publishing +Applications/System +Applications/Text +Development/Debuggers +Development/Languages +Development/Libraries +Development/System +Development/Tools +Documentation +System Environment/Base +System Environment/Daemons +System Environment/Kernel +System Environment/Libraries +System Environment/Shells +User Interface/Desktops +User Interface/X +User Interface/X Hardware Support) +} + +CATEGORIES.each do |platform_type, categories| + parent = Category.roots.find_or_create_by_name(platform_type) + categories.split("\n").each do |category| + Category.find_or_create_by_name(category) do |c| + c.parent = parent + end + end +end diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rb new file mode 100644 index 000000000..a0861c93a --- /dev/null +++ b/spec/models/category_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Category do + pending "add some examples to (or delete) #{__FILE__}" +end