Fully qualify ::Type class constant

See 0b941955.

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/2160/head
Alex Coles 10 years ago
parent e8c1d940e0
commit f75392f8be
  1. 6
      app/models/workflow.rb
  2. 4
      features/step_definitions/type_steps.rb
  3. 82
      lib/redmine/default_data/loader.rb
  4. 6
      spec/factories/type_factory.rb
  5. 2
      test/exemplars/type_exemplar.rb

@ -68,7 +68,7 @@ class Workflow < ActiveRecord::Base
# Copies workflows from source to targets # Copies workflows from source to targets
def self.copy(source_type, source_role, target_types, target_roles) def self.copy(source_type, source_role, target_types, target_roles)
unless source_type.is_a?(Type) || source_role.is_a?(Role) unless source_type.is_a?(::Type) || source_role.is_a?(Role)
raise ArgumentError.new('source_type or source_role must be specified') raise ArgumentError.new('source_type or source_role must be specified')
end end
@ -90,9 +90,9 @@ class Workflow < ActiveRecord::Base
# Copies a single set of workflows from source to target # Copies a single set of workflows from source to target
def self.copy_one(source_type, source_role, target_type, target_role) def self.copy_one(source_type, source_role, target_type, target_role)
unless source_type.is_a?(Type) && !source_type.new_record? && unless source_type.is_a?(::Type) && !source_type.new_record? &&
source_role.is_a?(Role) && !source_role.new_record? && source_role.is_a?(Role) && !source_role.new_record? &&
target_type.is_a?(Type) && !target_type.new_record? && target_type.is_a?(::Type) && !target_type.new_record? &&
target_role.is_a?(Role) && !target_role.new_record? target_role.is_a?(Role) && !target_role.new_record?
raise ArgumentError.new('arguments can not be nil or unsaved objects') raise ArgumentError.new('arguments can not be nil or unsaved objects')

@ -29,9 +29,9 @@
# change from symbol to constant once namespace is removed # 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') RouteMap.register(::Type, '/types')
Given /^the following types are enabled for the project called "(.*?)":$/ do |project_name, type_name_table| 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| types = type_name_table.raw.flatten.map do |type_name|

@ -150,55 +150,55 @@ module Redmine
end).flatten] end).flatten]
# Types # Types
task = Type.create! name: l(:default_type_task), task = ::Type.create! name: l(:default_type_task),
color_id: colors[:Mint], color_id: colors[:Mint],
is_default: false, is_default: false,
is_in_roadmap: true, is_in_roadmap: true,
in_aggregation: true, in_aggregation: true,
is_milestone: false, is_milestone: false,
position: 1 position: 1
deliverable = Type.create! name: l(:default_type_deliverable), deliverable = ::Type.create! name: l(:default_type_deliverable),
is_default: false, is_default: false,
color_id: colors[:Orange], color_id: colors[:Orange],
is_in_roadmap: true, is_in_roadmap: true,
in_aggregation: true,
is_milestone: false,
position: 2
milestone = ::Type.create! name: l(:default_type_milestone),
is_default: true,
color_id: colors[:Purple],
is_in_roadmap: false,
in_aggregation: true, in_aggregation: true,
is_milestone: false, is_milestone: true,
position: 2 position: 3
milestone = Type.create! name: l(:default_type_milestone), phase = ::Type.create! name: l(:default_type_phase),
is_default: true, is_default: true,
color_id: colors[:Purple], color_id: colors[:Lime],
is_in_roadmap: false, is_in_roadmap: false,
in_aggregation: true, in_aggregation: true,
is_milestone: true, is_milestone: false,
position: 3 position: 4
phase = Type.create! name: l(:default_type_phase), bug = ::Type.create! name: l(:default_type_bug),
is_default: true, is_default: false,
color_id: colors[:Lime], color_id: colors[:'Red-bright'],
is_in_roadmap: false, is_in_roadmap: true,
in_aggregation: true, in_aggregation: true,
is_milestone: false, is_milestone: false,
position: 4 position: 5
bug = Type.create! name: l(:default_type_bug), feature = ::Type.create! name: l(:default_type_feature),
is_default: false, is_default: false,
color_id: colors[:'Red-bright'], color_id: colors[:Blue],
is_in_roadmap: true, is_in_roadmap: true,
in_aggregation: true, in_aggregation: true,
is_milestone: false, is_milestone: false,
position: 5 position: 6
feature = Type.create! name: l(:default_type_feature),
is_default: false,
color_id: colors[:Blue],
is_in_roadmap: true,
in_aggregation: true,
is_milestone: false,
position: 6
none = Type.standard_type none = ::Type.standard_type
# Issue statuses # Issue statuses
new = Status.create!(name: l(:default_status_new), is_closed: false, is_default: true, position: 1) new = Status.create!(name: l(:default_status_new), is_closed: false, is_default: true, position: 1)

@ -32,13 +32,13 @@ FactoryGirl.define do
name { |a| "Type No. #{a.position}" } name { |a| "Type No. #{a.position}" }
end end
factory :type_standard, class: Type do factory :type_standard, class: ::Type do
name 'None' name 'None'
is_standard true is_standard true
is_default true is_default true
end end
factory :type_bug, class: Type do factory :type_bug, class: ::Type do
name 'Bug' name 'Bug'
position 1 position 1
@ -63,7 +63,7 @@ FactoryGirl.define do
end end
end end
factory :type_with_workflow, class: Type do factory :type_with_workflow, class: ::Type do
sequence(:name) { |n| "Type #{n}" } sequence(:name) { |n| "Type #{n}" }
sequence(:position) { |n| n } sequence(:position) { |n| n }
callback(:after_build) do |t| callback(:after_build) do |t|

@ -27,7 +27,7 @@
# See doc/COPYRIGHT.rdoc for more details. # See doc/COPYRIGHT.rdoc for more details.
#++ #++
class Type < ActiveRecord::Base class ::Type < ActiveRecord::Base
generator_for :name, :method => :next_name generator_for :name, :method => :next_name
def self.next_name def self.next_name

Loading…
Cancel
Save