mingle-macro-development-toolkit 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/LICENSE.txt +21 -0
  2. data/README.rdoc +66 -0
  3. data/Rakefile +36 -0
  4. data/bin/new_mingle_macro +107 -0
  5. data/example/Rakefile +3 -0
  6. data/example/deploy.rake +10 -0
  7. data/example/init.rb +10 -0
  8. data/example/integration_test.rb +13 -0
  9. data/example/integration_test_helper.rb +19 -0
  10. data/example/macro.rb +18 -0
  11. data/example/unit_test.rb +13 -0
  12. data/example/unit_test_helper.rb +12 -0
  13. data/getting_started.txt +253 -0
  14. data/lib/macro_development_toolkit.rb +22 -0
  15. data/lib/macro_development_toolkit/mingle/card_type.rb +41 -0
  16. data/lib/macro_development_toolkit/mingle/card_type_property_definition.rb +26 -0
  17. data/lib/macro_development_toolkit/mingle/project.rb +80 -0
  18. data/lib/macro_development_toolkit/mingle/project_variable.rb +23 -0
  19. data/lib/macro_development_toolkit/mingle/property_definition.rb +94 -0
  20. data/lib/macro_development_toolkit/mingle/property_value.rb +68 -0
  21. data/lib/macro_development_toolkit/mingle/user.rb +29 -0
  22. data/lib/macro_development_toolkit/mingle_model_loader.rb +169 -0
  23. data/tasks/test.rake +15 -0
  24. data/test/fixtures/sample/card_types.yml +29 -0
  25. data/test/fixtures/sample/card_types_property_definitions.yml +81 -0
  26. data/test/fixtures/sample/project_variables.yml +5 -0
  27. data/test/fixtures/sample/projects.yml +4 -0
  28. data/test/fixtures/sample/property_definitions.yml +41 -0
  29. data/test/fixtures/sample/users.yml +16 -0
  30. data/test/integration/integration_test_helper.rb +20 -0
  31. data/test/integration/rest_loader.rb +302 -0
  32. data/test/integration/rest_loader_test.rb +86 -0
  33. data/test/unit/fixture_loader.rb +180 -0
  34. data/test/unit/fixture_loader_test.rb +46 -0
  35. data/test/unit/unit_test_helper.rb +13 -0
  36. metadata +110 -0
@@ -0,0 +1,86 @@
1
+ #Copyright 2008 ThoughtWorks, Inc. All rights reserved.
2
+
3
+ require File.dirname(__FILE__) + '/integration_test_helper.rb'
4
+
5
+ class RestLoaderTest < Test::Unit::TestCase
6
+
7
+ TEST_PROJECT = 'http://bjanakir:p@localhost:8080/lightweight_projects/scrum_template_2_2.xml'
8
+
9
+ def test_should_load_direct_project_attributes_from_correct_fixture
10
+ assert_not_nil project(TEST_PROJECT)
11
+ assert_equal 'scrum_template_2_2', project(TEST_PROJECT).identifier
12
+ end
13
+
14
+ def test_should_load_first_level_project_associations_from_correct_fixture
15
+ assert_equal(['Release', 'Sprint', 'Story', 'Task', 'Defect', 'Feature', 'Epic Story'], project(TEST_PROJECT).card_types.collect(&:name))
16
+ end
17
+
18
+ def test_should_load_second_level_project_associations_for_card_type_from_correct_fixture
19
+ task_type = project(TEST_PROJECT).card_types.detect { |ct| ct.name == 'Task' }
20
+ assert_equal(['Planning - Release', 'Planning - Sprint', 'Planning - Story', 'Priority', 'Task Status', 'Owner', 'Task Estimate', 'Depend on'], task_type.property_definitions.collect(&:name))
21
+ end
22
+
23
+ def test_should_load_second_level_project_associations_for_property_definition_from_correct_fixture
24
+ priority_definition = project(TEST_PROJECT).property_definitions.detect { |pd| pd.name == 'Priority' }
25
+ assert_equal(['Story', 'Task', 'Defect'], priority_definition.card_types.collect(&:name))
26
+ end
27
+
28
+ def test_should_load_correct_values_for_property_definitions
29
+ priority_definition = project(TEST_PROJECT).property_definitions.detect { |pd| pd.name == 'Priority' }
30
+ assert_equal ['Low', 'Medium', 'High'], priority_definition.values.collect(&:db_identifier)
31
+ end
32
+
33
+ def test_should_load_correct_colors_for_values_of_property_definitions
34
+ priority_definition = project(TEST_PROJECT).property_definitions.detect { |pd| pd.name == 'Priority' }
35
+ assert_equal ['f1ff26', 'ff6600', 'b30600'], priority_definition.values.collect(&:color)
36
+ end
37
+
38
+ def test_should_load_correct_team_members
39
+ assert_equal [], project(TEST_PROJECT).team.collect(&:login)
40
+ end
41
+
42
+ def test_should_detect_project_variables
43
+ assert_equal '#21 Release 1', project(TEST_PROJECT).value_of_project_variable('Current Release')
44
+ end
45
+
46
+ def test_should_execute_mql_to_return_an_array_of_hash_results_for_each_result_row
47
+ mql_results = project(TEST_PROJECT).execute_mql("SELECT SUM('Estimate - planning') WHERE 'Planning - Release' = (Current Release) AND 'Added On' IS NOT NULL")
48
+
49
+ assert_equal 1, mql_results.size
50
+ assert_equal Hash, mql_results.first.class
51
+ assert_equal 86, mql_results.first['Sum_Estimate___Planning'].to_i
52
+ end
53
+
54
+ def test_should_execute_number_format_remotely
55
+ proj = project(TEST_PROJECT)
56
+ assert_equal "3.67", proj.format_number_with_project_precision("3.6711").to_s
57
+ assert_equal "20.14", proj.format_number_with_project_precision("20.1398").to_s
58
+ end
59
+
60
+ def test_should_execute_date_format_remotely
61
+ proj = project(TEST_PROJECT)
62
+ assert_equal "22 May 2005", proj.format_date_with_project_date_format(Date.new(2005, 5, 22))
63
+ assert_equal "06 Oct 2008", proj.format_date_with_project_date_format(Date.new(2008, 10, 6))
64
+ end
65
+
66
+ def test_should_execute_mql_to_return_an_array_of_hash_results_for_each_result_row
67
+ mql_results = project(TEST_PROJECT).execute_mql("SELECT SUM('Estimate - planning') WHERE 'Planning - Release' = (Current Release) AND 'Added On' IS NOT NULL")
68
+
69
+ assert_equal 1, mql_results.size
70
+ assert_equal Hash, mql_results.first.class
71
+ assert_equal 86, mql_results.first['Sum_Estimate___Planning'].to_i
72
+ end
73
+
74
+ def test_should_errors_in_executing_mql_should_be_available_in_the_test
75
+ project = project(TEST_PROJECT)
76
+ mql_results = project.execute_mql("SELECT 'Invalid Property Name'")
77
+ assert_equal 1, errors.size
78
+ assert_equal "Card property 'Invalid Property Name' does not exist!", errors.first
79
+ end
80
+
81
+ def test_should_raise_error_on_trying_to_call_values_for_anything_other_than_managed_or_user_properties
82
+ added_on = project(TEST_PROJECT).property_definitions.detect { |pd| pd.name == 'Added On' }
83
+ assert_raise(RuntimeError) { added_on.values }
84
+ end
85
+
86
+ end
@@ -0,0 +1,180 @@
1
+ #Copyright 2008 ThoughtWorks, Inc. All rights reserved.
2
+
3
+ module FixtureLoaders
4
+ class Base
5
+ def initialize(mingle_file_name, macro_context=nil, alert_receiver=nil)
6
+ @mingle_file_name = mingle_file_name
7
+ @expanded_fixture = File.join(File.dirname(__FILE__), '..', 'fixtures', mingle_file_name)
8
+ raise "No such project fixture! #{mingle_file_name}" unless File.exist?(@expanded_fixture)
9
+ end
10
+
11
+ def load_fixtures_for(name)
12
+ YAML::load(File.open("#{@expanded_fixture}/#{name}.yml"))
13
+ end
14
+
15
+ def card_types_property_definitions_by_card_type_id_loader(card_type_id)
16
+ LoadCardTypesPropertyDefinitionsByCardTypeId.new(card_type_id, @mingle_file_name)
17
+ end
18
+
19
+ def card_types_property_definitions_by_property_definition_id_loader(property_definition_id)
20
+ LoadCardTypesPropertyDefinitionsByPropertyDefinitionId.new(property_definition_id, @mingle_file_name)
21
+ end
22
+
23
+ def values_by_property_definition_id_loader(property_definition_id)
24
+ LoadValuesByPropertyDefinitionId.new(property_definition_id, @mingle_file_name)
25
+ end
26
+
27
+ def card_type_by_id_loader(card_type_id)
28
+ LoadCardTypeById.new(card_type_id, @mingle_file_name)
29
+ end
30
+
31
+ def property_definition_by_id_loader(property_definition_id)
32
+ LoadPropertyDefinitionById.new(property_definition_id, @mingle_file_name)
33
+ end
34
+
35
+ def card_types_by_project_id_loader
36
+ LoadCardTypesByProjectId.new(@mingle_file_name)
37
+ end
38
+
39
+ def property_definitions_by_project_id_loader
40
+ LoadPropertyDefinitionsByProjectId.new(@mingle_file_name)
41
+ end
42
+
43
+ def team_by_project_id_loader
44
+ LoadTeamByProjectId.new(@mingle_file_name)
45
+ end
46
+
47
+ def project_variables_by_project_id_loader
48
+ LoadProjectVariablesByProjectId.new(@mingle_file_name)
49
+ end
50
+
51
+ end
52
+
53
+ class ProjectLoader < Base
54
+ def project
55
+ project_attributes = load_fixtures_for('projects').first
56
+ project = Mingle::Project.new(OpenStruct.new(project_attributes), nil)
57
+ project.card_types_loader = card_types_by_project_id_loader
58
+ project.property_definitions_loader = property_definitions_by_project_id_loader
59
+ project.team_loader = team_by_project_id_loader
60
+ project.project_variables_loader = project_variables_by_project_id_loader
61
+ project
62
+ end
63
+ end
64
+
65
+ class LoadCardTypesByProjectId < Base
66
+ def load
67
+ load_fixtures_for('card_types').collect do |ct|
68
+ card_type = Mingle::CardType.new(OpenStruct.new(ct))
69
+ card_type.card_types_property_definitions_loader = card_types_property_definitions_by_card_type_id_loader(ct['id'])
70
+ card_type
71
+ end.sort_by(&:position)
72
+ end
73
+ end
74
+
75
+ class LoadPropertyDefinitionsByProjectId < Base
76
+ def load
77
+ load_fixtures_for('property_definitions').collect do |pd|
78
+ property_definition = Mingle::PropertyDefinition.new(OpenStruct.new(pd))
79
+ property_definition.card_types_property_definitions_loader = card_types_property_definitions_by_property_definition_id_loader(pd['id'])
80
+ property_definition.values_loader = values_by_property_definition_id_loader(pd['id'])
81
+ property_definition
82
+ end
83
+ end
84
+ end
85
+
86
+ class LoadCardTypesPropertyDefinitionsByCardTypeId < Base
87
+ def initialize(card_type_id, fixture_file_name)
88
+ super(fixture_file_name)
89
+ @card_type_id = card_type_id
90
+ end
91
+
92
+ def load
93
+ load_fixtures_for('card_types_property_definitions').collect do |ctpd|
94
+ next unless ctpd['card_type_id'] == @card_type_id
95
+
96
+ card_type_property_definition = Mingle::CardTypePropertyDefinition.new(OpenStruct.new(ctpd))
97
+ card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd['card_type_id'])
98
+ card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd['property_definition_id'])
99
+ card_type_property_definition
100
+ end.compact.sort_by(&:position).compact
101
+ end
102
+
103
+ end
104
+
105
+ class LoadCardTypesPropertyDefinitionsByPropertyDefinitionId < Base
106
+ def initialize(property_definition_id, fixture_file_name)
107
+ super(fixture_file_name)
108
+ @property_definition_id = property_definition_id
109
+ end
110
+
111
+ def load
112
+ load_fixtures_for('card_types_property_definitions').collect do |ctpd|
113
+ next unless ctpd['property_definition_id'] == @property_definition_id
114
+
115
+ card_type_property_definition = Mingle::CardTypePropertyDefinition.new(OpenStruct.new(ctpd))
116
+ card_type_property_definition.card_type_loader = card_type_by_id_loader(ctpd['card_type_id'])
117
+ card_type_property_definition.property_definition_loader = property_definition_by_id_loader(ctpd['property_definition_id'])
118
+ card_type_property_definition
119
+ end.compact.sort_by(&:position).compact
120
+ end
121
+
122
+ end
123
+
124
+ class LoadCardTypeById < Base
125
+ def initialize(card_type_id, fixture_file_name)
126
+ super(fixture_file_name)
127
+ @card_type_id = card_type_id
128
+ end
129
+
130
+ def load
131
+ yaml = load_fixtures_for('card_types').detect { |ct| ct['id'] == @card_type_id }
132
+ ct = Mingle::CardType.new(OpenStruct.new(yaml))
133
+ ct.card_types_property_definitions_loader = card_types_property_definitions_by_card_type_id_loader(yaml['id'])
134
+ ct
135
+ end
136
+ end
137
+
138
+ class LoadPropertyDefinitionById < Base
139
+ def initialize(property_definition_id, fixture_file_name)
140
+ super(fixture_file_name)
141
+ @property_definition_id = property_definition_id
142
+ end
143
+
144
+ def load
145
+ yaml = load_fixtures_for('property_definitions').detect { |pd| pd['id'] == @property_definition_id }
146
+ pd = Mingle::PropertyDefinition.new(OpenStruct.new(yaml))
147
+ pd.card_types_property_definitions_loader = card_types_property_definitions_by_property_definition_id_loader(yaml['id'])
148
+ pd.values_loader = values_by_property_definition_id_loader(yaml['id'])
149
+ pd
150
+ end
151
+ end
152
+
153
+ class LoadValuesByPropertyDefinitionId < Base
154
+ def initialize(property_definition_id, fixture_file_name)
155
+ super(fixture_file_name)
156
+ @property_definition_id = property_definition_id
157
+ end
158
+
159
+ def load
160
+ result = load_fixtures_for('property_values').collect do |pv|
161
+ next unless pv['property_definition_id'] == @property_definition_id
162
+ property_value = Mingle::PropertyValue.new(OpenStruct.new(pv))
163
+ property_value.property_definition_loader = property_definition_by_id_loader(pv['property_definition_id'])
164
+ property_value
165
+ end.compact
166
+ end
167
+ end
168
+
169
+ class LoadTeamByProjectId < Base
170
+ def load
171
+ load_fixtures_for('users').collect { |user| Mingle::User.new(OpenStruct.new(user)) }
172
+ end
173
+ end
174
+
175
+ class LoadProjectVariablesByProjectId < Base
176
+ def load
177
+ load_fixtures_for('project_variables').collect { |pv| Mingle::ProjectVariable.new(OpenStruct.new(pv)) }
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,46 @@
1
+ #Copyright 2008 ThoughtWorks, Inc. All rights reserved.
2
+
3
+ require File.dirname(__FILE__) + '/unit_test_helper.rb'
4
+
5
+ class FixtureLoaderTest < Test::Unit::TestCase
6
+
7
+ TEST_FIXTURE = 'sample'
8
+
9
+ def test_should_load_direct_project_attributes_from_correct_fixture
10
+ assert_not_nil project(TEST_FIXTURE)
11
+ assert_equal 'scrum_template_2_1', project(TEST_FIXTURE).identifier
12
+ end
13
+
14
+ def test_should_load_first_level_project_associations_from_correct_fixture
15
+ assert_equal(['Release', 'Sprint', 'Story', 'Task', 'Defect', 'Feature', 'Epic Story'], project(TEST_FIXTURE).card_types.collect(&:name))
16
+ end
17
+
18
+ def test_should_load_second_level_project_associations_for_card_type_from_correct_fixture
19
+ task_type = project(TEST_FIXTURE).card_types.detect { |ct| ct.name == 'Task' }
20
+ assert_equal(['Estimate - Planning', 'Risk', 'Added On', 'Priority', 'Owner', 'Task Estimate'], task_type.property_definitions.collect(&:name))
21
+ end
22
+
23
+ def test_should_load_second_level_project_associations_for_property_definition_from_correct_fixture
24
+ priority_definition = project(TEST_FIXTURE).property_definitions.detect { |pd| pd.name == 'Priority' }
25
+ assert_equal(['Story', 'Task', 'Defect'], priority_definition.card_types.collect(&:name))
26
+ end
27
+
28
+ def test_should_load_correct_values_for_property_definitions
29
+ priority_definition = project(TEST_FIXTURE).property_definitions.detect { |pd| pd.name == 'Priority' }
30
+ assert_equal ['High', 'Medium', 'Low'], priority_definition.values.collect(&:db_identifier)
31
+ end
32
+
33
+ def test_should_load_correct_team_members
34
+ assert_equal ['groucho', 'harpo', 'karl'], project(TEST_FIXTURE).team.collect(&:login)
35
+ end
36
+
37
+ def test_should_detect_project_variables
38
+ assert_equal 'Release 3', project(TEST_FIXTURE).value_of_project_variable('Current Release')
39
+ end
40
+
41
+ def test_should_raise_error_on_trying_to_call_values_for_anything_other_than_managed_or_user_properties
42
+ added_on = project(TEST_FIXTURE).property_definitions.detect { |pd| pd.name == 'Added On' }
43
+ assert_raise(RuntimeError) { added_on.values }
44
+ end
45
+ end
46
+
@@ -0,0 +1,13 @@
1
+ #Copyright 2008 ThoughtWorks, Inc. All rights reserved.
2
+
3
+ require 'test/unit'
4
+ require 'macro_development_toolkit'
5
+ require File.dirname(__FILE__) + '/fixture_loader'
6
+
7
+ class Test::Unit::TestCase
8
+
9
+ def project(name)
10
+ @project ||= FixtureLoaders::ProjectLoader.new(name).project
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mingle-macro-development-toolkit
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - ThoughtWorks Inc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-08 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ version:
35
+ description: ""
36
+ email:
37
+ - support@thoughtworks.com
38
+ executables:
39
+ - new_mingle_macro
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - getting_started.txt
44
+ - README.rdoc
45
+ - LICENSE.txt
46
+ files:
47
+ - getting_started.txt
48
+ - README.rdoc
49
+ - LICENSE.txt
50
+ - Rakefile
51
+ - lib/macro_development_toolkit.rb
52
+ - lib/macro_development_toolkit/mingle/card_type_property_definition.rb
53
+ - lib/macro_development_toolkit/mingle/card_type.rb
54
+ - lib/macro_development_toolkit/mingle/project_variable.rb
55
+ - lib/macro_development_toolkit/mingle/project.rb
56
+ - lib/macro_development_toolkit/mingle/property_definition.rb
57
+ - lib/macro_development_toolkit/mingle/property_value.rb
58
+ - lib/macro_development_toolkit/mingle/user.rb
59
+ - lib/macro_development_toolkit/mingle_model_loader.rb
60
+ - tasks/test.rake
61
+ - test/unit/fixture_loader.rb
62
+ - test/unit/unit_test_helper.rb
63
+ - test/unit/fixture_loader_test.rb
64
+ - test/integration/rest_loader.rb
65
+ - test/integration/integration_test_helper.rb
66
+ - test/integration/rest_loader_test.rb
67
+ - test/fixtures/sample/card_types.yml
68
+ - test/fixtures/sample/card_types_property_definitions.yml
69
+ - test/fixtures/sample/project_variables.yml
70
+ - test/fixtures/sample/projects.yml
71
+ - test/fixtures/sample/property_definitions.yml
72
+ - test/fixtures/sample/users.yml
73
+ - bin/new_mingle_macro
74
+ - example/Rakefile
75
+ - example/deploy.rake
76
+ - example/init.rb
77
+ - example/macro.rb
78
+ - example/unit_test.rb
79
+ - example/unit_test_helper.rb
80
+ - example/integration_test.rb
81
+ - example/integration_test_helper.rb
82
+ has_rdoc: true
83
+ homepage: "This toolkit provides support for developing, testing and deploying custom Mingle macros. "
84
+ post_install_message: getting_started.txt
85
+ rdoc_options:
86
+ - --main
87
+ - README.rdoc
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: "0"
101
+ version:
102
+ requirements: []
103
+
104
+ rubyforge_project: mingle-macros
105
+ rubygems_version: 1.3.0
106
+ signing_key:
107
+ specification_version: 2
108
+ summary: ""
109
+ test_files: []
110
+