mingle-macro-development-toolkit 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/{README.rdoc → README.txt} +8 -6
- data/Rakefile +19 -27
- data/bin/new_mingle_macro +10 -4
- data/example/integration_test_helper.rb +5 -5
- data/example/unit_test_helper.rb +4 -13
- data/lib/macro_development_toolkit.rb +1 -1
- data/lib/macro_development_toolkit/mingle/project.rb +4 -4
- data/lib/macro_development_toolkit/mingle_model_loader.rb +100 -136
- data/test/fixtures/sample/card_types.yml +9 -1
- data/test/fixtures/sample/project_variables.yml +3 -1
- data/test/fixtures/sample/property_definitions.yml +13 -3
- data/test/integration/integration_test_helper.rb +20 -8
- data/test/integration/rest_loader.rb +172 -250
- data/test/unit/fixture_loader.rb +73 -145
- data/test/unit/fixture_loader_test.rb +11 -11
- data/test/unit/unit_test_helper.rb +6 -5
- metadata +29 -15
data/test/unit/fixture_loader.rb
CHANGED
@@ -1,181 +1,109 @@
|
|
1
1
|
#Copyright 2010 ThoughtWorks, Inc. All rights reserved.
|
2
|
-
require 'erb'
|
3
2
|
|
4
3
|
module FixtureLoaders
|
5
4
|
class Base
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
raise "No such project fixture! #{mingle_file_name}" unless File.exist?(@expanded_fixture)
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
@attributes = attributes
|
10
8
|
end
|
11
|
-
|
9
|
+
|
12
10
|
def load_fixtures_for(name)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def card_types_property_definitions_by_card_type_id_loader(card_type_id)
|
17
|
-
LoadCardTypesPropertyDefinitionsByCardTypeId.new(card_type_id, @mingle_file_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
def card_types_property_definitions_by_property_definition_id_loader(property_definition_id)
|
21
|
-
LoadCardTypesPropertyDefinitionsByPropertyDefinitionId.new(property_definition_id, @mingle_file_name)
|
22
|
-
end
|
23
|
-
|
24
|
-
def values_by_property_definition_id_loader(property_definition_id)
|
25
|
-
LoadValuesByPropertyDefinitionId.new(property_definition_id, @mingle_file_name)
|
26
|
-
end
|
27
|
-
|
28
|
-
def card_type_by_id_loader(card_type_id)
|
29
|
-
LoadCardTypeById.new(card_type_id, @mingle_file_name)
|
11
|
+
path = File.join(File.dirname(__FILE__), '..', 'fixtures', "sample", "#{name}.yml")
|
12
|
+
YAML::load(File.read(path))
|
30
13
|
end
|
31
|
-
|
32
|
-
def property_definition_by_id_loader(property_definition_id)
|
33
|
-
LoadPropertyDefinitionById.new(property_definition_id, @mingle_file_name)
|
34
|
-
end
|
35
14
|
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def property_definitions_by_project_id_loader
|
41
|
-
LoadPropertyDefinitionsByProjectId.new(@mingle_file_name)
|
42
|
-
end
|
43
|
-
|
44
|
-
def team_by_project_id_loader
|
45
|
-
LoadTeamByProjectId.new(@mingle_file_name)
|
15
|
+
def match?(record)
|
16
|
+
@attributes.all? { |key, value| value == record[key] }
|
46
17
|
end
|
47
|
-
|
48
|
-
def project_variables_by_project_id_loader
|
49
|
-
LoadProjectVariablesByProjectId.new(@mingle_file_name)
|
50
|
-
end
|
51
|
-
|
52
18
|
end
|
53
19
|
|
54
20
|
class ProjectLoader < Base
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
project
|
60
|
-
project.
|
61
|
-
project.
|
62
|
-
project
|
21
|
+
attr_reader :project
|
22
|
+
|
23
|
+
def initialize(identifier)
|
24
|
+
project_attributes = load_fixtures_for('projects').detect {|project| project['identifier'] == identifier }
|
25
|
+
@project = Mingle::Project.new(OpenStruct.new(project_attributes), nil)
|
26
|
+
project.card_types_loader = CardTypesLoader.new('project_id' => project_attributes['id'])
|
27
|
+
project.property_definitions_loader = PropertyDefinitionsLoader.new('project_id' => project_attributes['id'])
|
28
|
+
project.team_loader = TeamLoader.new('project_id' => project_attributes['id'])
|
29
|
+
project.project_variables_loader = ProjectVariablesLoader.new('project_id' => project_attributes['id'])
|
63
30
|
end
|
64
31
|
end
|
65
|
-
|
66
|
-
class
|
32
|
+
|
33
|
+
class CardTypesLoader < Base
|
67
34
|
def load
|
68
35
|
load_fixtures_for('card_types').collect do |ct|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end.sort_by(&:position)
|
73
|
-
end
|
36
|
+
CardTypeLoader.new('id' => ct['id']) if match?(ct)
|
37
|
+
end.compact.sort_by { |loader| loader.card_type.position }
|
38
|
+
end
|
74
39
|
end
|
75
|
-
|
76
|
-
class
|
40
|
+
|
41
|
+
class CardTypeLoader < Base
|
42
|
+
def card_type
|
43
|
+
@card_type ||= load
|
44
|
+
end
|
45
|
+
|
77
46
|
def load
|
78
|
-
load_fixtures_for('
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
47
|
+
record = load_fixtures_for('card_types').find {|ct| match?(ct)}
|
48
|
+
card_type = Mingle::CardType.new(OpenStruct.new(record))
|
49
|
+
card_type.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new('card_type_id' => record['id'])
|
50
|
+
card_type
|
51
|
+
end
|
85
52
|
end
|
86
|
-
|
87
|
-
class LoadCardTypesPropertyDefinitionsByCardTypeId < Base
|
88
|
-
def initialize(card_type_id, fixture_file_name)
|
89
|
-
super(fixture_file_name)
|
90
|
-
@card_type_id = card_type_id
|
91
|
-
end
|
92
53
|
|
54
|
+
class PropertyDefinitionsLoader < Base
|
93
55
|
def load
|
94
|
-
load_fixtures_for('
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd['card_type_id'])
|
99
|
-
card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd['property_definition_id'])
|
100
|
-
card_type_property_definition
|
101
|
-
end.compact.sort_by(&:position).compact
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
class LoadCardTypesPropertyDefinitionsByPropertyDefinitionId < Base
|
107
|
-
def initialize(property_definition_id, fixture_file_name)
|
108
|
-
super(fixture_file_name)
|
109
|
-
@property_definition_id = property_definition_id
|
110
|
-
end
|
111
|
-
|
112
|
-
def load
|
113
|
-
load_fixtures_for('property_type_mappings').collect do |ctpd|
|
114
|
-
next unless ctpd['property_definition_id'] == @property_definition_id
|
115
|
-
|
116
|
-
card_type_property_definition = Mingle::CardTypePropertyDefinition.new(OpenStruct.new(ctpd))
|
117
|
-
card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd['card_type_id'])
|
118
|
-
card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd['property_definition_id'])
|
119
|
-
card_type_property_definition
|
120
|
-
end.compact.sort_by(&:position).compact
|
121
|
-
end
|
122
|
-
|
56
|
+
load_fixtures_for('property_definitions').collect do |pd|
|
57
|
+
PropertyDefinitionLoader.new('id' => pd['id']) if match?(pd)
|
58
|
+
end.compact
|
59
|
+
end
|
123
60
|
end
|
124
|
-
|
125
|
-
class
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
61
|
+
|
62
|
+
class PropertyDefinitionLoader < Base
|
63
|
+
def property_definition
|
64
|
+
@property_definition ||= load
|
65
|
+
end
|
66
|
+
|
131
67
|
def load
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
class LoadPropertyDefinitionById < Base
|
140
|
-
def initialize(property_definition_id, fixture_file_name)
|
141
|
-
super(fixture_file_name)
|
142
|
-
@property_definition_id = property_definition_id
|
68
|
+
record = load_fixtures_for('property_definitions').find { |pd| match?(pd)}
|
69
|
+
property_definition = Mingle::PropertyDefinition.new(OpenStruct.new(record))
|
70
|
+
property_definition.card_types_property_definitions_loader = CardTypesPropertyDefinitionsLoader.new('property_definition_id' => record['id'])
|
71
|
+
property_definition.values_loader = PropertyValuesLoader.new('property_definition_id' => record['id'])
|
72
|
+
property_definition
|
143
73
|
end
|
144
|
-
|
74
|
+
end
|
75
|
+
|
76
|
+
class PropertyValuesLoader < Base
|
145
77
|
def load
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
pd
|
151
|
-
end
|
78
|
+
load_fixtures_for('property_values').collect do |pv|
|
79
|
+
Mingle::PropertyValue.new(OpenStruct.new(pv)) if match?(pv)
|
80
|
+
end.compact
|
81
|
+
end
|
152
82
|
end
|
153
83
|
|
154
|
-
class
|
155
|
-
def initialize(property_definition_id, fixture_file_name)
|
156
|
-
super(fixture_file_name)
|
157
|
-
@property_definition_id = property_definition_id
|
158
|
-
end
|
159
|
-
|
84
|
+
class CardTypesPropertyDefinitionsLoader < Base
|
160
85
|
def load
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
property_value
|
86
|
+
load_fixtures_for('property_type_mappings').collect do |mapping|
|
87
|
+
pd = PropertyDefinitionLoader.new('id' => mapping['property_definition_id']) if match?(mapping)
|
88
|
+
ct = CardTypeLoader.new('id' => mapping['card_type_id']) if match?(mapping)
|
89
|
+
OpenStruct.new(:card_type => ct.load, :property_definition => pd.load) if ct && pd
|
166
90
|
end.compact
|
167
|
-
end
|
91
|
+
end
|
168
92
|
end
|
169
93
|
|
170
|
-
class
|
94
|
+
class TeamLoader < Base
|
171
95
|
def load
|
172
|
-
load_fixtures_for('users').collect
|
173
|
-
|
96
|
+
load_fixtures_for('users').collect do |user|
|
97
|
+
Mingle::User.new(OpenStruct.new(user)) if match?(user)
|
98
|
+
end.compact
|
99
|
+
end
|
174
100
|
end
|
175
|
-
|
176
|
-
class
|
101
|
+
|
102
|
+
class ProjectVariablesLoader < Base
|
177
103
|
def load
|
178
|
-
load_fixtures_for('project_variables').collect
|
179
|
-
|
104
|
+
load_fixtures_for('project_variables').collect do |pv|
|
105
|
+
Mingle::ProjectVariable.new(OpenStruct.new(pv)) if match?(pv)
|
106
|
+
end.compact
|
107
|
+
end
|
180
108
|
end
|
181
109
|
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
#Copyright
|
1
|
+
#Copyright 2010 ThoughtWorks, Inc. All rights reserved.
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/unit_test_helper.rb'
|
4
4
|
|
5
5
|
class FixtureLoaderTest < Test::Unit::TestCase
|
6
6
|
|
7
|
-
|
7
|
+
PROJECT = 'scrum_template_2_1'
|
8
8
|
|
9
9
|
def test_should_load_direct_project_attributes_from_correct_fixture
|
10
|
-
assert_not_nil project(
|
11
|
-
assert_equal 'scrum_template_2_1', project(
|
10
|
+
assert_not_nil project(PROJECT)
|
11
|
+
assert_equal 'scrum_template_2_1', project(PROJECT).identifier
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_should_load_first_level_project_associations_from_correct_fixture
|
15
|
-
assert_equal(['Release', 'Sprint', 'Story', 'Task', 'Defect', 'Feature', 'Epic Story'], project(
|
15
|
+
assert_equal(['Release', 'Sprint', 'Story', 'Task', 'Defect', 'Feature', 'Epic Story'], project(PROJECT).card_types.collect(&:name))
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_should_load_second_level_project_associations_for_card_type_from_correct_fixture
|
19
|
-
task_type = project(
|
19
|
+
task_type = project(PROJECT).card_types.detect { |ct| ct.name == 'Task' }
|
20
20
|
assert_equal(['Estimate - Planning', 'Risk', 'Added On', 'Priority', 'Owner', 'Task Estimate'], task_type.property_definitions.collect(&:name))
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_should_load_second_level_project_associations_for_property_definition_from_correct_fixture
|
24
|
-
priority_definition = project(
|
24
|
+
priority_definition = project(PROJECT).property_definitions.detect { |pd| pd.name == 'Priority' }
|
25
25
|
assert_equal(['Story', 'Task', 'Defect'], priority_definition.card_types.collect(&:name))
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_load_correct_values_for_property_definitions
|
29
|
-
priority_definition = project(
|
29
|
+
priority_definition = project(PROJECT).property_definitions.detect { |pd| pd.name == 'Priority' }
|
30
30
|
assert_equal ['High', 'Medium', 'Low'], priority_definition.values.collect(&:db_identifier)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_should_load_correct_team_members
|
34
|
-
assert_equal ['groucho', 'harpo', 'karl'], project(
|
34
|
+
assert_equal ['groucho', 'harpo', 'karl'], project(PROJECT).team.collect(&:login)
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_should_detect_project_variables
|
38
|
-
assert_equal 'Release 3', project(
|
38
|
+
assert_equal 'Release 3', project(PROJECT).value_of_project_variable('Current Release')
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_should_raise_error_on_trying_to_call_values_for_anything_other_than_managed_or_user_properties
|
42
|
-
added_on = project(
|
42
|
+
added_on = project(PROJECT).property_definitions.detect { |pd| pd.name == 'Added On' }
|
43
43
|
assert_raise(RuntimeError) { added_on.values }
|
44
44
|
end
|
45
45
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
#Copyright
|
1
|
+
#Copyright 2010 ThoughtWorks, Inc. All rights reserved.
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'macro_development_toolkit'
|
5
5
|
require File.dirname(__FILE__) + '/fixture_loader'
|
6
6
|
|
7
7
|
class Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
def project(name)
|
10
|
-
@
|
11
|
-
|
12
|
-
|
10
|
+
@projects ||= {}
|
11
|
+
@projects[name] ||= FixtureLoaders::ProjectLoader.new(name).project
|
12
|
+
end
|
13
|
+
|
13
14
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
8
|
+
- 3
|
9
|
+
version: 1.3.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- ThoughtWorks Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-27 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -22,13 +22,13 @@ dependencies:
|
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 2
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 2.
|
29
|
+
- 3
|
30
|
+
- 5
|
31
|
+
version: 2.3.5
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
@@ -46,19 +46,33 @@ dependencies:
|
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: gemcutter
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id003 !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
segments:
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
version:
|
56
|
+
- 0
|
57
|
+
- 5
|
58
|
+
- 0
|
59
|
+
version: 0.5.0
|
60
60
|
type: :development
|
61
61
|
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: hoe
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 2
|
71
|
+
- 5
|
72
|
+
- 0
|
73
|
+
version: 2.5.0
|
74
|
+
type: :development
|
75
|
+
version_requirements: *id004
|
62
76
|
description: ""
|
63
77
|
email:
|
64
78
|
- support@thoughtworks.com
|
@@ -68,12 +82,12 @@ extensions: []
|
|
68
82
|
|
69
83
|
extra_rdoc_files:
|
70
84
|
- getting_started.txt
|
85
|
+
- README.txt
|
71
86
|
- LICENSE.txt
|
72
87
|
- History.txt
|
73
|
-
- README.rdoc
|
74
88
|
files:
|
75
89
|
- getting_started.txt
|
76
|
-
- README.
|
90
|
+
- README.txt
|
77
91
|
- LICENSE.txt
|
78
92
|
- History.txt
|
79
93
|
- Rakefile
|
@@ -111,7 +125,7 @@ files:
|
|
111
125
|
- example/integration_test.rb
|
112
126
|
- example/integration_test_helper.rb
|
113
127
|
has_rdoc: true
|
114
|
-
homepage:
|
128
|
+
homepage: http://mingle-macros.rubyforge.org/
|
115
129
|
licenses: []
|
116
130
|
|
117
131
|
post_install_message: getting_started.txt
|