From 796ff758575ae427c7ff3b23981095d23c081f7e Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Thu, 24 Nov 2011 23:46:19 +0200 Subject: [PATCH] Great models refactoring. Refactor some cancan abilities and controllers authorization. Move some common parts to modules. Fix lots bugs. Remove unused files and code. Drop ACL tables. Add more can? helpers. Refs #2249 --- .../auto_build_lists_controller.rb | 34 ++------ app/controllers/build_lists_controller.rb | 5 +- app/controllers/categories_controller.rb | 4 +- app/controllers/collaborators_controller.rb | 14 ++-- app/controllers/downloads_controller.rb | 3 +- app/controllers/event_logs_controller.rb | 1 + app/controllers/git/base_controller.rb | 2 + app/controllers/groups_controller.rb | 2 +- .../personal_repositories_controller.rb | 15 +--- app/controllers/platforms_controller.rb | 5 +- app/controllers/private_users_controller.rb | 7 +- .../product_build_lists_controller.rb | 4 +- app/controllers/products_controller.rb | 3 +- app/controllers/projects_controller.rb | 6 +- app/controllers/repositories_controller.rb | 8 +- app/controllers/users_controller.rb | 2 +- app/helpers/auto_build_lists_helper.rb | 2 - app/helpers/collaborators_helper.rb | 2 - app/helpers/containers_helper.rb | 2 - app/helpers/download_helper.rb | 2 - app/helpers/personal_repositories_helper.rb | 2 - app/helpers/private_users_helper.rb | 2 - app/helpers/privates_helper.rb | 2 - app/helpers/product_build_lists_helper.rb | 2 - app/helpers/products_helper.rb | 2 - app/helpers/users_helper.rb | 2 - app/models/ability.rb | 6 +- app/models/build_list.rb | 4 - app/models/container.rb | 4 +- app/models/group.rb | 24 +----- app/models/permission.rb | 35 -------- app/models/personal_repository.rb | 35 -------- app/models/platform.rb | 82 ++----------------- app/models/product.rb | 20 ++--- app/models/project.rb | 16 +--- app/models/project_to_repository.rb | 50 ----------- app/models/repository.rb | 47 +---------- app/models/right.rb | 21 ----- app/models/rpm.rb | 6 +- app/models/user.rb | 8 +- .../auto_build_lists/_not_automated.html.haml | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/platforms/show.html.haml | 8 +- app/views/projects/_sidebar.html.haml | 2 +- app/views/repositories/_form.html.haml | 3 - app/views/repositories/index.html.haml | 2 +- app/views/repositories/show.html.haml | 2 +- config/environments/development.rb | 1 - config/initializers/load_config.rb | 2 + db/migrate/20111123160010_drop_acl_tables.rb | 42 ++++++++++ db/schema.rb | 48 ++--------- lib/modules.rb | 11 +++ lib/modules/models/owner.rb | 17 ++++ lib/modules/models/personal_repository.rb | 41 ++++++++++ spec/helpers/auto_build_lists_helper_spec.rb | 15 ---- spec/helpers/collaborators_helper_spec.rb | 15 ---- spec/helpers/containers_helper_spec.rb | 15 ---- spec/helpers/download_helper_spec.rb | 15 ---- spec/helpers/git_helper_spec.rb | 15 ---- .../personal_repositories_helper_spec.rb | 15 ---- spec/helpers/platforms_helper_spec.rb | 15 ---- spec/helpers/private_users_helper_spec.rb | 15 ---- spec/helpers/privates_helper_spec.rb | 15 ---- .../product_build_lists_helper_spec.rb | 15 ---- spec/helpers/products_helper_spec.rb | 15 ---- spec/helpers/projects_helper_spec.rb | 15 ---- spec/helpers/users_helper_spec.rb | 15 ---- spec/models/permission_spec.rb | 5 -- spec/models/right_spec.rb | 5 -- spec/routing/permissions_routing_spec.rb | 35 -------- spec/routing/rights_routing_spec.rb | 35 -------- spec/routing/roles_routing_spec.rb | 35 -------- spec/views/permissions/edit.html.haml_spec.rb | 22 ----- .../views/permissions/index.html.haml_spec.rb | 28 ------- spec/views/permissions/new.html.haml_spec.rb | 22 ----- spec/views/permissions/show.html.haml_spec.rb | 21 ----- .../edit.html.haml_spec.rb | 20 ----- .../index.html.haml_spec.rb | 24 ------ .../product_build_lists/new.html.haml_spec.rb | 20 ----- .../show.html.haml_spec.rb | 18 ---- spec/views/rights/edit.html.haml_spec.rb | 22 ----- spec/views/rights/index.html.haml_spec.rb | 28 ------- spec/views/rights/new.html.haml_spec.rb | 22 ----- spec/views/rights/show.html.haml_spec.rb | 21 ----- spec/views/roles/edit.html.haml_spec.rb | 18 ---- spec/views/roles/index.html.haml_spec.rb | 20 ----- spec/views/roles/new.html.haml_spec.rb | 18 ---- spec/views/roles/show.html.haml_spec.rb | 15 ---- test/integration/permission_test.rb | 10 --- test/integration/product_build_list_test.rb | 10 --- test/integration/right_test.rb | 10 --- test/integration/role_test.rb | 10 --- 92 files changed, 201 insertions(+), 1164 deletions(-) delete mode 100644 app/helpers/auto_build_lists_helper.rb delete mode 100644 app/helpers/collaborators_helper.rb delete mode 100644 app/helpers/containers_helper.rb delete mode 100644 app/helpers/download_helper.rb delete mode 100644 app/helpers/personal_repositories_helper.rb delete mode 100644 app/helpers/private_users_helper.rb delete mode 100644 app/helpers/privates_helper.rb delete mode 100644 app/helpers/product_build_lists_helper.rb delete mode 100644 app/helpers/products_helper.rb delete mode 100644 app/helpers/users_helper.rb delete mode 100644 app/models/permission.rb delete mode 100644 app/models/personal_repository.rb delete mode 100644 app/models/right.rb create mode 100644 db/migrate/20111123160010_drop_acl_tables.rb create mode 100644 lib/modules.rb create mode 100644 lib/modules/models/owner.rb create mode 100644 lib/modules/models/personal_repository.rb delete mode 100644 spec/helpers/auto_build_lists_helper_spec.rb delete mode 100644 spec/helpers/collaborators_helper_spec.rb delete mode 100644 spec/helpers/containers_helper_spec.rb delete mode 100644 spec/helpers/download_helper_spec.rb delete mode 100644 spec/helpers/git_helper_spec.rb delete mode 100644 spec/helpers/personal_repositories_helper_spec.rb delete mode 100644 spec/helpers/platforms_helper_spec.rb delete mode 100644 spec/helpers/private_users_helper_spec.rb delete mode 100644 spec/helpers/privates_helper_spec.rb delete mode 100644 spec/helpers/product_build_lists_helper_spec.rb delete mode 100644 spec/helpers/products_helper_spec.rb delete mode 100644 spec/helpers/projects_helper_spec.rb delete mode 100644 spec/helpers/users_helper_spec.rb delete mode 100644 spec/models/permission_spec.rb delete mode 100644 spec/models/right_spec.rb delete mode 100644 spec/routing/permissions_routing_spec.rb delete mode 100644 spec/routing/rights_routing_spec.rb delete mode 100644 spec/routing/roles_routing_spec.rb delete mode 100644 spec/views/permissions/edit.html.haml_spec.rb delete mode 100644 spec/views/permissions/index.html.haml_spec.rb delete mode 100644 spec/views/permissions/new.html.haml_spec.rb delete mode 100644 spec/views/permissions/show.html.haml_spec.rb delete mode 100644 spec/views/product_build_lists/edit.html.haml_spec.rb delete mode 100644 spec/views/product_build_lists/index.html.haml_spec.rb delete mode 100644 spec/views/product_build_lists/new.html.haml_spec.rb delete mode 100644 spec/views/product_build_lists/show.html.haml_spec.rb delete mode 100644 spec/views/rights/edit.html.haml_spec.rb delete mode 100644 spec/views/rights/index.html.haml_spec.rb delete mode 100644 spec/views/rights/new.html.haml_spec.rb delete mode 100644 spec/views/rights/show.html.haml_spec.rb delete mode 100644 spec/views/roles/edit.html.haml_spec.rb delete mode 100644 spec/views/roles/index.html.haml_spec.rb delete mode 100644 spec/views/roles/new.html.haml_spec.rb delete mode 100644 spec/views/roles/show.html.haml_spec.rb delete mode 100644 test/integration/permission_test.rb delete mode 100644 test/integration/product_build_list_test.rb delete mode 100644 test/integration/right_test.rb delete mode 100644 test/integration/role_test.rb diff --git a/app/controllers/auto_build_lists_controller.rb b/app/controllers/auto_build_lists_controller.rb index 7a6daaeb4..42724cfe5 100644 --- a/app/controllers/auto_build_lists_controller.rb +++ b/app/controllers/auto_build_lists_controller.rb @@ -1,11 +1,9 @@ class AutoBuildListsController < ApplicationController before_filter :authenticate_user!, :except => :auto_build - before_filter :find_project, :only => :create before_filter :find_auto_build_list, :only => :destroy - authorize_resource - skip_authorize_resource :only => :create - + load_and_authorize_resource + def index projects = Project.where(:owner_id => current_user.id, :owner_type => 'User').order('name ASC') @projects_not_automated = projects.automateable.paginate(:page => params[:not_automated_page]) @@ -14,30 +12,17 @@ class AutoBuildListsController < ApplicationController @projects_already_automated = projects.select('projects.*, auto_build_lists.id auto_build_lists_id'). joins(:auto_build_lists).paginate(:page => params[:already_automated_page]) end - - #def new - # @auto_build_list = AutoBuildList.new - # # Now user can create auto_build_list only for personal repository and i586 arch. - # @bpls = Platform.where(:id => current_user.personal_platform.id) - # @pls = Platform.where(:id => current_user.personal_platform.id) - # @archs = Arch.where(:name => 'i386') - #end - + def create - authorize :build, @project - #@auto_build_list = AutoBuildList.new(params[:auto_build_list]) - @auto_build_list = AutoBuildList.new( :bpl_id => Platform.find_by_unixname('mandriva2011').try(:id), :pl_id => current_user.personal_platform.id, :arch_id => Arch.find_by_name('i586').id, - :project_id => params[:project_id] - ) - + :project_id => params[:project_id]) + if @auto_build_list.save - redirect_to auto_build_lists_path(), :notice => t('flash.auto_build_list.success') + redirect_to auto_build_lists_path, :notice => t('flash.auto_build_list.success') else - #render :action => 'new' redirect_to auto_build_lists_path, :notice => t('flash.auto_build_list.failed') end end @@ -51,14 +36,9 @@ class AutoBuildListsController < ApplicationController redirect_to auto_build_lists_path end -protected - - def find_project - @project = Project.find(params[:project_id]) - end + protected def find_auto_build_list @auto_build_list = AutoBuildList.find(params[:id]) end - end diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index d32a52a2e..72814895f 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -6,8 +6,7 @@ class BuildListsController < ApplicationController before_filter :find_project_versions, :only => [:index, :filter] before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build] - authorize_resource - skip_authorize_resource :only => :index + load_and_authorize_resource def all if params[:filter] @@ -34,8 +33,6 @@ class BuildListsController < ApplicationController end def index - authorize! :build, @project - @build_lists = @project.build_lists.recent.paginate :page => params[:page] @filter = BuildList::Filter.new(@project) @action_url = project_build_lists_path(@project) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 3ce7bb48b..df0944d58 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -3,7 +3,7 @@ class CategoriesController < ApplicationController before_filter :find_category, :only => [:show, :edit, :update, :destroy] before_filter :find_platform, :only => [:show, :index] - authorize_resource + load_and_authorize_resource def platforms @all_platforms = Platform.all @@ -18,7 +18,7 @@ class CategoriesController < ApplicationController if @platform @categories = Category.select('categories.id, categories.name, categories.ancestry, count(projects.id) projects_count'). joins(:projects => :repositories).where('repositories.platform_id = ?', @platform.id). - having('projects_count > 0').group('categories.id, categories.name, categories.ancestry, projects_count').default_order + having('count(projects.id) > 0').group('categories.id, categories.name, categories.ancestry, projects_count').default_order render 'index2' else @categories = Category.default_order.paginate(:page => params[:page]) diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/collaborators_controller.rb index 985113b02..72d45bc61 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/collaborators_controller.rb @@ -2,13 +2,12 @@ class CollaboratorsController < ApplicationController before_filter :authenticate_user! before_filter :find_project - before_filter :find_users before_filter :find_groups - def index - authorize! :manage_collaborators, @project - + load_and_authorize_resource :project + + def index redirect_to edit_project_collaborators_path(@project) end @@ -19,15 +18,16 @@ class CollaboratorsController < ApplicationController end def edit - authorize! :manage_collaborators, @project + if params[:id] + @user = User.find params[:id] + render :edit_rights and return + end end def create end def update - authorize! :manage_collaborators, @project - all_user_ids = [] Relation::ROLES.each { |r| all_user_ids = all_user_ids | params[r.to_sym].keys if params[r.to_sym] diff --git a/app/controllers/downloads_controller.rb b/app/controllers/downloads_controller.rb index 4ba699807..41d3072f0 100644 --- a/app/controllers/downloads_controller.rb +++ b/app/controllers/downloads_controller.rb @@ -1,7 +1,6 @@ class DownloadsController < ApplicationController before_filter :authenticate_user! - - authorize_resource + load_and_authorize_resource def index @downloads = Download.paginate :page => params[:page], :per_page => 30 diff --git a/app/controllers/event_logs_controller.rb b/app/controllers/event_logs_controller.rb index a3d62b8ed..91b16e482 100644 --- a/app/controllers/event_logs_controller.rb +++ b/app/controllers/event_logs_controller.rb @@ -1,6 +1,7 @@ # coding: UTF-8 class EventLogsController < ApplicationController before_filter :authenticate_user! + load_and_authorize_resource def index @event_logs = EventLog.default_order.eager_loading.paginate :page => params[:page] diff --git a/app/controllers/git/base_controller.rb b/app/controllers/git/base_controller.rb index f91704749..90ed02ecf 100644 --- a/app/controllers/git/base_controller.rb +++ b/app/controllers/git/base_controller.rb @@ -9,6 +9,8 @@ class Git::BaseController < ApplicationController before_filter :set_current_tag before_filter :set_current_branch + load_and_authorize_resource :project + protected def find_project @project = Project.find(params[:project_id]) diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index fa59357ab..ec116fb6a 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -3,7 +3,7 @@ class GroupsController < ApplicationController before_filter :authenticate_user! before_filter :find_group, :only => [:show, :edit, :update, :destroy] - authorize_resource + load_and_authorize_resource def index @groups = Group.paginate(:page => params[:group_page]) diff --git a/app/controllers/personal_repositories_controller.rb b/app/controllers/personal_repositories_controller.rb index 8ca4b96c7..fb078858b 100644 --- a/app/controllers/personal_repositories_controller.rb +++ b/app/controllers/personal_repositories_controller.rb @@ -2,12 +2,10 @@ class PersonalRepositoriesController < ApplicationController before_filter :authenticate_user! before_filter :find_repository#, :only => [:show, :destroy, :add_project, :remove_project, :make_private, :settings] before_filter :check_repository - - #authorize_resource + + load_and_authorize_resource :class => Repository def show - authorize! :read, @repository - if params[:query] @projects = @repository.projects.recent.by_name(params[:query]).paginate :page => params[:project_page], :per_page => 30 else @@ -18,20 +16,15 @@ class PersonalRepositoriesController < ApplicationController end def change_visibility - authorize! :change_visibility, @repository - @repository.platform.change_visibility redirect_to settings_personal_repository_path(@repository) end def settings - authorize! :settings, @repository end def add_project - authorize! :add_project, @repository - if params[:project_id] @project = Project.find(params[:project_id]) # params[:project_id] = nil @@ -49,8 +42,6 @@ class PersonalRepositoriesController < ApplicationController end def remove_project - authorize! :remove_project, @repository - @project = Project.find(params[:project_id]) ProjectToRepository.where(:project_id => @project.id, :repository_id => @repository.id).destroy_all redirect_to personal_repository_path(@repository), :notice => t('flash.repository.project_removed') @@ -61,7 +52,7 @@ class PersonalRepositoriesController < ApplicationController def find_repository @repository = Repository.find(params[:id]) end - + def check_repository redirect_to root_path if !@repository.platform.personal? end diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index 95fc0f19a..b4f5c1291 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -4,11 +4,10 @@ class PlatformsController < ApplicationController before_filter :find_platform, :only => [:freeze, :unfreeze, :clone, :edit, :destroy] before_filter :get_paths, :only => [:new, :create, :clone] - authorize_resource + load_and_authorize_resource def index - #@platforms = Platform.accessible_by(current_ability).paginate(:page => params[:platform_page]) - @platforms = Platform.paginate(:page => params[:platform_page]) + @platforms = Platform.accessible_by(current_ability).paginate(:page => params[:platform_page]) end def easy_urpmi diff --git a/app/controllers/private_users_controller.rb b/app/controllers/private_users_controller.rb index a296c8a7e..8583eed73 100644 --- a/app/controllers/private_users_controller.rb +++ b/app/controllers/private_users_controller.rb @@ -2,7 +2,7 @@ class PrivateUsersController < ApplicationController before_filter :authenticate_user! before_filter :find_platform_and_private_users - authorize_resource + load_and_authorize_resource :platform def index end @@ -13,10 +13,7 @@ class PrivateUsersController < ApplicationController @pair = PrivateUser.generate_pair(params[:platform_id], current_user.id) @urpmi_list = @platform.urpmi_list(request.host, @pair) - #redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }" - flash[:notice] = "Логин: #{ @pair[:login] } Пароль: #{ @pair[:pass] }" - - render :action => 'index' + redirect_to platform_private_users_path(params[:platform_id]), :notice => "Логин: #{@pair[:login]} Пароль: #{@pair[:pass]}" end #def destroy diff --git a/app/controllers/product_build_lists_controller.rb b/app/controllers/product_build_lists_controller.rb index 26a3c0633..7fbf3ffb7 100644 --- a/app/controllers/product_build_lists_controller.rb +++ b/app/controllers/product_build_lists_controller.rb @@ -4,7 +4,9 @@ class ProductBuildListsController < ApplicationController before_filter :find_product, :except => [:status_build] before_filter :find_platform, :except => [:status_build] - authorize_resource + load_and_authorize_resource :platform + load_and_authorize_resource :product, :through => :platform + load_and_authorize_resource :product_build_list, :through => :product # def index # end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb index fe7592b08..9b5327dc9 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/products_controller.rb @@ -3,7 +3,8 @@ class ProductsController < ApplicationController before_filter :find_product, :only => [:show, :edit, :update, :destroy] before_filter :find_platform - authorize_resource + load_and_authorize_resource :platform + load_and_authorize_resource :product, :through => :platform def new @product = @platform.products.new diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index dde76c200..27c264f37 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -7,11 +7,9 @@ class ProjectsController < ApplicationController def index if params[:query] - #@projects = Project.accessible_by(current_ability).where(:name => params[:query]).paginate(:page => params[:project_page]) - @projects = Project.where(:name => params[:query]).paginate(:page => params[:project_page]) + @projects = Project.accessible_by(current_ability).where(:name => params[:query]).paginate(:page => params[:project_page]) else - #@projects = Project.accessible_by(current_ability).paginate(:page => params[:project_page]) - @projects = Project.paginate(:page => params[:project_page]) + @projects = Project.accessible_by(current_ability).paginate(:page => params[:project_page]) end @own_projects = current_user.own_projects diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1ef45c970..0d457cb91 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -1,11 +1,12 @@ class RepositoriesController < ApplicationController before_filter :authenticate_user! - #before_filter :find_platform, :except => [:index, :new, :create] - before_filter :find_repository, :only => [:show, :destroy, :add_project, :remove_project] + before_filter :find_repository, :except => [:index, :new, :create] + before_filter :find_platform, :only => [:show, :destroy, :add_project, :remove_project] before_filter :get_paths, :only => [:show, :new, :create, :add_project, :remove_project] before_filter :find_platforms, :only => [:new, :create] - authorize_resource + load_and_authorize_resource :platform + load_and_authorize_resource :repository, :through => :platform, :shallow => true def index if params[:platform_id] @@ -38,6 +39,7 @@ class RepositoriesController < ApplicationController def create @repository = Repository.new(params[:repository]) + @repository.platform_id = params[:platform_id] @repository.owner = get_owner if @repository.save flash[:notice] = t('flash.repository.saved') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 73c05c1d3..711847c32 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -3,7 +3,7 @@ class UsersController < ApplicationController before_filter :authenticate_user! before_filter :find_user, :only => [:show, :edit, :update, :destroy] - authorize_resource + load_and_authorize_resource def index @users = User.paginate(:page => params[:user_page]) diff --git a/app/helpers/auto_build_lists_helper.rb b/app/helpers/auto_build_lists_helper.rb deleted file mode 100644 index 98e76397b..000000000 --- a/app/helpers/auto_build_lists_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module AutoBuildListsHelper -end diff --git a/app/helpers/collaborators_helper.rb b/app/helpers/collaborators_helper.rb deleted file mode 100644 index 908c1ac46..000000000 --- a/app/helpers/collaborators_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module CollaboratorsHelper -end diff --git a/app/helpers/containers_helper.rb b/app/helpers/containers_helper.rb deleted file mode 100644 index aa138f451..000000000 --- a/app/helpers/containers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ContainersHelper -end diff --git a/app/helpers/download_helper.rb b/app/helpers/download_helper.rb deleted file mode 100644 index 9e232c4ef..000000000 --- a/app/helpers/download_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module DownloadHelper -end diff --git a/app/helpers/personal_repositories_helper.rb b/app/helpers/personal_repositories_helper.rb deleted file mode 100644 index db846e4c5..000000000 --- a/app/helpers/personal_repositories_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PersonalRepositoriesHelper -end diff --git a/app/helpers/private_users_helper.rb b/app/helpers/private_users_helper.rb deleted file mode 100644 index c8c63083d..000000000 --- a/app/helpers/private_users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PrivateUsersHelper -end diff --git a/app/helpers/privates_helper.rb b/app/helpers/privates_helper.rb deleted file mode 100644 index d4e240ef7..000000000 --- a/app/helpers/privates_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PrivatesHelper -end diff --git a/app/helpers/product_build_lists_helper.rb b/app/helpers/product_build_lists_helper.rb deleted file mode 100644 index 3fd279807..000000000 --- a/app/helpers/product_build_lists_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ProductBuildListsHelper -end diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb deleted file mode 100644 index ab5c42b32..000000000 --- a/app/helpers/products_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ProductsHelper -end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb deleted file mode 100644 index 2310a240d..000000000 --- a/app/helpers/users_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module UsersHelper -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8888251b8..e7b22ad03 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -20,10 +20,12 @@ class Ability # Guest rights if user.guest? can :create, User - # Registered user rights else - can :index, AutoBuildList + can [:read, :platforms], Category + + can :create, AutoBuildList + can [:index, :destroy], AutoBuildList, :project_id => user.own_project_ids # If rules goes one by one CanCan joins them by 'OR' sql operator can :read, Project, :visibility => 'open' can :read, User diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 1d003245d..a637f4b9a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -8,15 +8,11 @@ class BuildList < ActiveRecord::Base validates :project_id, :presence => true validates :project_version, :presence => true #validates_inclusion_of :update_type, :in => UPDATE_TYPES#, :message => "extension %s is not included in the list" - UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage] - validates :update_type, :inclusion => UPDATE_TYPES - validate lambda { errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id } - validate lambda { errors.add(:bpl, I18n.t('flash.build_list.can_not_published')) if status == BUILD_PUBLISHED && status_was != BuildServer::SUCCESS } diff --git a/app/models/container.rb b/app/models/container.rb index 2a1741414..7008fa54d 100644 --- a/app/models/container.rb +++ b/app/models/container.rb @@ -2,7 +2,5 @@ class Container < ActiveRecord::Base belongs_to :project belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id' - validates :name, :presence => true - validates :project_id, :presence => true - validates :onwer_id, :presence => true + validates :name, :project_id, :onwer_id, :presence => true end diff --git a/app/models/group.rb b/app/models/group.rb index 4c0ce1b72..e56a0709a 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -6,7 +6,6 @@ class Group < ActiveRecord::Base has_many :relations, :as => :object, :dependent => :destroy has_many :objects, :as => :target, :class_name => 'Relation' has_many :targets, :as => :object, :class_name => 'Relation' - has_many :roles, :through => :targets has_many :members, :through => :objects, :source => :object, :source_type => 'User', :autosave => true has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true @@ -14,30 +13,13 @@ class Group < ActiveRecord::Base has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true validates :name, :owner, :presence => true - validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }, :allow_nil => false, :allow_blank => false + validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? } attr_readonly :uname delegate :ssh_key, :to => :owner - include PersonalRepository - - after_create :make_owner_rel - before_save :check_owner_rel - - protected - - def make_owner_rel - r = relations.build :object_id => owner.id, :object_type => 'User', :role => 'admin' - r.save - end - - def check_owner_rel - if !new_record? and owner_id_changed? - relations.by_object(owner).delete_all if owner_type_was - make_owner_rel if owner - end - end - + include Modules::Models::PersonalRepository + include Modules::Models::Owner end diff --git a/app/models/permission.rb b/app/models/permission.rb deleted file mode 100644 index ee04111f2..000000000 --- a/app/models/permission.rb +++ /dev/null @@ -1,35 +0,0 @@ -class Permission < ActiveRecord::Base - belongs_to :role - belongs_to :right - - def name - Permission.right(self.right_id) - end - def self.get_rights_list - res=[] - for k in 1..8 - res << [Permission.right(k), k] - end - return res - end - def self.right(n) - case n - when 1 - "Проекты - Чтение" - when 2 - "Проекты - Чтение/Запись" - when 3 - "Проекты - Сборка" - when 4 - "Репозиторий - Просмотр" - when 5 - "Репозиторий - Изменение состава пакетов" - when 6 - "Платформа - Создание/Удаление репозиториев" - when 7 - "Платформа - Изменение параметров платформы" - when 8 - "Платформа - Сборка" - end - end -end diff --git a/app/models/personal_repository.rb b/app/models/personal_repository.rb deleted file mode 100644 index 6935a77dd..000000000 --- a/app/models/personal_repository.rb +++ /dev/null @@ -1,35 +0,0 @@ -module PersonalRepository - extend ActiveSupport::Concern - - included do - after_create :create_personal_repository - end - - module InstanceMethods - def create_personal_repository - pl = platforms.build - pl.owner = self - pl.name = "#{self.uname}_personal" - pl.unixname = "#{self.uname}_personal" - pl.platform_type = 'personal' - pl.distrib_type = APP_CONFIG['distr_types'].first - pl.visibility = 'hidden' - pl.save! - - rep = pl.repositories.build - rep.owner = pl.owner - rep.name = 'main' - rep.unixname = 'main' - rep.save! - end - - def personal_platform - platforms.personal.first - end - - def personal_repository - personal_platform.repositories.first - end - end - -end diff --git a/app/models/platform.rb b/app/models/platform.rb index fccd1f28a..37b9126f8 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -1,6 +1,5 @@ #require 'lib/build_server.rb' class Platform < ActiveRecord::Base - DOWNLOADS_PATH = RAILS_ROOT + '/public/downloads' VISIBILITIES = ['open', 'hidden'] belongs_to :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' @@ -15,29 +14,14 @@ class Platform < ActiveRecord::Base has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' validates :name, :presence => true, :uniqueness => true - validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-z0-9_]+$/ }, :allow_nil => false, :allow_blank => false - validates :distrib_type, :presence => true, :allow_nil => :false, :allow_blank => false, :inclusion => {:in => APP_CONFIG['distr_types']} + validates :unixname, :uniqueness => true, :presence => true, :format => { :with => /^[a-z0-9_]+$/ } + validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} - after_create :make_owner_rel - before_save :check_owner_rel -# before_save :create_directory -# after_destroy :remove_directory before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy # before_update :check_freezing - after_create lambda { - unless self.hidden? - #add_downloads_symlink - mount_directory_for_rsync - end - } - - after_destroy lambda { - unless self.hidden? - #remove_downloads_symlink - umount_directory_for_rsync - end - } + after_create lambda { mount_directory_for_rsync unless hidden? } + after_destroy lambda { umount_directory_for_rsync unless hidden? } scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}} scope :open, where(:visibility => 'open') @@ -47,6 +31,8 @@ class Platform < ActiveRecord::Base #attr_accessible :visibility + include Modules::Models::Owner + def urpmi_list(host, pair = nil) blank_pair = {:login => 'login', :pass => 'password'} pair = blank_pair if pair.blank? @@ -75,7 +61,7 @@ class Platform < ActiveRecord::Base end def hidden? - self.visibility == 'hidden' + visibility == 'hidden' end def personal? @@ -102,7 +88,6 @@ class Platform < ActiveRecord::Base ensure Thread.current[:skip] = false end - # (Thread.current[:skip] = true) and p.save and (Thread.current[:skip] = false or true) and xml_rpc_clone(attrs[:unixname]) p end @@ -113,23 +98,14 @@ class Platform < ActiveRecord::Base def change_visibility if !self.hidden? self.update_attribute(:visibility, 'hidden') - #remove_downloads_symlink umount_directory_for_rsync else self.update_attribute(:visibility, 'open') - #add_downloads_symlink mount_directory_for_rsync end end - - #def add_downloads_symlink - # #raise "Personal platform path #{ symlink_downloads_path } already exists!" if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path) - # return true if File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path) - # FileUtils.symlink path, symlink_downloads_path - #end def mount_directory_for_rsync - #system("touch #{ Rails.root.join('tmp') }/mount_rsync") FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.unixname) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', unixname) }" FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', unixname) }" Arch.all.each do |arch| @@ -140,14 +116,7 @@ class Platform < ActiveRecord::Base end end - #def remove_downloads_symlink - # #raise "Personal platform path #{ symlink_downloads_path } does not exists!" if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)) - # return true if !(File.exists?(symlink_downloads_path) && File.directory?(symlink_downloads_path)) - # FileUtils.rm_rf symlink_downloads_path - #end - def umount_directory_for_rsync - #system("touch #{ Rails.root.join('tmp') }/unmount_rsync") FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', unixname) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', unixname) }" FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', unixname) }" end @@ -158,26 +127,6 @@ class Platform < ActiveRecord::Base File.join(APP_CONFIG['root_path'], 'platforms', dir) end - def git_path(dir) - File.join(build_path(dir), 'git') - end - - def create_directory - exists = File.exists?(path) && File.directory?(path) - raise "Directory #{path} already exists" if exists - if new_record? - FileUtils.mkdir_p(path) - elsif unixname_changed? - FileUtils.mv(build_path(unixname_was), build_path(unixname)) - end - end - - def remove_directory - exists = File.exists?(path) && File.directory?(path) - raise "Directory #{path} didn't exists" unless exists - FileUtils.rm_rf(path) - end - def xml_rpc_create result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] + '/platforms' , distrib_type if result == BuildServer::SUCCESS @@ -210,21 +159,4 @@ class Platform < ActiveRecord::Base BuildServer.freeze_platform self.unixname end end - - def symlink_downloads_path - "#{ DOWNLOADS_PATH }/#{ self.unixname }" - end - - def make_owner_rel - r = relations.build :object_id => owner.id, :object_type => 'User', :role => 'admin' - r.save - end - - def check_owner_rel - if !new_record? and owner_id_changed? - relations.by_object(owner).delete_all if owner_type_was - make_owner_rel if owner - end - end - end diff --git a/app/models/product.rb b/app/models/product.rb index eabd4fbb3..e0c00ebbf 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,26 +1,19 @@ class Product < ActiveRecord::Base - # NEVER_BUILT = 2 - # BUILD_COMPLETED = 0 - # BUILD_FAILED = 1 - ATTRS_TO_CLONE = [ 'build_path', 'build_script', 'counter', 'ks', 'menu', 'tar', 'use_cron', 'cron_tab' ] - validates :name, :presence => true, :uniqueness => {:scope => :platform_id} - # validates :build_status, :inclusion => { :in => [ NEVER_BUILT, BUILD_COMPLETED, BUILD_FAILED ] } - # validates :platform_id, :presence => true # if you uncomment this platform clone will not work - belongs_to :platform has_many :product_build_lists, :dependent => :destroy - has_attached_file :tar - validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip2", "application/x-tar"], :message => I18n.t('layout.products.invalid_content_type') - after_validation :merge_tar_errors + before_save :destroy_tar? + + has_attached_file :tar + + validates_attachment_content_type :tar, :content_type => ["application/gnutar", "application/x-compressed", "application/x-gzip", "application/x-bzip2", "application/x-tar"], :message => I18n.t('layout.products.invalid_content_type') + validates :name, :presence => true, :uniqueness => {:scope => :platform_id} scope :recent, order("name ASC") - before_save :destroy_tar? - def delete_tar @delete_tar ||= "0" end @@ -83,5 +76,4 @@ class Product < ActiveRecord::Base errors[:tar_content_type] = [] end - end diff --git a/app/models/project.rb b/app/models/project.rb index a49bd33aa..50c4b0cb8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -28,7 +28,6 @@ class Project < ActiveRecord::Base scope :addable_to_repository, lambda { |repository_id| where("projects.id NOT IN (SELECT project_to_repositories.project_id FROM project_to_repositories WHERE (project_to_repositories.repository_id = #{ repository_id }))") } scope :automateable, where("projects.id NOT IN (SELECT auto_build_lists.project_id FROM auto_build_lists)") - after_create :make_owner_rel after_create :attach_to_personal_repository after_create :create_git_repo after_destroy :destroy_git_repo @@ -36,6 +35,8 @@ class Project < ActiveRecord::Base has_ancestry + include Modules::Models::Owner + def auto_build auto_build_lists.each do |auto_build_list| build_lists.create( @@ -87,15 +88,6 @@ class Project < ActiveRecord::Base end end - def add_to_repository(platf, repo) - result = BuildServer.add_to_repo(repository.name, platf.name) - if result == BuildServer::SUCCESS - return true - else - raise "Failed to add project #{name} to repo #{repo.name} of platform #{platf.name} with code #{result}." - end - end - def path build_path(git_repo_name) end @@ -135,8 +127,4 @@ class Project < ActiveRecord::Base def destroy_git_repo FileUtils.rm_rf path end - - def make_owner_rel - relations.create :object_id => owner_id, :object_type => owner_type, :role => 'admin' - end end diff --git a/app/models/project_to_repository.rb b/app/models/project_to_repository.rb index 94ec8af2f..68148f89c 100644 --- a/app/models/project_to_repository.rb +++ b/app/models/project_to_repository.rb @@ -4,57 +4,7 @@ class ProjectToRepository < ActiveRecord::Base delegate :path, :to => :project - #before_save :create_link - #before_save :add_compability_link - #after_destroy :remove_link - #after_destroy :remove_compability_link - after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]} after_destroy lambda { project.xml_rpc_destroy(repository) } # after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? } - - #def path - # build_path(project.unixname) - #end - - # This is symbolink to /git_projects//.git - def sym_path - "#{ repository.platform.path }/projects/#{ project.unixname }.git" - end - - protected - - #def build_path(dir) - # File.join(repository.path, dir) - #end - - #def create_link - # exists = File.exists?(path) && File.directory?(path) - # raise "Symlink #{path} already exists" if exists - # if new_record? - # FileUtils.ln_s(project.path, path) - # end - #end - # - #def remove_link - # exists = File.exists?(path) && File.directory?(path) - # raise "Directory #{path} didn't exists" unless exists - # FileUtils.rm_rf(path) - #end - - def add_compability_link - exists = File.exists?(sym_path) && File.directory?(sym_path) - return false if exists - if new_record? - #FileUtils.ln_s(path, sym_path) - system("sudo ln -s #{ path } #{ sym_path }") - end - end - - def remove_compability_link - exists = File.exists?(sym_path) && File.directory?(sym_path) - return false unless exists - #FileUtils.rm_rf(sym_path) - system("sudo rm -rf #{ sym_path }") - end end diff --git a/app/models/repository.rb b/app/models/repository.rb index 540d17903..91b3b4a67 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -16,19 +16,10 @@ class Repository < ActiveRecord::Base scope :recent, order("name ASC") - after_create :make_owner_rel - before_save :check_owner_rel - #before_save :create_directory - #after_destroy :remove_directory - before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy - attr_accessible :name, :unixname, :platform_id - -# def path -# build_path(unixname) -# end + attr_accessible :name, :unixname #, :platform_id def full_clone(attrs) # owner clone.tap do |c| # dup @@ -38,28 +29,9 @@ class Repository < ActiveRecord::Base end end - protected + include Modules::Models::Owner -# def build_path(dir) -# File.join(platform.path, dir) -# end -# -# def create_directory -# exists = File.exists?(path) && File.directory?(path) -# raise "Directory #{path} already exists" if exists -# if new_record? -# FileUtils.mkdir_p(path) -# %w(release updates).each { |subrep| FileUtils.mkdir_p(path + subrep) } -# elsif unixname_changed? -# FileUtils.mv(build_path(unixname_was), buildpath(unixname)) -# end -# end -# -# def remove_directory -# exists = File.exists?(path) && File.directory?(path) -# raise "Directory #{path} didn't exists" unless exists -# FileUtils.rm_rf(path) -# end + protected def xml_rpc_create result = BuildServer.create_repo unixname, platform.unixname @@ -78,17 +50,4 @@ class Repository < ActiveRecord::Base raise "Failed to delete repository #{name} inside platform #{platform.name}." end end - - def make_owner_rel - r = relations.build :object_id => owner.id, :object_type => 'User', :role => 'admin' - r.save - end - - def check_owner_rel - if !new_record? and owner_id_changed? - relations.by_object(owner).delete_all if owner_type_was - make_owner_rel if owner - end - end - end diff --git a/app/models/right.rb b/app/models/right.rb deleted file mode 100644 index ac92a0581..000000000 --- a/app/models/right.rb +++ /dev/null @@ -1,21 +0,0 @@ -class Right < ActiveRecord::Base - before_save :generate_name - - scope :for_controller, lambda { |cont| {:conditions => ['controller = ?', cont.controller_name]}} - - class << self - def by_controller - all.inject({}) do |h, i| - h[i.controller] ||= [] - h[i.controller] << i - h - end - end - end - protected - NAME_TEMPL = 'Right to perform %s action.' - - def generate_name - self.name = sprintf(NAME_TEMPL, action) unless name and name.size == 0 - end -end diff --git a/app/models/rpm.rb b/app/models/rpm.rb index 7422039ad..e954c8247 100644 --- a/app/models/rpm.rb +++ b/app/models/rpm.rb @@ -1,8 +1,6 @@ class Rpm < ActiveRecord::Base - validates :name, :presence => true - validates :arch_id, :presence => true - validates :project_id, :presence => true - belongs_to :arch belongs_to :project + + validates :name, :arch_id, :project_id, :presence => true end diff --git a/app/models/user.rb b/app/models/user.rb index cdf35bb78..14aea50b5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,9 +21,9 @@ class User < ActiveRecord::Base has_many :platforms, :through => :targets, :source => :target, :source_type => 'Platform', :autosave => true has_many :repositories, :through => :targets, :source => :target, :source_type => 'Repository', :autosave => true - include PersonalRepository + include Modules::Models::PersonalRepository - validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ }, :allow_nil => false, :allow_blank => false + validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } validate { errors.add(:uname, :taken) if Group.where('uname LIKE ?', uname).present? } validates :ssh_key, :uniqueness => true, :allow_blank => true validates :role, :inclusion => {:in => ROLES}, :allow_blank => true @@ -32,14 +32,12 @@ class User < ActiveRecord::Base attr_readonly :uname attr_accessor :login - # after_create() { UserMailer.new_user_notification(self).deliver } - def admin? role == 'admin' end def guest? - self.id.blank? + self.id.blank? # persisted? end class << self diff --git a/app/views/auto_build_lists/_not_automated.html.haml b/app/views/auto_build_lists/_not_automated.html.haml index b2439c200..da198e54f 100644 --- a/app/views/auto_build_lists/_not_automated.html.haml +++ b/app/views/auto_build_lists/_not_automated.html.haml @@ -8,6 +8,6 @@ - @projects_not_automated.each do |project| %tr{:class => cycle("odd", "even")} %td= link_to project.name, project_path(project) - %td= link_to t("layout.auto_build_lists.automate_btn"), auto_build_lists_path(:project_id => project.id), :method => :post + %td= link_to t("layout.auto_build_lists.automate_btn"), auto_build_lists_path(:project_id => project.id), :method => :post, :confirm => t("layout.confirm") = will_paginate @projects_not_automated, :param_name => 'not_automated_page' \ No newline at end of file diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 364ca6252..9e1e43f6b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -34,7 +34,7 @@ -if can? :index, BuildList %li{:class => controller.controller_path == 'build_lists' ? 'active' : '' } %a{:href => all_build_lists_path}= t("layout.menu.build_lists") - -if can? :index, Category + -if can? :platforms, Category %li{:class => controller.controller_path == 'categories' ? 'active' : '' } %a{:href => catalogs_path}= t("layout.menu.categories") -if can? :read, current_user.personal_repository diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/show.html.haml index 1d9e973c7..b150b967b 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/show.html.haml @@ -57,12 +57,12 @@ .wat-cf -#= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => t("layout.edit")) + " " + t("layout.edit"), edit_platform_path(@platform), :class => "button" - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_path(@platform), :method => "delete", :class => "button", :confirm => t("layout.platforms.confirm_delete") + = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), platform_path(@platform), :method => "delete", :class => "button", :confirm => t("layout.platforms.confirm_delete") if can? :delete, @platform - if @platform.released? - = link_to t("layout.platforms.unfreeze"), unfreeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_unfreeze"), :class => "button" + = link_to t("layout.platforms.unfreeze"), unfreeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_unfreeze"), :class => "button" if can? :unfreeze, @platform - else - = link_to t("layout.platforms.freeze"), freeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_freeze"), :class => "button" - = link_to "Клонировать", clone_platform_path(@platform), :class => "button" + = link_to t("layout.platforms.freeze"), freeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_freeze"), :class => "button" if can? :freeze, @platform + = link_to "Клонировать", clone_platform_path(@platform), :class => "button" if can? :clone, @platform %a{ :name => "repositories" } .block diff --git a/app/views/projects/_sidebar.html.haml b/app/views/projects/_sidebar.html.haml index 2334c82ed..f5ab2217c 100644 --- a/app/views/projects/_sidebar.html.haml +++ b/app/views/projects/_sidebar.html.haml @@ -15,7 +15,7 @@ = '(' + t("layout.owner") + ')' %br -# if can? :update, @project - = link_to t("layout.projects.edit_collaborators"), edit_project_collaborators_path(@project) + = link_to t("layout.projects.edit_collaborators"), edit_project_collaborators_path(@project) if can? :manage_collaborators, @project / %p / %b diff --git a/app/views/repositories/_form.html.haml b/app/views/repositories/_form.html.haml index fa7c4a5d7..e7e0aa710 100644 --- a/app/views/repositories/_form.html.haml +++ b/app/views/repositories/_form.html.haml @@ -5,9 +5,6 @@ = f.label :unixname, t("activerecord.attributes.repository.unixname"), :class => :label = f.text_field :unixname, :class => 'text_field' -.group - = f.hidden_field :platform_id, :value => @platform_id - .group.navform.wat-cf %button.button{:type => "submit"} = image_tag("web-app-theme/icons/tick.png", :alt => t("layout.save")) diff --git a/app/views/repositories/index.html.haml b/app/views/repositories/index.html.haml index 01ed0727c..8a56a4eb9 100644 --- a/app/views/repositories/index.html.haml +++ b/app/views/repositories/index.html.haml @@ -2,7 +2,7 @@ .secondary-navigation %ul.wat-cf %li.first.active= link_to t("layout.repositories.list"), repositories_path - %li= link_to t("layout.repositories.new"), new_repository_path if can? :create, Platform + %li= link_to t("layout.repositories.new"), new_repository_path if can? :create, Platform # TODO repo without platform?? .content %h2.title = t("layout.repositories.list_header") diff --git a/app/views/repositories/show.html.haml b/app/views/repositories/show.html.haml index 86971e882..3616143d2 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/repositories/show.html.haml @@ -27,7 +27,7 @@ \: = link_to @repository.owner.try(:name), url_for(@repository.owner) .wat-cf - = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") + = link_to image_tag("web-app-theme/icons/cross.png", :alt => t("layout.delete")) + " " + t("layout.delete"), @repository_path, :method => "delete", :class => "button", :confirm => t("layout.repositories.confirm_delete") if can? :destroy, @repository %a{ :name => "projects" } .block diff --git a/config/environments/development.rb b/config/environments/development.rb index ea2a0ad58..973ff54d4 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,7 +11,6 @@ Rosa::Application.configure do # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send diff --git a/config/initializers/load_config.rb b/config/initializers/load_config.rb index 7421fa9cc..fb6d0a02a 100644 --- a/config/initializers/load_config.rb +++ b/config/initializers/load_config.rb @@ -1,5 +1,7 @@ APP_CONFIG = YAML.load_file("#{Rails.root}/config/application.yml")[Rails.env] +require 'modules' + # Setup Smart HTTP GRack require 'grack' config = {:project_root => File.join(APP_CONFIG['root_path'], 'git_projects'), :git_path => 'git', :upload_pack => true, :receive_pack => true} diff --git a/db/migrate/20111123160010_drop_acl_tables.rb b/db/migrate/20111123160010_drop_acl_tables.rb new file mode 100644 index 000000000..c05feb666 --- /dev/null +++ b/db/migrate/20111123160010_drop_acl_tables.rb @@ -0,0 +1,42 @@ +class DropAclTables < ActiveRecord::Migration + def self.up + drop_table :permissions + drop_table :rights + drop_table :role_lines + drop_table :roles + + remove_column :users, :global_role_id + remove_column :groups, :global_role_id + end + + def self.down + create_table :permissions do |t| + t.integer "right_id" + t.integer "role_id" + t.timestamps + end + create_table :rights do |t| + t.string "name", :null => false + t.string "controller", :null => false + t.string "action", :null => false + t.timestamps + end + create_table :role_lines do |t| + t.integer "role_id" + t.integer "relation_id" + t.timestamps + end + create_table :roles do |t| + t.string "name" + t.text "can_see" + t.string "on", :default => "" + t.string "to", :default => "" + t.boolean "use_default", :default => false + t.boolean "use_default_for_owner", :default => false + t.timestamps + end + + add_column :users, :global_role_id, :integer + add_column :groups, :global_role_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 602bb07f5..038b221f8 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 => 20111122232244) do +ActiveRecord::Schema.define(:version => 20111123160010) do create_table "arches", :force => true do |t| t.string "name", :null => false @@ -138,14 +138,6 @@ ActiveRecord::Schema.define(:version => 20111122232244) do t.datetime "created_at" t.datetime "updated_at" t.string "uname" - t.integer "global_role_id" - end - - create_table "permissions", :force => true do |t| - t.integer "right_id" - t.integer "role_id" - t.datetime "created_at" - t.datetime "updated_at" end create_table "platforms", :force => true do |t| @@ -229,7 +221,6 @@ ActiveRecord::Schema.define(:version => 20111122232244) do t.string "object_type" t.integer "target_id" t.string "target_type" - t.integer "role_id" t.datetime "created_at" t.datetime "updated_at" t.string "role" @@ -245,32 +236,6 @@ ActiveRecord::Schema.define(:version => 20111122232244) do t.string "owner_type" end - create_table "rights", :force => true do |t| - t.string "name", :null => false - t.string "controller", :null => false - t.string "action", :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "role_lines", :force => true do |t| - t.integer "role_id" - t.integer "relation_id" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "roles", :force => true do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.text "can_see" - t.string "on", :default => "" - t.string "to", :default => "" - t.boolean "use_default", :default => false - t.boolean "use_default_for_owner", :default => false - end - create_table "rpms", :force => true do |t| t.string "name", :null => false t.integer "arch_id", :null => false @@ -284,17 +249,16 @@ ActiveRecord::Schema.define(:version => 20111122232244) do create_table "users", :force => true do |t| t.string "name" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :limit => 128, :default => "", :null => false + t.string "password_salt", :default => "", :null => false t.string "reset_password_token" - t.datetime "reset_password_sent_at" + t.string "remember_token" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" - t.string "uname" t.text "ssh_key" - t.integer "role_id" - t.integer "global_role_id" + t.string "uname" t.string "role" end diff --git a/lib/modules.rb b/lib/modules.rb new file mode 100644 index 000000000..38176fcf9 --- /dev/null +++ b/lib/modules.rb @@ -0,0 +1,11 @@ +module Modules + module Controllers + extend ActiveSupport::Autoload + end + + module Models + extend ActiveSupport::Autoload + + autoload :Owner + end +end diff --git a/lib/modules/models/owner.rb b/lib/modules/models/owner.rb new file mode 100644 index 000000000..392655400 --- /dev/null +++ b/lib/modules/models/owner.rb @@ -0,0 +1,17 @@ +module Modules + module Models + module Owner + extend ActiveSupport::Concern + + included do + after_create lambda { relations.create :object_id => owner.id, :object_type => owner.class.to_s, :role => 'admin' } + end + + module InstanceMethods + end + + module ClassMethods + end + end + end +end diff --git a/lib/modules/models/personal_repository.rb b/lib/modules/models/personal_repository.rb new file mode 100644 index 000000000..aa20e21e7 --- /dev/null +++ b/lib/modules/models/personal_repository.rb @@ -0,0 +1,41 @@ +module Modules + module Models + module PersonalRepository + extend ActiveSupport::Concern + + included do + after_create :create_personal_repository + end + + module InstanceMethods + def create_personal_repository + pl = platforms.build + pl.owner = self + pl.name = "#{self.uname}_personal" + pl.unixname = "#{self.uname}_personal" + pl.platform_type = 'personal' + pl.distrib_type = APP_CONFIG['distr_types'].first + pl.visibility = 'hidden' + pl.save! + + rep = pl.repositories.build + rep.owner = pl.owner + rep.name = 'main' + rep.unixname = 'main' + rep.save! + end + + def personal_platform + platforms.personal.first + end + + def personal_repository + personal_platform.repositories.first + end + end + + module ClassMethods + end + end + end +end diff --git a/spec/helpers/auto_build_lists_helper_spec.rb b/spec/helpers/auto_build_lists_helper_spec.rb deleted file mode 100644 index 0d34cd5d7..000000000 --- a/spec/helpers/auto_build_lists_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the AutoBuildListsHelper. For example: -# -# describe AutoBuildListsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe AutoBuildListsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/collaborators_helper_spec.rb b/spec/helpers/collaborators_helper_spec.rb deleted file mode 100644 index 2578b3a49..000000000 --- a/spec/helpers/collaborators_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the CollaboratorsHelper. For example: -# -# describe CollaboratorsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe CollaboratorsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/containers_helper_spec.rb b/spec/helpers/containers_helper_spec.rb deleted file mode 100644 index 15bff5d33..000000000 --- a/spec/helpers/containers_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ContainersHelper. For example: -# -# describe ContainersHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ContainersHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/download_helper_spec.rb b/spec/helpers/download_helper_spec.rb deleted file mode 100644 index e375fe17c..000000000 --- a/spec/helpers/download_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the DownloadHelper. For example: -# -# describe DownloadHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe DownloadHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/git_helper_spec.rb b/spec/helpers/git_helper_spec.rb deleted file mode 100644 index 8e9bd35ee..000000000 --- a/spec/helpers/git_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the GitHelper. For example: -# -# describe GitHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -#describe GitHelper do -# pending "add some examples to (or delete) #{__FILE__}" -#end diff --git a/spec/helpers/personal_repositories_helper_spec.rb b/spec/helpers/personal_repositories_helper_spec.rb deleted file mode 100644 index 1aed8ddb2..000000000 --- a/spec/helpers/personal_repositories_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the PersonalRepositoriesHelper. For example: -# -# describe PersonalRepositoriesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe PersonalRepositoriesHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/platforms_helper_spec.rb b/spec/helpers/platforms_helper_spec.rb deleted file mode 100644 index c569f8d17..000000000 --- a/spec/helpers/platforms_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the PlatformsHelper. For example: -# -# describe PlatformsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe PlatformsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/private_users_helper_spec.rb b/spec/helpers/private_users_helper_spec.rb deleted file mode 100644 index 2ac72aba5..000000000 --- a/spec/helpers/private_users_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the PrivateUsersHelper. For example: -# -# describe PrivateUsersHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe PrivateUsersHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/privates_helper_spec.rb b/spec/helpers/privates_helper_spec.rb deleted file mode 100644 index 3a17aad73..000000000 --- a/spec/helpers/privates_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the PrivatesHelper. For example: -# -# describe PrivatesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe PrivatesHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/product_build_lists_helper_spec.rb b/spec/helpers/product_build_lists_helper_spec.rb deleted file mode 100644 index 90435e83d..000000000 --- a/spec/helpers/product_build_lists_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ProductBuildListsHelper. For example: -# -# describe ProductBuildListsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ProductBuildListsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/products_helper_spec.rb b/spec/helpers/products_helper_spec.rb deleted file mode 100644 index e5212c5f2..000000000 --- a/spec/helpers/products_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ProductsHelper. For example: -# -# describe ProductsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ProductsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb deleted file mode 100644 index 4dfdd6da1..000000000 --- a/spec/helpers/projects_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the ProjectsHelper. For example: -# -# describe ProjectsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe ProjectsHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb deleted file mode 100644 index e65fff91c..000000000 --- a/spec/helpers/users_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the UsersHelper. For example: -# -# describe UsersHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe UsersHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/permission_spec.rb b/spec/models/permission_spec.rb deleted file mode 100644 index 60a42775b..000000000 --- a/spec/models/permission_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Permission do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/right_spec.rb b/spec/models/right_spec.rb deleted file mode 100644 index d866fdc4f..000000000 --- a/spec/models/right_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Right do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/routing/permissions_routing_spec.rb b/spec/routing/permissions_routing_spec.rb deleted file mode 100644 index 287f50156..000000000 --- a/spec/routing/permissions_routing_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "spec_helper" - -describe PermissionsController do - describe "routing" do - - it "routes to #index" do - get("/permissions").should route_to("permissions#index") - end - - it "routes to #new" do - get("/permissions/new").should route_to("permissions#new") - end - - it "routes to #show" do - get("/permissions/1").should route_to("permissions#show", :id => "1") - end - - it "routes to #edit" do - get("/permissions/1/edit").should route_to("permissions#edit", :id => "1") - end - - it "routes to #create" do - post("/permissions").should route_to("permissions#create") - end - - it "routes to #update" do - put("/permissions/1").should route_to("permissions#update", :id => "1") - end - - it "routes to #destroy" do - delete("/permissions/1").should route_to("permissions#destroy", :id => "1") - end - - end -end diff --git a/spec/routing/rights_routing_spec.rb b/spec/routing/rights_routing_spec.rb deleted file mode 100644 index 5ae75a976..000000000 --- a/spec/routing/rights_routing_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "spec_helper" - -describe RightsController do - describe "routing" do - - it "routes to #index" do - get("/rights").should route_to("rights#index") - end - - it "routes to #new" do - get("/rights/new").should route_to("rights#new") - end - - it "routes to #show" do - get("/rights/1").should route_to("rights#show", :id => "1") - end - - it "routes to #edit" do - get("/rights/1/edit").should route_to("rights#edit", :id => "1") - end - - it "routes to #create" do - post("/rights").should route_to("rights#create") - end - - it "routes to #update" do - put("/rights/1").should route_to("rights#update", :id => "1") - end - - it "routes to #destroy" do - delete("/rights/1").should route_to("rights#destroy", :id => "1") - end - - end -end diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb deleted file mode 100644 index 4084a6e7e..000000000 --- a/spec/routing/roles_routing_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require "spec_helper" - -describe RolesController do - describe "routing" do - - it "routes to #index" do - get("/roles").should route_to("roles#index") - end - - it "routes to #new" do - get("/roles/new").should route_to("roles#new") - end - - it "routes to #show" do - get("/roles/1").should route_to("roles#show", :id => "1") - end - - it "routes to #edit" do - get("/roles/1/edit").should route_to("roles#edit", :id => "1") - end - - it "routes to #create" do - post("/roles").should route_to("roles#create") - end - - it "routes to #update" do - put("/roles/1").should route_to("roles#update", :id => "1") - end - - it "routes to #destroy" do - delete("/roles/1").should route_to("roles#destroy", :id => "1") - end - - end -end diff --git a/spec/views/permissions/edit.html.haml_spec.rb b/spec/views/permissions/edit.html.haml_spec.rb deleted file mode 100644 index 05715ddbd..000000000 --- a/spec/views/permissions/edit.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe "permissions/edit.html.haml" do - before(:each) do - @permission = assign(:permission, stub_model(Permission, - :role_id => 1, - :right_id => 1, - :access_obj_id => 1 - )) - end - - it "renders the edit permission form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => permissions_path(@permission), :method => "post" do - assert_select "input#permission_role_id", :name => "permission[role_id]" - assert_select "input#permission_right_id", :name => "permission[right_id]" - assert_select "input#permission_access_obj_id", :name => "permission[access_obj_id]" - end - end -end diff --git a/spec/views/permissions/index.html.haml_spec.rb b/spec/views/permissions/index.html.haml_spec.rb deleted file mode 100644 index 67d29ede2..000000000 --- a/spec/views/permissions/index.html.haml_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe "permissions/index.html.haml" do - before(:each) do - assign(:permissions, [ - stub_model(Permission, - :role_id => 1, - :right_id => 1, - :access_obj_id => 1 - ), - stub_model(Permission, - :role_id => 1, - :right_id => 1, - :access_obj_id => 1 - ) - ]) - end - - it "renders a list of permissions" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => 1.to_s, :count => 2 - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => 1.to_s, :count => 2 - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => 1.to_s, :count => 2 - end -end diff --git a/spec/views/permissions/new.html.haml_spec.rb b/spec/views/permissions/new.html.haml_spec.rb deleted file mode 100644 index 151976539..000000000 --- a/spec/views/permissions/new.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe "permissions/new.html.haml" do - before(:each) do - assign(:permission, stub_model(Permission, - :role_id => 1, - :right_id => 1, - :access_obj_id => 1 - ).as_new_record) - end - - it "renders new permission form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => permissions_path, :method => "post" do - assert_select "input#permission_role_id", :name => "permission[role_id]" - assert_select "input#permission_right_id", :name => "permission[right_id]" - assert_select "input#permission_access_obj_id", :name => "permission[access_obj_id]" - end - end -end diff --git a/spec/views/permissions/show.html.haml_spec.rb b/spec/views/permissions/show.html.haml_spec.rb deleted file mode 100644 index 0460962bf..000000000 --- a/spec/views/permissions/show.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe "permissions/show.html.haml" do - before(:each) do - @permission = assign(:permission, stub_model(Permission, - :role_id => 1, - :right_id => 1, - :access_obj_id => 1 - )) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/1/) - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/1/) - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/1/) - end -end diff --git a/spec/views/product_build_lists/edit.html.haml_spec.rb b/spec/views/product_build_lists/edit.html.haml_spec.rb deleted file mode 100644 index d0a5b4b9b..000000000 --- a/spec/views/product_build_lists/edit.html.haml_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe "product_build_lists/edit.html.haml" do - before(:each) do - @product_build_list = assign(:product_build_list, stub_model(ProductBuildList, - :product => nil, - :status => "MyString" - )) - end - - it "renders the edit product_build_list form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => product_build_lists_path(@product_build_list), :method => "post" do - assert_select "input#product_build_list_product", :name => "product_build_list[product]" - assert_select "input#product_build_list_status", :name => "product_build_list[status]" - end - end -end diff --git a/spec/views/product_build_lists/index.html.haml_spec.rb b/spec/views/product_build_lists/index.html.haml_spec.rb deleted file mode 100644 index 0991cc223..000000000 --- a/spec/views/product_build_lists/index.html.haml_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe "product_build_lists/index.html.haml" do - before(:each) do - assign(:product_build_lists, [ - stub_model(ProductBuildList, - :product => nil, - :status => "Status" - ), - stub_model(ProductBuildList, - :product => nil, - :status => "Status" - ) - ]) - end - - it "renders a list of product_build_lists" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => nil.to_s, :count => 2 - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Status".to_s, :count => 2 - end -end diff --git a/spec/views/product_build_lists/new.html.haml_spec.rb b/spec/views/product_build_lists/new.html.haml_spec.rb deleted file mode 100644 index 493008f90..000000000 --- a/spec/views/product_build_lists/new.html.haml_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe "product_build_lists/new.html.haml" do - before(:each) do - assign(:product_build_list, stub_model(ProductBuildList, - :product => nil, - :status => "MyString" - ).as_new_record) - end - - it "renders new product_build_list form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => product_build_lists_path, :method => "post" do - assert_select "input#product_build_list_product", :name => "product_build_list[product]" - assert_select "input#product_build_list_status", :name => "product_build_list[status]" - end - end -end diff --git a/spec/views/product_build_lists/show.html.haml_spec.rb b/spec/views/product_build_lists/show.html.haml_spec.rb deleted file mode 100644 index 6eb0dd320..000000000 --- a/spec/views/product_build_lists/show.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe "product_build_lists/show.html.haml" do - before(:each) do - @product_build_list = assign(:product_build_list, stub_model(ProductBuildList, - :product => nil, - :status => "Status" - )) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(//) - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Status/) - end -end diff --git a/spec/views/rights/edit.html.haml_spec.rb b/spec/views/rights/edit.html.haml_spec.rb deleted file mode 100644 index a1a9c538b..000000000 --- a/spec/views/rights/edit.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe "rights/edit.html.haml" do - before(:each) do - @right = assign(:right, stub_model(Right, - :controller_name => "MyString", - :method_name => "MyString", - :name => "MyString" - )) - end - - it "renders the edit right form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => rights_path(@right), :method => "post" do - assert_select "input#right_controller_name", :name => "right[controller_name]" - assert_select "input#right_method_name", :name => "right[method_name]" - assert_select "input#right_name", :name => "right[name]" - end - end -end diff --git a/spec/views/rights/index.html.haml_spec.rb b/spec/views/rights/index.html.haml_spec.rb deleted file mode 100644 index 2a7129898..000000000 --- a/spec/views/rights/index.html.haml_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'spec_helper' - -describe "rights/index.html.haml" do - before(:each) do - assign(:rights, [ - stub_model(Right, - :controller_name => "Controller Name", - :method_name => "Method Name", - :name => "Name" - ), - stub_model(Right, - :controller_name => "Controller Name", - :method_name => "Method Name", - :name => "Name" - ) - ]) - end - - it "renders a list of rights" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Controller Name".to_s, :count => 2 - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Method Name".to_s, :count => 2 - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Name".to_s, :count => 2 - end -end diff --git a/spec/views/rights/new.html.haml_spec.rb b/spec/views/rights/new.html.haml_spec.rb deleted file mode 100644 index 063a74cd5..000000000 --- a/spec/views/rights/new.html.haml_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'spec_helper' - -describe "rights/new.html.haml" do - before(:each) do - assign(:right, stub_model(Right, - :controller_name => "MyString", - :method_name => "MyString", - :name => "MyString" - ).as_new_record) - end - - it "renders new right form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => rights_path, :method => "post" do - assert_select "input#right_controller_name", :name => "right[controller_name]" - assert_select "input#right_method_name", :name => "right[method_name]" - assert_select "input#right_name", :name => "right[name]" - end - end -end diff --git a/spec/views/rights/show.html.haml_spec.rb b/spec/views/rights/show.html.haml_spec.rb deleted file mode 100644 index 81a8a36fa..000000000 --- a/spec/views/rights/show.html.haml_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe "rights/show.html.haml" do - before(:each) do - @right = assign(:right, stub_model(Right, - :controller_name => "Controller Name", - :method_name => "Method Name", - :name => "Name" - )) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Controller Name/) - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Method Name/) - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - end -end diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb deleted file mode 100644 index 9560395a1..000000000 --- a/spec/views/roles/edit.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe "roles/edit.html.haml" do - before(:each) do - @role = assign(:role, stub_model(Role, - :name => "MyString" - )) - end - - it "renders the edit role form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => roles_path(@role), :method => "post" do - assert_select "input#role_name", :name => "role[name]" - end - end -end diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb deleted file mode 100644 index d0ba6c026..000000000 --- a/spec/views/roles/index.html.haml_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe "roles/index.html.haml" do - before(:each) do - assign(:roles, [ - stub_model(Role, - :name => "Name" - ), - stub_model(Role, - :name => "Name" - ) - ]) - end - - it "renders a list of roles" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "tr>td", :text => "Name".to_s, :count => 2 - end -end diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb deleted file mode 100644 index dba3ada41..000000000 --- a/spec/views/roles/new.html.haml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe "roles/new.html.haml" do - before(:each) do - assign(:role, stub_model(Role, - :name => "MyString" - ).as_new_record) - end - - it "renders new role form" do - render - - # Run the generator again with the --webrat flag if you want to use webrat matchers - assert_select "form", :action => roles_path, :method => "post" do - assert_select "input#role_name", :name => "role[name]" - end - end -end diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb deleted file mode 100644 index f49a5a36d..000000000 --- a/spec/views/roles/show.html.haml_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "roles/show.html.haml" do - before(:each) do - @role = assign(:role, stub_model(Role, - :name => "Name" - )) - end - - it "renders attributes in

" do - render - # Run the generator again with the --webrat flag if you want to use webrat matchers - rendered.should match(/Name/) - end -end diff --git a/test/integration/permission_test.rb b/test/integration/permission_test.rb deleted file mode 100644 index 41f04d956..000000000 --- a/test/integration/permission_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class PermissionTest < ActionDispatch::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/integration/product_build_list_test.rb b/test/integration/product_build_list_test.rb deleted file mode 100644 index 4b00d8ed0..000000000 --- a/test/integration/product_build_list_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class ProductBuildListTest < ActionDispatch::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/integration/right_test.rb b/test/integration/right_test.rb deleted file mode 100644 index 1f13dc615..000000000 --- a/test/integration/right_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class RightTest < ActionDispatch::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end diff --git a/test/integration/role_test.rb b/test/integration/role_test.rb deleted file mode 100644 index 8bc8544bd..000000000 --- a/test/integration/role_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class RoleTest < ActionDispatch::IntegrationTest - fixtures :all - - # Replace this with your real tests. - test "the truth" do - assert true - end -end