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

This commit is contained in:
Pavel Chipiga 2011-11-24 23:46:19 +02:00
parent 0573acb650
commit 796ff75857
92 changed files with 201 additions and 1164 deletions

View File

@ -1,10 +1,8 @@
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')
@ -15,29 +13,16 @@ class AutoBuildListsController < ApplicationController
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

View File

@ -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)

View File

@ -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])

View File

@ -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]

View File

@ -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

View File

@ -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]

View File

@ -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])

View File

@ -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])

View File

@ -3,11 +3,9 @@ class PersonalRepositoriesController < ApplicationController
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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -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])

View File

@ -1,2 +0,0 @@
module AutoBuildListsHelper
end

View File

@ -1,2 +0,0 @@
module CollaboratorsHelper
end

View File

@ -1,2 +0,0 @@
module ContainersHelper
end

View File

@ -1,2 +0,0 @@
module DownloadHelper
end

View File

@ -1,2 +0,0 @@
module PersonalRepositoriesHelper
end

View File

@ -1,2 +0,0 @@
module PrivateUsersHelper
end

View File

@ -1,2 +0,0 @@
module PrivatesHelper
end

View File

@ -1,2 +0,0 @@
module ProductBuildListsHelper
end

View File

@ -1,2 +0,0 @@
module ProductsHelper
end

View File

@ -1,2 +0,0 @@
module UsersHelper
end

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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/<owner.uname>/<unixname>.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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"))

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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}

View File

@ -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

View File

@ -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
@ -286,15 +251,14 @@ ActiveRecord::Schema.define(:version => 20111122232244) do
t.string "name"
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

11
lib/modules.rb Normal file
View File

@ -0,0 +1,11 @@
module Modules
module Controllers
extend ActiveSupport::Autoload
end
module Models
extend ActiveSupport::Autoload
autoload :Owner
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe Permission do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,5 +0,0 @@
require 'spec_helper'
describe Right do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <p>" 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <p>" 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <p>" 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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Name/)
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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