Fully qualify ::Type class constant

This fixes a naming collision with AR internals:

    undefined method `find' for ActiveRecord::AttributeMethods::Serialization::Type:Class

Signed-off-by: Alex Coles <alex@alexbcoles.com>
This commit is contained in:
Alex Coles
2014-08-31 20:50:38 +02:00
parent 7ff6f4fe94
commit 0b941955ce
40 changed files with 88 additions and 88 deletions
@@ -48,7 +48,7 @@ module Api
end
def show
@type = (@project.nil?) ? Type.find(params[:id])
@type = (@project.nil?) ? ::Type.find(params[:id])
: @project.types.find(params[:id])
respond_to do |format|
+1 -1
View File
@@ -109,6 +109,6 @@ class CustomFieldsController < ApplicationController
end
def find_types
@types = Type.find(:all, :order => 'position')
@types = ::Type.find(:all, :order => 'position')
end
end
+1 -1
View File
@@ -276,7 +276,7 @@ private
end
def types_used_by_work_packages
@types_used_by_work_packages ||= Type.find_all_by_id(WorkPackage.where(project_id: @project.id)
@types_used_by_work_packages ||= ::Type.find_all_by_id(WorkPackage.where(project_id: @project.id)
.select(:type_id)
.uniq)
end
+10 -10
View File
@@ -36,7 +36,7 @@ class TypesController < ApplicationController
before_filter :require_admin, :except => [:index, :show]
def index
@types = Type.page(params[:page]).per_page(per_page_param)
@types = ::Type.page(params[:page]).per_page(per_page_param)
render :action => "index", :layout => false if request.xhr?
end
@@ -46,22 +46,22 @@ class TypesController < ApplicationController
end
def new
@type = Type.new(params[:type])
@types = Type.find(:all, :order => 'position')
@type = ::Type.new(params[:type])
@types = ::Type.find(:all, :order => 'position')
@projects = Project.find(:all)
end
def create
@type = Type.new(permitted_params.type)
@type = ::Type.new(permitted_params.type)
if @type.save
# workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Type.find_by_id(params[:copy_workflow_from]))
if !params[:copy_workflow_from].blank? && (copy_from = ::Type.find_by_id(params[:copy_workflow_from]))
@type.workflows.copy(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'index'
else
@types = Type.find(:all, :order => 'position')
@types = ::Type.find(:all, :order => 'position')
@projects = Project.find(:all)
render :action => 'new'
end
@@ -69,11 +69,11 @@ class TypesController < ApplicationController
def edit
@projects = Project.all
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
end
def update
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
# forbid renaming if it is a standard type
params[:type].delete :name if @type.is_standard?
@@ -87,7 +87,7 @@ class TypesController < ApplicationController
end
def move
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
if @type.update_attributes(permitted_params.type_move)
flash[:notice] = l(:notice_successful_update)
@@ -99,7 +99,7 @@ class TypesController < ApplicationController
end
def destroy
@type = Type.find(params[:id])
@type = ::Type.find(params[:id])
# types cannot be deleted when they have work packages
# or they are standard types
# put that into the model and do a `if @type.destroy`
+2 -2
View File
@@ -54,7 +54,7 @@ class VersionsController < ApplicationController
issues = version.fixed_issues.visible.find(:all,
:include => [:project, :status, :type, :priority],
:conditions => {:type_id => @selected_type_ids, :project_id => project_ids},
:order => "#{Project.table_name}.lft, #{Type.table_name}.position, #{WorkPackage.table_name}.id")
:order => "#{Project.table_name}.lft, #{::Type.table_name}.position, #{WorkPackage.table_name}.id")
@issues_by_version[version] = issues
end
end
@@ -64,7 +64,7 @@ class VersionsController < ApplicationController
def show
@issues = @version.fixed_issues.visible.find(:all,
:include => [:status, :type, :priority],
:order => "#{Type.table_name}.position, #{WorkPackage.table_name}.id")
:order => "#{::Type.table_name}.position, #{WorkPackage.table_name}.id")
end
def new
+4 -4
View File
@@ -40,7 +40,7 @@ class WorkflowsController < ApplicationController
def edit
@role = Role.find_by_id(params[:role_id])
@type = Type.find_by_id(params[:type_id])
@type = ::Type.find_by_id(params[:type_id])
if request.post?
Workflow.destroy_all( ["role_id=? and type_id=?", @role.id, @type.id])
@@ -78,7 +78,7 @@ class WorkflowsController < ApplicationController
if params[:source_type_id].blank? || params[:source_type_id] == 'any'
@source_type = nil
else
@source_type = Type.find_by_id(params[:source_type_id].to_i)
@source_type = ::Type.find_by_id(params[:source_type_id].to_i)
end
if params[:source_role_id].blank? || params[:source_role_id] == 'any'
@source_role = nil
@@ -86,7 +86,7 @@ class WorkflowsController < ApplicationController
@source_role = Role.find_by_id(params[:source_role_id].to_i)
end
@target_types = params[:target_type_ids].blank? ? nil : Type.find_all_by_id(params[:target_type_ids])
@target_types = params[:target_type_ids].blank? ? nil : ::Type.find_all_by_id(params[:target_type_ids])
@target_roles = params[:target_role_ids].blank? ? nil : Role.find_all_by_id(params[:target_role_ids])
if request.post?
@@ -109,6 +109,6 @@ class WorkflowsController < ApplicationController
end
def find_types
@types = Type.find(:all, :order => 'position')
@types = ::Type.find(:all, :order => 'position')
end
end
+1 -1
View File
@@ -455,7 +455,7 @@ class DueIssuesReminder
def initialize(days = nil, project_id = nil, type_id = nil, user_ids = [])
@days = days ? days.to_i : 7
@project = Project.find_by_id(project_id)
@type = Type.find_by_id(type_id)
@type = ::Type.find_by_id(type_id)
@user_ids = user_ids
end
+5 -5
View File
@@ -65,7 +65,7 @@ class Project < ActiveRecord::Base
has_many :principals, :through => :member_principals, :source => :principal
has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :types, :order => "#{Type.table_name}.position"
has_and_belongs_to_many :types, :order => "#{::Type.table_name}.position"
has_many :work_packages, :order => "#{WorkPackage.table_name}.created_at DESC", :include => [:status, :type]
has_many :work_package_changes, :through => :work_packages, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
@@ -239,7 +239,7 @@ class Project < ActiveRecord::Base
self.enabled_module_names = Setting.default_projects_modules
end
if !initialized.key?('types') && !initialized.key?('type_ids')
self.types = Type.default
self.types = ::Type.default
end
end
@@ -533,10 +533,10 @@ class Project < ActiveRecord::Base
# Returns an array of the types used by the project and its active sub projects
def rolled_up_types
@rolled_up_types ||=
Type.find(:all, :joins => :projects,
:select => "DISTINCT #{Type.table_name}.*",
::Type.find(:all, :joins => :projects,
:select => "DISTINCT #{::Type.table_name}.*",
:conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt],
:order => "#{Type.table_name}.position")
:order => "#{::Type.table_name}.position")
end
# Closes open and locked project versions that are completed
@@ -94,7 +94,7 @@ module Queries::WorkPackages::AvailableFilterOptions
# options for available filters
def setup_available_work_package_filters
types = project.nil? ? Type.find(:all, order: 'position') : project.rolled_up_types
types = project.nil? ? ::Type.find(:all, order: 'position') : project.rolled_up_types
@available_work_package_filters = {
status_id: { type: :list_status, order: 1, values: Status.all.collect{|s| [s.name, s.id.to_s] } },
+1 -1
View File
@@ -54,7 +54,7 @@ class Query < ActiveRecord::Base
@@available_columns = [
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
QueryColumn.new(:type, :sortable => "#{Type.table_name}.position", :groupable => true),
QueryColumn.new(:type, :sortable => "#{::Type.table_name}.position", :groupable => true),
QueryColumn.new(:parent, :sortable => ["#{WorkPackage.table_name}.root_id", "#{WorkPackage.table_name}.lft ASC"], :default_order => 'desc'),
QueryColumn.new(:status, :sortable => "#{Status.table_name}.position", :groupable => true),
QueryColumn.new(:priority, :sortable => "#{IssuePriority.table_name}.position", :default_order => 'desc', :groupable => true),
+3 -3
View File
@@ -221,7 +221,7 @@ class Timeline < ActiveRecord::Base
# that are reporting into the project that this timeline is
# referencing.
Type.find(:all, :order => :name)
::Type.find(:all, :order => :name)
end
def available_planning_element_status
@@ -237,13 +237,13 @@ class Timeline < ActiveRecord::Base
def selected_planning_element_types
resolve_with_none_element(:planning_element_types) do |ary|
Type.find_all_by_id(ary)
::Type.find_all_by_id(ary)
end
end
def selected_planning_element_time_types
resolve_with_none_element(:planning_element_time_types) do |ary|
Type.find_all_by_id(ary)
::Type.find_all_by_id(ary)
end
end
+2 -2
View File
@@ -86,11 +86,11 @@ class Type < ActiveRecord::Base
end
def self.standard_type
Type.where(is_standard: true).first
::Type.where(is_standard: true).first
end
def self.default
Type.where(is_default: true)
::Type.where(is_default: true)
end
def statuses
+2 -2
View File
@@ -159,7 +159,7 @@ class WorkPackage < ActiveRecord::Base
self.method(:cleanup_time_entries_before_destruction_of)
# Mapping attributes, that are passed in as id's onto their respective associations
# (eg. type=4711 onto type=Type.find(4711))
# (eg. type=4711 onto type=::Type.find(4711))
include AssociationsMapper
# recovered this from planning-element: is it still needed?!
map_associations_for :parent,
@@ -900,7 +900,7 @@ class WorkPackage < ActiveRecord::Base
def self.by_type(project)
count_and_group_by :project => project,
:field => 'type_id',
:joins => Type.table_name
:joins => ::Type.table_name
end
def self.by_version(project)
+1 -1
View File
@@ -40,7 +40,7 @@ class Workflow < ActiveRecord::Base
def self.count_by_type_and_role
counts = connection.select_all("SELECT role_id, type_id, count(id) AS c FROM #{Workflow.table_name} GROUP BY role_id, type_id")
roles = Role.find(:all, :order => 'builtin, position')
types = Type.find(:all, :order => 'position')
types = ::Type.find(:all, :order => 'position')
result = []
types.each do |type|
+1 -1
View File
@@ -129,7 +129,7 @@ SQL
def self.resolve_types(work_packages)
type_ids = work_packages.map(&:type_id).uniq.compact
types = Hash[Type.find(type_ids).map{|type| [type.id,type]}]
types = Hash[::Type.find(type_ids).map{|type| [type.id,type]}]
end
def self.resolve_statuses(work_packages)
+1 -1
View File
@@ -37,7 +37,7 @@ See doc/COPYRIGHT.rdoc for more details.
entries = TimeEntry.find(:all,
:conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today],
:include => [:activity, :project, {:work_package => [:type, :status]}],
:order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Type.table_name}.position ASC, #{WorkPackage.table_name}.id ASC")
:order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{::Type.table_name}.position ASC, #{WorkPackage.table_name}.id ASC")
entries_by_day = entries.group_by(&:spent_on)
%>
+1 -1
View File
@@ -38,7 +38,7 @@ Project
PlanningElementTypeColor.colors.map(&:save)
default_color = PlanningElementTypeColor.find_by_name('Grey-light')
Type.find_or_create_by_is_standard(true, name: 'none',
::Type.find_or_create_by_is_standard(true, name: 'none',
position: 0,
color_id: default_color.id,
is_default: true,
+1 -1
View File
@@ -30,7 +30,7 @@
# add seeds specific for the production-environment here
standard_type = Type.find_by_is_standard(true)
standard_type = ::Type.find_by_is_standard(true)
# Adds the standard type to all existing projects
#
+1 -1
View File
@@ -51,7 +51,7 @@ Then(/^the json\-response should( not)? contain a work_package "(.*?)"$/) do |ne
end
And(/^the json\-response for work_package "(.*?)" should have the type "(.*?)"$/) do |work_package_name, type_name|
type = Type.where(name: type_name).first
type = ::Type.where(name: type_name).first
work_package = lookup_work_package(work_package_name)
expect(work_package["type_id"]).to eql type.id
end
+1 -1
View File
@@ -42,7 +42,7 @@ Given /^the [pP]roject(?: "([^\"]+?)")? uses the following types:$/ do |project,
types = table.raw.map do |line|
name = line.first
type = Type.find_by_name(name)
type = ::Type.find_by_name(name)
type = FactoryGirl.create(:type, :name => name) if type.blank?
type
@@ -108,7 +108,7 @@ end
Given /^the custom field "(.*?)" is activated for type "(.*?)"$/ do |field_name, type_name|
custom_field = WorkPackageCustomField.find_by_name(field_name)
type = Type.find_by_name(type_name)
type = ::Type.find_by_name(type_name)
custom_field.types << type
end
+3 -3
View File
@@ -198,7 +198,7 @@ end
Given /^there are the following types:$/ do |table|
table = table.map_headers { |header| header.underscore.gsub(' ', '_') }
table.hashes.each_with_index do |t, i|
type = Type.find_by_name(t['name'])
type = ::Type.find_by_name(t['name'])
type = Type.new :name => t['name'] if type.nil?
type.position = t['position'] ? t['position'] : i
type.is_in_roadmap = t['is_in_roadmap'] ? t['is_in_roadmap'] : true
@@ -225,7 +225,7 @@ end
Given /^the type "(.+?)" has the default workflow for the role "(.+?)"$/ do |type_name, role_name|
role = Role.find_by_name(role_name)
type = Type.find_by_name(type_name)
type = ::Type.find_by_name(type_name)
type.workflows = []
Status.all(:order => "id ASC").collect(&:id).combination(2).each do |c|
@@ -353,7 +353,7 @@ end
Given /^the [pP]roject(?: "([^\"]*)")? has the following types:$/ do |project_name, table|
p = get_project(project_name)
table.hashes.each_with_index do |t, i|
type = Type.find_by_name(t['name'])
type = ::Type.find_by_name(t['name'])
type = Type.new :name => t['name'] if type.nil?
type.position = t['position'] ? t['position'] : i
type.is_in_roadmap = t['is_in_roadmap'] ? t['is_in_roadmap'] : true
+2 -2
View File
@@ -64,7 +64,7 @@ Given /^the [Uu]ser "([^\"]*)" has (\d+) [iI]ssue(?:s)? with(?: the following)?:
assigned_to: u,
status: Status.default || FactoryGirl.create(:status))
i.type = Type.find_by_name(table.rows_hash.delete("type")) if table.rows_hash["type"]
i.type = ::Type.find_by_name(table.rows_hash.delete("type")) if table.rows_hash["type"]
send_table_to_object(i, table, {}, method(:add_custom_value_to_issue))
i.save!
@@ -110,7 +110,7 @@ Given (/^there are the following issues with attributes:$/) do |table|
watchers = attributes.delete("watched_by")
type = Type.find_by_name(attributes.delete('type'))
type = ::Type.find_by_name(attributes.delete('type'))
attributes.merge! :type_id => type.id if type
version = Version.find_by_name(attributes.delete("version"))
@@ -103,7 +103,7 @@ Given /^the following types are enabled for projects of type "(.*?)"$/ do |proje
project_type = ProjectType.find_by_name(project_type_name)
projects = Project.where(:project_type_id => project_type.id)
types = type_name_table.raw.flatten.map do |type_name|
Type.find_by_name(type_name) || FactoryGirl.create(:type, :name => type_name)
::Type.find_by_name(type_name) || FactoryGirl.create(:type, :name => type_name)
end
projects.each do |project|
@@ -140,7 +140,7 @@ def create_work_packages_from_table table, project
# lookup the type by its name and replace it with the type
# if the cast is ommitted, the contents of type_attributes is interpreted as an int
unless type_attributes.has_key? :type
type_attributes[:type] = Type.where(name: type_attributes[:type].to_s).first
type_attributes[:type] = ::Type.where(name: type_attributes[:type].to_s).first
end
if type_attributes.has_key? "author"
@@ -144,7 +144,7 @@ When (/^I show only work packages which have the type "(.*?)"$/) do |type|
When I edit the settings of the current timeline
}
type = Type.find_by_name(type)
type = ::Type.find_by_name(type)
page.execute_script(<<-JavaScript)
jQuery('#timeline_options_planning_element_types').val('#{type.id}')
jQuery('#content form').submit()
@@ -170,7 +170,7 @@ When (/^I show only projects which have a planning element which lies between "(
page.should have_selector("#timeline_options_planning_element_time_types", :visible => false)
type = Type.find_by_name(type)
type = ::Type.find_by_name(type)
page.execute_script("jQuery('#timeline_options_planning_element_time_types').val('#{type.id}')")
page.execute_script("jQuery('#timeline_options_planning_element_time_absolute').prop('checked', true)")
page.execute_script("jQuery('#timeline_options_planning_element_time_absolute_one').val('#{start_date}')")
+2 -2
View File
@@ -29,13 +29,13 @@
# change from symbol to constant once namespace is removed
InstanceFinder.register(Type, Proc.new { |name| Type.find_by_name(name) })
InstanceFinder.register(Type, Proc.new { |name| ::Type.find_by_name(name) })
RouteMap.register(Type, "/types")
Given /^the following types are enabled for the project called "(.*?)":$/ do |project_name, type_name_table|
types = type_name_table.raw.flatten.map do |type_name|
Type.find_by_name(type_name) || FactoryGirl.create(:type, :name => type_name)
::Type.find_by_name(type_name) || FactoryGirl.create(:type, :name => type_name)
end
project = Project.find_by_identifier(project_name)
@@ -62,7 +62,7 @@ Given(/^the work_package "(.+?)" is updated with the following:$/) do |subject,
work_package = WorkPackage.find_by_subject(subject)
except = {}
except["type"] = lambda{|wp, value| wp.type = Type.find_by_name(value) if value }
except["type"] = lambda{|wp, value| wp.type = ::Type.find_by_name(value) if value }
except["assigned_to"] = lambda{|wp, value| wp.assigned_to = User.find_by_login(value) if value}
except["responsible"] = lambda{|wp, value| wp.responsible = User.find_by_login(value) if value}
@@ -74,7 +74,7 @@ Given(/^the user "([^\"]+)" has the following queries by type in the project "(.
p = get_project(project_name)
table.hashes.each_with_index do |t, i|
types = Type.find_all_by_name(t['type_value']).map {|type| type.id.to_s}
types = ::Type.find_all_by_name(t['type_value']).map {|type| type.id.to_s}
p.queries.create(user_id: u.id, name: t['name'], filters: [Queries::WorkPackages::Filter.new(:type_id, operator: "=", values: types)])
end
end
@@ -74,7 +74,7 @@ module API
end
def type=(value)
model.type = Type.find_by_name(value)
model.type = ::Type.find_by_name(value)
end
def status
+1 -1
View File
@@ -39,7 +39,7 @@ module Redmine
# otherwise false
def no_data?
!Role.find(:first, :conditions => {:builtin => 0}) &&
!Type.find(:first, :conditions => {is_standard: false}) &&
!::Type.find(:first, :conditions => {is_standard: false}) &&
!Status.find(:first) &&
!Enumeration.find(:first)
end
@@ -84,7 +84,7 @@ describe Api::V2::PlanningElementTypesController, :type => :controller do
@all_types = Array.new
@all_types.concat @created_planning_element_types
@all_types.concat Type.where(is_standard: true)
@all_types.concat ::Type.where(is_standard: true)
# Creating one PlanningElemenType which is not assigned to any
# Project and should therefore not show up in projects with a project
@@ -586,7 +586,7 @@ describe Api::V2::PlanningElementsController, :type => :controller do
end
describe 'with custom fields' do
let(:type) { Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:type) { ::Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:custom_field) do
FactoryGirl.create :issue_custom_field,
@@ -717,7 +717,7 @@ describe Api::V2::PlanningElementsController, :type => :controller do
render_views
let(:project) { FactoryGirl.create(:project) }
let(:type) { Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:type) { ::Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:custom_field) do
FactoryGirl.create :text_issue_custom_field,
@@ -802,7 +802,7 @@ describe Api::V2::PlanningElementsController, :type => :controller do
end
describe 'with custom fields' do
let(:type) { Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:type) { ::Type.find_by_name("None") || FactoryGirl.create(:type_standard) }
let(:custom_field) do
FactoryGirl.create :text_issue_custom_field,
+6 -6
View File
@@ -122,7 +122,7 @@ describe TypesController, :type => :controller do
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it 'should have the copied workflows' do
expect(Type.find_by_name('New type').workflows.count).to eq(existing_type.workflows.count)
expect(::Type.find_by_name('New type').workflows.count).to eq(existing_type.workflows.count)
end
end
end
@@ -156,7 +156,7 @@ describe TypesController, :type => :controller do
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it 'should be renamed' do
expect(Type.find_by_name('My type renamed').id).to eq(type.id)
expect(::Type.find_by_name('My type renamed').id).to eq(type.id)
end
end
@@ -170,7 +170,7 @@ describe TypesController, :type => :controller do
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it 'should have no projects assigned' do
expect(Type.find_by_name('My type').projects.count).to eq(0)
expect(::Type.find_by_name('My type').projects.count).to eq(0)
end
end
end
@@ -187,7 +187,7 @@ describe TypesController, :type => :controller do
it { expect(response).to be_redirect }
it { expect(response).to redirect_to(types_path) }
it 'should have the position updated' do
expect(Type.find_by_name('My type').position).to eq(2)
expect(::Type.find_by_name('My type').position).to eq(2)
end
end
@@ -209,7 +209,7 @@ describe TypesController, :type => :controller do
expect(flash[:notice]).to eq(I18n.t(:notice_successful_delete))
end
it 'should not be present in the database' do
expect(Type.find_by_name('My type')).to eq(nil)
expect(::Type.find_by_name('My type')).to eq(nil)
end
end
@@ -233,7 +233,7 @@ describe TypesController, :type => :controller do
expect(flash[:error]).to eq(I18n.t(:error_can_not_delete_type))
end
it 'should be present in the database' do
expect(Type.find_by_name('My type 2').id).to eq(type2.id)
expect(::Type.find_by_name('My type 2').id).to eq(type2.id)
end
end
+1 -1
View File
@@ -34,7 +34,7 @@ FactoryGirl.define do
enabled_module_names Redmine::AccessControl.available_project_modules
callback(:before_create) do |project|
unless Type.find(:first, conditions: { is_standard: true })
unless ::Type.find(:first, conditions: { is_standard: true })
project.types << FactoryGirl.build(:type_standard)
end
end
+1 -1
View File
@@ -44,7 +44,7 @@ FactoryGirl.define do
# reuse existing type with the given name
# this prevents a validation error (name has to be unique)
initialize_with { Type.find_or_create_by_name(name)}
initialize_with { ::Type.find_or_create_by_name(name)}
factory :type_feature do
name "Feature"
@@ -37,14 +37,14 @@ describe 'api/v2/custom_fields/index.api.rabl', :type => :view do
FactoryGirl.create :issue_custom_field,
:name => "Brot",
:field_format => "text",
:types => [(Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
:types => [(::Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
end
let(:custom_field_2) do
FactoryGirl.create :issue_custom_field,
:name => "Belag",
:field_format => "text",
:types => [(Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
:types => [(::Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
end
describe 'with two custom fields' do
@@ -62,7 +62,7 @@ describe 'api/v2/planning_elements/show.api.rabl', :type => :view do
:name => "Belag",
:field_format => "text",
:projects => [planning_element.project],
:types => [(Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
:types => [(::Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
end
before do
@@ -270,7 +270,7 @@ describe 'api/v2/projects/show.api.rabl', :type => :view do
:name => "Belag",
:field_format => "text",
:projects => [project],
:types => [(Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
:types => [(::Type.find_by_name("None") || FactoryGirl.create(:type_standard))]
end
before do
+7 -7
View File
@@ -59,7 +59,7 @@ class TypesControllerTest < ActionController::TestCase
def test_post_create
post :create, :type => { :name => 'New type', :project_ids => ['1', '', ''], :custom_field_ids => ['1', '6', ''] }
assert_redirected_to :action => 'index'
type = Type.find_by_name('New type')
type = ::Type.find_by_name('New type')
assert_equal [1], type.project_ids.sort
assert_equal [1, 6], type.custom_field_ids
assert_equal 0, type.workflows.count
@@ -68,13 +68,13 @@ class TypesControllerTest < ActionController::TestCase
def test_post_create_with_workflow_copy
post :create, :type => { :name => 'New type' }, :copy_workflow_from => 1
assert_redirected_to :action => 'index'
type = Type.find_by_name('New type')
type = ::Type.find_by_name('New type')
assert_equal 0, type.projects.count
assert_equal Type.find(1).workflows.count, type.workflows.count
assert_equal ::Type.find(1).workflows.count, type.workflows.count
end
def test_get_edit
Type.find(1).project_ids = [1, 3]
::Type.find(1).project_ids = [1, 3]
get :edit, :id => 1
assert_response :success
@@ -97,18 +97,18 @@ class TypesControllerTest < ActionController::TestCase
post :update, :id => 1, :type => { :name => 'Renamed',
:project_ids => ['1', '2', ''] }
assert_redirected_to :action => 'index'
assert_equal [1, 2], Type.find(1).project_ids.sort
assert_equal [1, 2], ::Type.find(1).project_ids.sort
end
def test_post_update_without_projects
post :update, :id => 1, :type => { :name => 'Renamed',
:project_ids => [''] }
assert_redirected_to :action => 'index'
assert Type.find(1).project_ids.empty?
assert ::Type.find(1).project_ids.empty?
end
def test_move_lower
type = Type.find_by_position(1)
type = ::Type.find_by_position(1)
post :move, :id => 1, :type => { :move_to => 'lower' }
assert_equal 2, type.reload.position
end
+4 -4
View File
@@ -98,7 +98,7 @@ class ProjectTest < ActiveSupport::TestCase
end
assert_equal Type.all, Project.new.types
assert_equal Type.find(1, 3), Project.new(:type_ids => [1, 3]).types
assert_equal ::Type.find(1, 3), Project.new(:type_ids => [1, 3]).types
end
def test_update
@@ -420,7 +420,7 @@ class ProjectTest < ActiveSupport::TestCase
def test_rolled_up_types
parent = Project.find(1)
parent.types = Type.find([1,2])
parent.types = ::Type.find([1,2])
child = parent.children.find(3)
assert_equal [1, 2], parent.type_ids
@@ -434,9 +434,9 @@ class ProjectTest < ActiveSupport::TestCase
def test_rolled_up_types_should_ignore_archived_subprojects
parent = Project.find(1)
parent.types = Type.find([1,2])
parent.types = ::Type.find([1,2])
child = parent.children.find(3)
child.types = Type.find([1,3])
child.types = ::Type.find([1,3])
parent.children.each(&:archive)
assert_equal [1,2], parent.rolled_up_types.collect(&:id)
+4 -4
View File
@@ -32,7 +32,7 @@ class TypeTest < ActiveSupport::TestCase
fixtures :all
def test_copy_workflows
source = Type.find(1)
source = ::Type.find(1)
assert_equal 89, source.workflows.size
target = Type.new(:name => 'Target')
@@ -43,18 +43,18 @@ class TypeTest < ActiveSupport::TestCase
end
def test_statuses
type = Type.find(1)
type = ::Type.find(1)
Workflow.delete_all
Workflow.create!(:role_id => 1, :type_id => 1, :old_status_id => 2, :new_status_id => 3)
Workflow.create!(:role_id => 2, :type_id => 1, :old_status_id => 3, :new_status_id => 5)
assert_kind_of Array, type.statuses.all
assert_kind_of Status, type.statuses.first
assert_equal [2, 3, 5], Type.find(1).statuses.collect(&:id)
assert_equal [2, 3, 5], ::Type.find(1).statuses.collect(&:id)
end
def test_statuses_empty
Workflow.delete_all("type_id = 1")
assert_equal [], Type.find(1).statuses
assert_equal [], ::Type.find(1).statuses
end
end