mingle_events 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +6 -14
  2. data/Gemfile +1 -1
  3. data/lib/mingle_events/feed/category.rb +31 -18
  4. data/lib/mingle_events/feed/changes.rb +0 -1
  5. data/lib/mingle_events/processors/card_type_filter.rb +8 -8
  6. data/lib/mingle_events/xml.rb +18 -12
  7. data/lib/mingle_events/zip_directory.rb +6 -6
  8. data/test/mingle_events/entry_cache_test.rb +8 -8
  9. data/test/mingle_events/feed/author_test.rb +7 -7
  10. data/test/mingle_events/feed/category_test.rb +8 -8
  11. data/test/mingle_events/feed/changes_test.rb +87 -37
  12. data/test/mingle_events/feed/entry_test.rb +26 -26
  13. data/test/mingle_events/feed/links_test.rb +4 -4
  14. data/test/mingle_events/feed/page_test.rb +11 -11
  15. data/test/mingle_events/mingle_basic_auth_access_test.rb +1 -1
  16. data/test/mingle_events/mingle_hmac_auth_access_test.rb +1 -1
  17. data/test/mingle_events/mingle_oauth_access_test.rb +1 -1
  18. data/test/mingle_events/poller_test.rb +15 -15
  19. data/test/mingle_events/processors/author_filter_test.rb +21 -21
  20. data/test/mingle_events/processors/card_data_test.rb +61 -61
  21. data/test/mingle_events/processors/card_type_filter_test.rb +20 -24
  22. data/test/mingle_events/processors/category_filter_test.rb +6 -6
  23. data/test/mingle_events/processors/custom_property_filter_test.rb +17 -21
  24. data/test/mingle_events/processors/filter_test.rb +3 -3
  25. data/test/mingle_events/processors/pipeline_test.rb +4 -4
  26. data/test/mingle_events/processors/processor_test.rb +3 -3
  27. data/test/mingle_events/project_custom_properties_test.rb +23 -23
  28. data/test/mingle_events/project_event_fetcher_test.rb +23 -23
  29. data/test/mingle_events/xml_test.rb +6 -1
  30. data/test/mingle_events/zip_directory_test.rb +1 -1
  31. data/test/test_helper.rb +8 -3
  32. metadata +26 -25
@@ -2,9 +2,9 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Feed
5
-
6
- class EntryTest < Test::Unit::TestCase
7
-
5
+
6
+ class EntryTest < MiniTest::Test
7
+
8
8
  def test_parse_basic_attributes
9
9
  element_xml_text = %{
10
10
  <entry xmlns="http://www.w3.org/2005/Atom" >
@@ -18,14 +18,14 @@ module MingleEvents
18
18
  </author>
19
19
  </entry>
20
20
  }
21
- entry = Entry.from_snippet(element_xml_text)
22
- # assert_equal(element_xml_text.inspect, entry.raw_xml.inspect)
21
+ entry = Entry.from_snippet(element_xml_text)
22
+ # assert_equal(element_xml_text.inspect, entry.raw_xml.inspect)
23
23
  assert_equal("https://mingle.example.com/projects/mingle/events/index/234443", entry.entry_id)
24
24
  assert_equal("Page Special:HeaderActions changed", entry.title)
25
25
  assert_equal(Time.utc(2011, 2, 3, 8, 12, 42), entry.updated)
26
26
  assert_equal("Sammy Soso", entry.author.name)
27
27
  end
28
-
28
+
29
29
  def test_parse_categories
30
30
  element_xml_text = %{
31
31
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -38,12 +38,12 @@ module MingleEvents
38
38
  entry.categories
39
39
  )
40
40
  end
41
-
41
+
42
42
  def test_parse_card_number_and_version
43
-
43
+
44
44
  # the links below contain intentionally nonsensical data so as to ensure
45
45
  # that the card number is derived from a single, precise position
46
-
46
+
47
47
  element_xml_text = %{
48
48
  <entry xmlns="http://www.w3.org/2005/Atom">
49
49
  <category term="card" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
@@ -56,35 +56,35 @@ module MingleEvents
56
56
  assert_equal(106, entry.card_number)
57
57
  assert_equal(7, entry.version)
58
58
  end
59
-
60
- def test_card_number_and_version_throws_error_when_event_not_related_to_a_card
59
+
60
+ def test_card_number_and_version_throws_error_when_event_not_related_to_a_card
61
61
  element_xml_text = %{
62
62
  <entry xmlns="http://www.w3.org/2005/Atom">
63
63
  <category term="page" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
64
64
  </entry>}
65
65
  entry = Entry.from_snippet(element_xml_text)
66
-
66
+
67
67
  begin
68
68
  entry.card_number
69
69
  fail("Should not have been able to retrieve a card number for non card-related event!")
70
70
  rescue Exception => e
71
71
  assert_equal("You cannot get the card number for an event that is not sourced by a card!", e.message)
72
72
  end
73
-
73
+
74
74
  begin
75
75
  entry.version
76
76
  fail("Should not have been able to retrieve a card version for non card-related event!")
77
77
  rescue Exception => e
78
78
  assert_equal("You cannot get card version data for an event that is not sourced by a card!", e.message)
79
79
  end
80
-
80
+
81
81
  end
82
-
82
+
83
83
  def test_parse_card_version_resource_uri
84
-
84
+
85
85
  # the links below contain intentionally nonsensical data so as to ensure
86
86
  # that the card number is derived from a single, precise position
87
-
87
+
88
88
  element_xml_text = %{
89
89
  <entry xmlns="http://www.w3.org/2005/Atom">
90
90
  <category term="card" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
@@ -96,7 +96,7 @@ module MingleEvents
96
96
  entry = Entry.from_snippet(element_xml_text)
97
97
  assert_equal('https://mingle.example.com/api/v2/projects/atlas/cards/104.xml?version=7', entry.card_version_resource_uri)
98
98
  end
99
-
99
+
100
100
  def test_card_version_resource_uri_throws_error_when_not_card_event
101
101
  element_xml_text = %{
102
102
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -110,7 +110,7 @@ module MingleEvents
110
110
  assert_equal("You cannot get card version data for an event that is not sourced by a card!", e.message)
111
111
  end
112
112
  end
113
-
113
+
114
114
  def test_entry_id_aliased_as_event_id
115
115
  element_xml_text = %{
116
116
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -120,7 +120,7 @@ module MingleEvents
120
120
  assert_equal('https://mingle.example.com/projects/mingle/events/index/234443', entry.event_id)
121
121
  assert_equal(entry.entry_id, entry.event_id)
122
122
  end
123
-
123
+
124
124
  def test_entry_id_determines_equality
125
125
  element_xml_text_1 = %{
126
126
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -128,27 +128,27 @@ module MingleEvents
128
128
  <category term="page" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
129
129
  </entry>}
130
130
  entry_1 = Entry.from_snippet(element_xml_text_1)
131
-
131
+
132
132
  element_xml_text_2 = %{
133
133
  <entry xmlns="http://www.w3.org/2005/Atom">
134
134
  <id>https://mingle.example.com/projects/mingle/events/index/234443</id>
135
135
  <category term="card" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
136
136
  </entry>}
137
137
  entry_2 = Entry.from_snippet(element_xml_text_2)
138
-
138
+
139
139
  element_xml_text_3 = %{
140
140
  <entry xmlns="http://www.w3.org/2005/Atom">
141
141
  <id>https://mingle.example.com/projects/mingle/events/index/234</id>
142
142
  <category term="card" scheme="http://www.thoughtworks-studios.com/ns/mingle#categories"/>
143
143
  </entry>}
144
144
  entry_3 = Entry.from_snippet(element_xml_text_3)
145
-
145
+
146
146
  assert entry_1.eql?(entry_2)
147
147
  assert entry_1 == entry_2
148
148
  assert !entry_2.eql?(entry_3)
149
149
  assert entry_2 != entry_3
150
150
  end
151
-
151
+
152
152
  def test_construct_links
153
153
  element_xml_text = %{
154
154
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -160,8 +160,8 @@ module MingleEvents
160
160
  links = entry.links.to_a
161
161
  assert_equal 2, links.count
162
162
  end
163
-
163
+
164
164
  end
165
-
165
+
166
166
  end
167
167
  end
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Feed
5
-
6
- class LinksTest < Test::Unit::TestCase
5
+
6
+ class LinksTest < MiniTest::Test
7
7
  def test_parse_links
8
8
  element_xml = %{
9
9
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -20,7 +20,7 @@ module MingleEvents
20
20
  assert_equal "bug #103", the_links.first.title
21
21
  assert_equal "https://mingle.example.com/api/v2/projects/atlas/cards/104.xml?version=7", the_links.last.href
22
22
  end
23
-
23
+
24
24
  def test_find_by_rel_and_type
25
25
  element_xml = %{
26
26
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -35,6 +35,6 @@ module MingleEvents
35
35
  end
36
36
 
37
37
  end
38
-
38
+
39
39
  end
40
40
  end
@@ -2,32 +2,32 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Feed
5
-
6
- class PageTest < Test::Unit::TestCase
7
-
8
- def test_entries_are_enumerable
5
+
6
+ class PageTest < MiniTest::Test
7
+
8
+ def test_entries_are_enumerable
9
9
  latest_entries_page = Page.new('https://mingle.example.com/api/v2/projects/atlas/feeds/events.xml', stub_mingle_access)
10
-
10
+
11
11
  assert_equal([
12
12
  'https://mingle.example.com/projects/atlas/events/index/103',
13
13
  'https://mingle.example.com/projects/atlas/events/index/101',
14
14
  'https://mingle.example.com/projects/atlas/events/index/100'
15
- ], latest_entries_page.entries.map(&:entry_id))
15
+ ], latest_entries_page.entries.map(&:entry_id))
16
16
  end
17
-
17
+
18
18
  def test_next_page_returns_the_page_of_entries_as_specified_by_next_link
19
19
  latest_entries_page = Page.new('https://mingle.example.com/api/v2/projects/atlas/feeds/events.xml', stub_mingle_access)
20
20
  next_page = latest_entries_page.next
21
21
  assert_equal('https://mingle.example.com/api/v2/projects/atlas/feeds/events.xml?page=2', next_page.url)
22
22
  assert_equal('https://mingle.example.com/projects/atlas/events/index/99', next_page.entries.first.entry_id)
23
23
  end
24
-
24
+
25
25
  def test_next_page_when_on_last_page
26
26
  last_page = Page.new('https://mingle.example.com/api/v2/projects/atlas/feeds/events.xml?page=1', stub_mingle_access)
27
27
  assert_nil(last_page.next)
28
28
  end
29
-
29
+
30
30
  end
31
-
31
+
32
32
  end
33
- end
33
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
2
 
3
3
  module MingleEvents
4
- class MingleBasicAuthAccessTest < Test::Unit::TestCase
4
+ class MingleBasicAuthAccessTest < MiniTest::Test
5
5
  def setup
6
6
  @httpstub = HttpStub.new
7
7
  @access = MingleBasicAuthAccess.new("http://foo.bar.com", "foo", "bar", @httpstub)
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
2
 
3
3
  module MingleEvents
4
- class MingleHmacAccessTest < Test::Unit::TestCase
4
+ class MingleHmacAccessTest < MiniTest::Test
5
5
  def setup
6
6
  @httpstub = HttpStub.new
7
7
  @access = MingleHmacAuthAccess.new("http://foo.bar.com", "login", "api-key", @httpstub)
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
2
 
3
3
  module MingleEvents
4
- class MingleOauthAccessTest < Test::Unit::TestCase
4
+ class MingleOauthAccessTest < MiniTest::Test
5
5
  def setup
6
6
  @httpstub = HttpStub.new
7
7
  @access = MingleOauthAccess.new("http://foo.bar.com", "some-token", @httpstub)
@@ -1,20 +1,20 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
2
 
3
3
  module MingleEvents
4
- class PollerTest < Test::Unit::TestCase
5
-
4
+ class PollerTest < MiniTest::Test
5
+
6
6
  def test_sends_all_events_to_all_processors
7
7
  state_folder = temp_dir
8
8
  mingle_access = stub_mingle_access
9
9
  processor_1 = DummyProcessor.new
10
10
  processor_2 = DummyProcessor.new
11
11
  poller = Poller.new(mingle_access, {'atlas' => [processor_1, processor_2]}, state_folder)
12
-
12
+
13
13
  mingle_access.register_page_content('/api/v2/projects/atlas/feeds/events.xml', EMPTY_EVENTS_XML)
14
14
  poller.run_once
15
- mingle_access.register_page_content('/api/v2/projects/atlas/feeds/events.xml', LATEST_EVENTS_XML)
15
+ mingle_access.register_page_content('/api/v2/projects/atlas/feeds/events.xml', LATEST_EVENTS_XML)
16
16
  poller.run_once
17
-
17
+
18
18
  expected_entry_ids = [
19
19
  'https://mingle.example.com/projects/atlas/events/index/23',
20
20
  'https://mingle.example.com/projects/atlas/events/index/97',
@@ -24,28 +24,28 @@ module MingleEvents
24
24
  'https://mingle.example.com/projects/atlas/events/index/101',
25
25
  'https://mingle.example.com/projects/atlas/events/index/103'
26
26
  ]
27
-
27
+
28
28
  [processor_1, processor_2].each do |processor|
29
29
  assert_equal(expected_entry_ids, processor.processed_events.map(&:entry_id))
30
30
  end
31
31
  end
32
-
33
- class DummyProcessor
34
-
32
+
33
+ class DummyProcessor
34
+
35
35
  def initialize
36
36
  @processed_events = []
37
37
  end
38
-
38
+
39
39
  def process_events(events)
40
40
  @processed_events = @processed_events + events
41
41
  end
42
-
42
+
43
43
  def processed_events
44
44
  @processed_events
45
45
  end
46
-
46
+
47
47
  end
48
-
48
+
49
49
  end
50
-
51
- end
50
+
51
+ end
@@ -2,39 +2,39 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Processors
5
- class AuthorFilterTest < Test::Unit::TestCase
6
-
5
+ class AuthorFilterTest < MiniTest::Test
6
+
7
7
  def setup
8
8
  @dummy_mingle_access = StubMingleAccess.new
9
9
  @dummy_mingle_access.register_page_content(
10
10
  '/api/v2/projects/atlas/team.xml',
11
11
  %{
12
- <projects_members type="array">
13
- <projects_member>
14
- <user url="http://example.com/users/10.xml">
15
- <id type="integer">333</id>
16
- <name>Chester Tester</name>
17
- <login>ctester</login>
12
+ <projects_members type="array">
13
+ <projects_member>
14
+ <user url="http://example.com/users/10.xml">
15
+ <id type="integer">333</id>
16
+ <name>Chester Tester</name>
17
+ <login>ctester</login>
18
18
  <email>chester.tester@example.com</email>
19
19
  </user>
20
20
  </projects_member>
21
- <projects_member>
22
- <user url="http://example.com/users/17.xml">
23
- <id type="integer">444</id>
24
- <name>Joe Developer</name>
25
- <login>jdeveloper</login>
21
+ <projects_member>
22
+ <user url="http://example.com/users/17.xml">
23
+ <id type="integer">444</id>
24
+ <name>Joe Developer</name>
25
+ <login>jdeveloper</login>
26
26
  <email>joe.developer@example.com</email>
27
27
  </user>
28
28
  </projects_member>
29
29
  </projects_members>
30
30
  }
31
31
  )
32
-
32
+
33
33
  @event_1 = stub_event(1, {:uri => "http://example.com/users/10.xml", :login => 'ctester'})
34
34
  @event_2 = stub_event(2, {:uri => "http://example.com/users/17.xml", :login => 'jdeveloper'})
35
35
  @event_3 = stub_event(3, {:uri => "http://example.com/users/10.xml", :login => 'ctester'})
36
36
  end
37
-
37
+
38
38
  def test_filter_can_only_be_constructed_with_a_single_criteria
39
39
  begin
40
40
  AuthorFilter.new({:url => 'foo', :email => 'bar'}, nil, nil)
@@ -43,31 +43,31 @@ module MingleEvents
43
43
  assert_equal(0, e.message.index("Author spec must contain 1 and only 1 piece of criteria"))
44
44
  end
45
45
  end
46
-
46
+
47
47
  def test_match_on_author_url
48
48
  author_filter = AuthorFilter.new({:url => 'http://example.com/users/10.xml'}, @dummy_mingle_access, 'atlas')
49
49
  assert author_filter.match?(@event_1)
50
50
  assert !author_filter.match?(@event_2)
51
51
  end
52
-
52
+
53
53
  def test_match_on_author_login
54
54
  author_filter = AuthorFilter.new({:login => 'ctester'}, @dummy_mingle_access, 'atlas')
55
55
  assert author_filter.match?(@event_1)
56
56
  assert !author_filter.match?(@event_2)
57
57
  end
58
-
58
+
59
59
  def test_match_on_author_email
60
60
  author_filter = AuthorFilter.new({:email => 'joe.developer@example.com'}, @dummy_mingle_access, 'atlas')
61
61
  assert !author_filter.match?(@event_1)
62
62
  assert author_filter.match?(@event_2)
63
63
  end
64
-
64
+
65
65
  private
66
-
66
+
67
67
  def stub_event(entry_id, author)
68
68
  OpenStruct.new(:entry_id => entry_id, :author => OpenStruct.new(author))
69
69
  end
70
-
70
+
71
71
  end
72
72
  end
73
73
  end
@@ -2,21 +2,21 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Processors
5
-
5
+
6
6
  # TODO: better revision resource URIs in tests -- make tests more understandable
7
- class CardDataTest < Test::Unit::TestCase
8
-
7
+ class CardDataTest < MiniTest::Test
8
+
9
9
  def test_load_basic_card_data_in_bulk
10
10
  event_1 = stub_event(1, 100, 11, ['card', 'comment-addition'])
11
11
  event_2 = stub_event(3, nil, nil, ['revision-commit'])
12
12
  event_3 = stub_event(4, 103, 13, ['card', 'property-change'])
13
13
  events = [event_1, event_2, event_3]
14
-
14
+
15
15
  dummy_mingle_access = StubMingleAccess.new
16
16
  dummy_mingle_access.register_page_content(
17
17
  URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (100,103)'),
18
- %{<?xml version="1.0" encoding="UTF-8"?>
19
- <results type="array">
18
+ %{<?xml version="1.0" encoding="UTF-8"?>
19
+ <results type="array">
20
20
  <result>
21
21
  <number>100</number>
22
22
  <card_type_name>story</card_type_name>
@@ -29,10 +29,10 @@ module MingleEvents
29
29
  </result>
30
30
  </results>
31
31
  })
32
-
32
+
33
33
  card_data = CardData.new(dummy_mingle_access, 'atlas')
34
34
  card_data.process_events(events)
35
-
35
+
36
36
  assert_correct_basic_card_data_for_event(
37
37
  {:number => 100, :card_type_name => 'story', :version => 11},
38
38
  card_data, event_1)
@@ -40,15 +40,15 @@ module MingleEvents
40
40
  {:number => 103, :card_type_name => 'bug', :version => 13},
41
41
  card_data, event_3)
42
42
  end
43
-
43
+
44
44
  def test_load_custom_properties
45
45
  event_1 = stub_event(1, 100, 11, ['card', 'comment-addition'])
46
-
46
+
47
47
  dummy_mingle_access = StubMingleAccess.new
48
48
  dummy_mingle_access.register_page_content(
49
49
  URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (100)'),
50
- %{<?xml version="1.0" encoding="UTF-8"?>
51
- <results type="array">
50
+ %{<?xml version="1.0" encoding="UTF-8"?>
51
+ <results type="array">
52
52
  <result>
53
53
  <number>100</number>
54
54
  <card_type_name>story</card_type_name>
@@ -59,30 +59,30 @@ module MingleEvents
59
59
  </result>
60
60
  </results>
61
61
  })
62
-
62
+
63
63
  dummy_custom_properties = StubProjectCustomProperties.new({
64
64
  'cp_priority' => 'Foo', 'cp_estimate' => 'Bar', 'cp_completed_on' => 'Completed On'
65
65
  })
66
-
66
+
67
67
  card_data = CardData.new(dummy_mingle_access, 'atlas', dummy_custom_properties)
68
68
  card_data.process_events([event_1])
69
-
69
+
70
70
  assert_equal("Low", card_data.for_card_event(event_1)[:custom_properties]['Foo'])
71
- assert_equal("5", card_data.for_card_event(event_1)[:custom_properties]['Bar'])
72
- assert_nil card_data.for_card_event(event_1)[:custom_properties]['Completed On']
71
+ assert_equal("5", card_data.for_card_event(event_1)[:custom_properties]['Bar'])
72
+ assert_nil card_data.for_card_event(event_1)[:custom_properties]['Completed On']
73
73
  end
74
-
74
+
75
75
  def test_load_basic_card_data_when_card_has_been_updated_beyond_the_specific_event
76
76
  event_1 = stub_event(1, 100, 11, ['card', 'comment-addition'])
77
77
  event_2 = stub_event(3, nil, nil, ['revision-commit'])
78
78
  event_3 = stub_event(4, 103, 13, ['card', 'property-change'])
79
79
  events = [event_1, event_2, event_3]
80
-
80
+
81
81
  dummy_mingle_access = StubMingleAccess.new
82
82
  dummy_mingle_access.register_page_content(
83
83
  URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (100,103)'),
84
- %{<?xml version="1.0" encoding="UTF-8"?>
85
- <results type="array">
84
+ %{<?xml version="1.0" encoding="UTF-8"?>
85
+ <results type="array">
86
86
  <result>
87
87
  <number>100</number>
88
88
  <card_type_name>story</card_type_name>
@@ -97,17 +97,17 @@ module MingleEvents
97
97
  })
98
98
  dummy_mingle_access.register_page_content('http://example.com?version=13',%{
99
99
  <card>
100
- <number type="integer">103</number>
101
- <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/21.xml">
102
- <name>epic</name>
103
- </card_type>
104
- <version type="integer">13</version>
100
+ <number type="integer">103</number>
101
+ <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/21.xml">
102
+ <name>epic</name>
103
+ </card_type>
104
+ <version type="integer">13</version>
105
105
  </card>
106
106
  })
107
-
107
+
108
108
  card_data = CardData.new(dummy_mingle_access, 'atlas')
109
109
  card_data.process_events(events)
110
-
110
+
111
111
  assert_correct_basic_card_data_for_event(
112
112
  {:number => 100, :card_type_name => 'story', :version => 11},
113
113
  card_data, event_1)
@@ -115,16 +115,16 @@ module MingleEvents
115
115
  {:number => 103, :card_type_name => 'epic', :version => 13},
116
116
  card_data, event_3)
117
117
  end
118
-
118
+
119
119
  def test_load_custom_properties_when_card_has_been_updated_beyond_the_specific_event
120
120
  event_1 = stub_event(1, 100, 11, ['card', 'comment-addition'])
121
121
  events = [event_1]
122
-
122
+
123
123
  dummy_mingle_access = StubMingleAccess.new
124
124
  dummy_mingle_access.register_page_content(
125
125
  URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (100)'),
126
- %{<?xml version="1.0" encoding="UTF-8"?>
127
- <results type="array">
126
+ %{<?xml version="1.0" encoding="UTF-8"?>
127
+ <results type="array">
128
128
  <result>
129
129
  <number>100</number>
130
130
  <card_type_name>story</card_type_name>
@@ -137,10 +137,10 @@ module MingleEvents
137
137
  dummy_mingle_access.register_page_content('http://example.com?version=11',
138
138
  %{
139
139
  <card>
140
- <number type="integer">101</number>
141
- <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/24.xml">
142
- <name>issue</name>
143
- </card_type>
140
+ <number type="integer">101</number>
141
+ <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/24.xml">
142
+ <name>issue</name>
143
+ </card_type>
144
144
  <version type="integer">11</version>
145
145
  <properties type="array">
146
146
  <property type_description="Managed text list" hidden="false">
@@ -155,70 +155,70 @@ module MingleEvents
155
155
  </card>
156
156
  }
157
157
  )
158
-
158
+
159
159
  dummy_custom_properties = StubProjectCustomProperties.new({'cp_priority' => 'Priority', 'cp_feature' => 'Feature'})
160
-
160
+
161
161
  card_data = CardData.new(dummy_mingle_access, 'atlas', dummy_custom_properties)
162
162
  card_data.process_events(events)
163
-
163
+
164
164
  assert_equal 'High', card_data.for_card_event(event_1)[:custom_properties]['Priority']
165
165
  assert_nil card_data.for_card_event(event_1)[:custom_properties]['Feature']
166
166
  end
167
-
167
+
168
168
  def test_load_card_data_when_card_has_been_deleted_before_event_processing
169
169
  event_1 = stub_event(1, 100, 11, ['card', 'comment-addition'])
170
170
  events = [event_1]
171
-
171
+
172
172
  dummy_mingle_access = StubMingleAccess.new
173
173
  dummy_mingle_access.register_page_content(
174
174
  URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (100)'),
175
- %{<?xml version="1.0" encoding="UTF-8"?>
176
- <results type="array">
175
+ %{<?xml version="1.0" encoding="UTF-8"?>
176
+ <results type="array">
177
177
  </results>
178
178
  })
179
179
  dummy_mingle_access.register_page_not_found('http://example.com?version=11')
180
-
180
+
181
181
  card_data = CardData.new(dummy_mingle_access, 'atlas')
182
182
  card_data.process_events(events)
183
-
183
+
184
184
  assert_nil(card_data.for_card_event(event_1))
185
185
  end
186
-
186
+
187
187
  def test_survives_bulk_load_exploding
188
188
  event = stub_event(4, 103, 13, ['card', 'property-change'])
189
-
189
+
190
190
  dummy_mingle_access = StubMingleAccess.new
191
191
  dummy_mingle_access.register_explosion(URIParser.escape('/api/v2/projects/atlas/cards/execute_mql.xml?mql=WHERE number IN (103)'))
192
192
 
193
193
  dummy_mingle_access.register_page_content('http://example.com?version=13',%{
194
194
  <card>
195
- <number type="integer">103</number>
196
- <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/21.xml">
197
- <name>epic</name>
198
- </card_type>
199
- <version type="integer">13</version>
195
+ <number type="integer">103</number>
196
+ <card_type url="https://localhost:7071/api/v2/projects/atlas/card_types/21.xml">
197
+ <name>epic</name>
198
+ </card_type>
199
+ <version type="integer">13</version>
200
200
  </card>
201
201
  })
202
-
202
+
203
203
  card_data = CardData.new(dummy_mingle_access, 'atlas')
204
204
  card_data.process_events([event])
205
-
205
+
206
206
  assert_correct_basic_card_data_for_event({:number => 103, :card_type_name => 'epic', :version => 13}, card_data, event)
207
207
  end
208
-
209
-
210
- private
211
-
208
+
209
+
210
+ private
211
+
212
212
  def stub_event(entry_id, card_number, version, categories)
213
213
  OpenStruct.new(
214
- :entry_id => entry_id,
215
- :card_number => card_number,
214
+ :entry_id => entry_id,
215
+ :card_number => card_number,
216
216
  :card? => !card_number.nil?,
217
217
  :version => version,
218
218
  :card_version_resource_uri => "http://example.com?version=#{version}",
219
219
  :categories => categories.map{|c| OpenStruct.new(:term => c)})
220
220
  end
221
-
221
+
222
222
  def assert_correct_basic_card_data_for_event(expected_data, actual_card_data, card_event)
223
223
  assert_equal(expected_data, actual_card_data.for_card_event(card_event).delete_if{|k,v| k == :custom_properties})
224
224
  end