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
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MGFjZmRmMTUzNDBmYmMyMjZkOGFjZTQwNmQwZGJkYmI3ZWJkM2U3Nw==
5
- data.tar.gz: !binary |-
6
- Y2U5ZjVlNDQ0NDRlMTAxNjE3MGY2ZWVlYjgyNTgzODA2YzBjYWU1ZQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MjYwN2U0MzZiZmNkMzk5NzljZmY0NGRmMWJkNjZiNzY2NjBlY2JiNjk1N2E5
10
- NTBiNzMyYmViYThkNzA3NTUzNjE0ZWRkNTA4MjA2NDczZDFmMmNjOTc4NTk4
11
- OTIxNDA0ZjE3MGRhYzc3NDYwNTBkYjZlYmI3MzVjZWQxZWI2NzQ=
12
- data.tar.gz: !binary |-
13
- NmFlNDE0N2ViZTQ4NmFlY2ZhZGU4ZTRkYjQzMzY4ODVmODAyMjdlNDUzMzRm
14
- ODFiY2JiYzM4OTdhZDNmMTY5OWYxNTg1NmZjNzFhYzVkZjc5YjEyYjNiZGMz
15
- NTc0MjMzNjJkNDAwN2VjM2RlMDE1YTRlYTUzYjZiZmRiMTI1YTc=
2
+ SHA1:
3
+ metadata.gz: db8c244cc6b0a5038dcc12a40e478906098cfb7d
4
+ data.tar.gz: 0cebb359a4b5bd057fe2e6ea794ebe4645c3e756
5
+ SHA512:
6
+ metadata.gz: b8e7269e1250643f31c4310f5f1dc37c82945ee0d0b47929a18422c0b4f5a1459cc2a4d7b51020962f4bc994a722d1d1548c79164a6a8ee21ba4f84b1a6a0967
7
+ data.tar.gz: 7b37839e548eefbdbd0b599a5e78ea1e3ab3485bcf84dfe6f9db3769ed2c05cdadbfb4883038862e519a3b688e7997ded85463bf7e94104efbe3c44b8d32a647
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
@@ -1,48 +1,48 @@
1
1
  module MingleEvents
2
2
  module Feed
3
-
3
+
4
4
  # An Atom category, with a term and a scheme. Note that an Atom
5
5
  # event can have any number of categories, including zero.
6
6
  # All current Mingle categories are also defined here, as constants.
7
7
  class Category
8
-
8
+
9
9
  @@categories_by_mingle_term = {}
10
-
10
+
11
11
  # The category's term
12
12
  attr_reader :term
13
13
  # The category's scheme
14
14
  attr_reader :scheme
15
-
15
+
16
16
  def initialize(term, scheme)
17
17
  @term = term
18
18
  @scheme = scheme
19
19
  @@categories_by_mingle_term[term] = self
20
20
  end
21
-
21
+
22
22
  # lookup a category by the text value of the term (mingle scheme is assumed)
23
23
  def self.for_mingle_term(mingle_term)
24
24
  @@categories_by_mingle_term[mingle_term]
25
25
  end
26
-
26
+
27
27
  def to_s
28
28
  term
29
29
  end
30
-
30
+
31
31
  def ==(other)
32
- other.is_a?(Category) && other.term == self.term && other.scheme == self.scheme
32
+ other.is_a?(Category) && other.term == self.term && other.scheme == self.scheme
33
33
  end
34
-
34
+
35
35
  def hash
36
36
  term.hash ^ scheme.hash
37
37
  end
38
-
38
+
39
39
  def eql?(other)
40
40
  self == other
41
41
  end
42
-
42
+
43
43
  # The Atom category scheme for all Mingle categories
44
44
  MINGLE_SCHEME = 'http://www.thoughtworks-studios.com/ns/mingle#categories'
45
-
45
+
46
46
  # Category for any event sourced by a card
47
47
  CARD = Category.new('card', MINGLE_SCHEME)
48
48
  # Category for any event that is the creation of a new card
@@ -59,12 +59,25 @@ module MingleEvents
59
59
  COMMENT_ADDITION = Category.new('comment-addition', MINGLE_SCHEME)
60
60
  # Category for any event that incldues the Mingle server's adding a comment to a card
61
61
  SYSTEM_COMMENT_ADDITION = Category.new('system-comment-addition', MINGLE_SCHEME)
62
-
62
+
63
+ # For correction events:
64
+ MANAGED_PROPERTY_VALUE_CHANGE = Category.new("managed-property-value-change", MINGLE_SCHEME)
65
+ PROPERTY_RENAME = Category.new("property-rename", MINGLE_SCHEME)
66
+ TAG_RENAME = Category.new("tag-rename", MINGLE_SCHEME)
67
+ PROPERTY_DELETION = Category.new("property-deletion", MINGLE_SCHEME)
68
+ CARD_TYPE_RENAME = Category.new("card-type-rename", MINGLE_SCHEME)
69
+ CARD_TYPE_DELETION = Category.new("card-type-deletion", MINGLE_SCHEME)
70
+ CARD_TYPE_AND_PROPERTY_DISASSOCIATION = Category.new("card-type-and-property-disassociation", MINGLE_SCHEME)
71
+ CARD_KEYWORDS_CHANGE = Category.new("card-keywords-change", MINGLE_SCHEME)
72
+ NUMERIC_PRECISION_CHANGE = Category.new("numeric-precision-change", MINGLE_SCHEME)
73
+ REPOSITORY_SETTINGS_CHANGE = Category.new("repository-settings-change", MINGLE_SCHEME)
74
+
75
+
63
76
  # Category for any event sourced by a wiki page
64
77
  PAGE = Category.new('page', MINGLE_SCHEME)
65
78
  # Category for any event that is the creation of a new wiki page
66
79
  PAGE_CREATION = Category.new('page-creation', MINGLE_SCHEME)
67
-
80
+
68
81
  # Category for any event that includes a card or page name change
69
82
  NAME_CHANGE = Category.new('name-change', MINGLE_SCHEME)
70
83
  # Category for any event that includes a card or page description/content change
@@ -79,11 +92,11 @@ module MingleEvents
79
92
  ATTACHMENT_REMOVAL = Category.new('attachment-removal', MINGLE_SCHEME)
80
93
  # Category for any event that includes the replacement of an attachment on a card or page
81
94
  ATTACHMENT_REPLACEMENT = Category.new('attachment-replacement', MINGLE_SCHEME)
82
-
95
+
83
96
  # Category for any event that is a revision or changeset commit
84
97
  REVISION_COMMIT = Category.new('revision-commit', MINGLE_SCHEME)
85
-
98
+
86
99
  end
87
-
100
+
88
101
  end
89
- end
102
+ end
@@ -33,7 +33,6 @@ module MingleEvents
33
33
 
34
34
  def build(element)
35
35
  raw_hash_from_xml = element.to_hash
36
-
37
36
  raw_hash_from_xml[:change].merge({
38
37
  :category => @category,
39
38
  :type => @category
@@ -1,26 +1,26 @@
1
1
  module MingleEvents
2
2
  module Processors
3
-
3
+
4
4
  # Filters events by card types. As events do not contain the type
5
- # of the card, this filter requires a lookup against Mingle to
5
+ # of the card, this filter requires a lookup against Mingle to
6
6
  # determine the type of the card that sourced the event. In the case
7
7
  # of the card's being deleted in the interim between the actual event
8
8
  # and this filtering, the event will be filtered as there is no means
9
9
  # to determine its type. Therefore, it's recommended to also
10
- # subscribe a 'CardDeleted' processor to the same project.
10
+ # subscribe a 'CardDeleted' processor to the same project.
11
11
  class CardTypeFilter < Filter
12
-
12
+
13
13
  def initialize(card_types, card_data)
14
14
  @card_types = card_types
15
15
  @card_data = card_data
16
16
  end
17
-
17
+
18
18
  def match?(event)
19
- event.card? &&
19
+ event.card? &&
20
20
  @card_data.for_card_event(event) &&
21
21
  @card_types.include?(@card_data.for_card_event(event)[:card_type_name])
22
22
  end
23
-
23
+
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -28,7 +28,7 @@ module MingleEvents
28
28
 
29
29
  def inner_text(element, xpath=nil)
30
30
  return inner_text(select(element, xpath)) if xpath
31
- return nil if attr(element, "nil") && attr(element, "nil") == "true"
31
+ return nil if attr(element, "nil") == "true"
32
32
  element.node.inner_text
33
33
  end
34
34
 
@@ -69,22 +69,28 @@ module MingleEvents
69
69
  end
70
70
  end
71
71
 
72
- def to_hash(element, hash={})
73
- hash_for_element = (hash[tag_name(element).to_sym] ||= {})
72
+ def to_hash(element)
73
+ { tag_name(element).to_sym => to_hash_attributes(element) }
74
+ end
74
75
 
75
- attributes(element).each do |name, value|
76
- hash_for_element[name.to_sym] = value
76
+ def to_hash_attributes(element)
77
+ attrs = attributes(element).inject({}) do |memo, pair|
78
+ name, value = pair
79
+ memo[name.to_sym] = value
80
+ memo
77
81
  end
78
82
 
79
- children(element).each do |child|
80
- if children(child).any?
81
- to_hash(child, hash_for_element)
82
- else
83
- hash_for_element[tag_name(child).to_sym] = inner_text(child)
83
+ return nil if attrs[:nil] == "true"
84
+
85
+ children = children(element)
86
+ if children.any?
87
+ return children.inject(attrs) do |memo, child|
88
+ memo[ tag_name(child).to_sym ] = to_hash_attributes(child)
89
+ memo
84
90
  end
85
91
  end
86
-
87
- hash
92
+ inner_text = inner_text(element)
93
+ inner_text && inner_text != "" ? inner_text : attrs
88
94
  end
89
95
 
90
96
  def patching_namespaces(node)
@@ -1,6 +1,6 @@
1
1
  module MingleEvents
2
2
  class ZipDirectory
3
-
3
+
4
4
  def initialize(name)
5
5
  FileUtils.mkdir_p(File.dirname(name))
6
6
  @root = name
@@ -10,7 +10,7 @@ module MingleEvents
10
10
 
11
11
  def write_file(path, &block)
12
12
  measure('write_file') do
13
- exists = File.exists?(@root) && File.lstat(@root).size > 1024
13
+ exists = File.exist?(@root) && File.lstat(@root).size > 1024
14
14
  writeio = File.open(@root, exists ? 'r+b' : 'wb')
15
15
  # for a existing tar, seek to -1024 from end to skip 1024 '\0' in tar format
16
16
  writeio.seek(-1024, IO::SEEK_END) if exists
@@ -30,7 +30,7 @@ module MingleEvents
30
30
  end
31
31
 
32
32
  def exists?(path)
33
- return unless File.exists?(@root)
33
+ return unless File.exist?(@root)
34
34
  entry_map.include?(path)
35
35
  end
36
36
 
@@ -66,16 +66,16 @@ module MingleEvents
66
66
 
67
67
  def entry_map
68
68
  return @entry_map if @entry_map
69
-
69
+
70
70
  @entry_map = {}
71
71
  measure("entries archive loading") do
72
72
  @readio = File.open(@root, 'rb')
73
73
  loop do
74
74
  break if @readio.eof?
75
-
75
+
76
76
  header = Archive::Tar::PosixHeader.new_from_stream(@readio)
77
77
  break if header.empty?
78
-
78
+
79
79
  entry = ReusableEntryStream.new(header, @readio)
80
80
  size = entry.size
81
81
  @entry_map[entry.name] = entry
@@ -1,13 +1,13 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
2
 
3
3
  module MingleEvents
4
- class EntryCacheTest < Test::Unit::TestCase
5
-
4
+ class EntryCacheTest < MiniTest::Test
5
+
6
6
  def setup
7
7
  @entry_cache = EntryCache.new("/tmp/foo")
8
8
  @entry_cache.clear
9
9
  end
10
-
10
+
11
11
  def test_stores_first_entry_under_root
12
12
  fetched_entry = entry(1)
13
13
  @entry_cache.write(fetched_entry, nil)
@@ -49,11 +49,11 @@ module MingleEvents
49
49
  assert_equal entry(1), enumerator.next()
50
50
  assert_equal entry(2), enumerator.next()
51
51
  assert_equal entry(3), enumerator.next()
52
- assert_raise(StopIteration) { enumerator.next() }
52
+ assert_raises(StopIteration) { enumerator.next() }
53
53
  end
54
-
54
+
55
55
  private
56
-
56
+
57
57
  def entry(id)
58
58
  element_xml_text = %{
59
59
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -69,7 +69,7 @@ module MingleEvents
69
69
  }
70
70
  Feed::Entry.from_snippet(element_xml_text)
71
71
  end
72
-
73
-
72
+
73
+
74
74
  end
75
75
  end
@@ -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 AuthorTest < Test::Unit::TestCase
7
-
5
+
6
+ class AuthorTest < MiniTest::Test
7
+
8
8
  def test_parse_attributes
9
9
  author_xml = %{
10
10
  <author xmlns="http://www.w3.org/2005/Atom" xmlns:mingle="http://www.thoughtworks-studios.com/ns/mingle">
@@ -13,14 +13,14 @@ module MingleEvents
13
13
  <uri>https://mingle.example.com/api/v2/users/233.xml</uri>
14
14
  <mingle:icon>https://mingle.example.com/user/icon/233/profile.jpg</mingle:icon>
15
15
  </author>
16
- }
16
+ }
17
17
  author = Author.from_snippet(author_xml)
18
18
  assert_equal("Sammy Soso", author.name)
19
19
  assert_equal("sammy@example.com", author.email)
20
20
  assert_equal("https://mingle.example.com/api/v2/users/233.xml", author.uri)
21
21
  assert_equal("https://mingle.example.com/user/icon/233/profile.jpg", author.icon_uri)
22
22
  end
23
-
23
+
24
24
  def test_parse_attributes_when_no_optional_fields
25
25
  author_xml = %{
26
26
  <author xmlns="http://www.w3.org/2005/Atom" xmlns:mingle="http://www.thoughtworks-studios.com/ns/mingle">
@@ -33,8 +33,8 @@ module MingleEvents
33
33
  assert_nil(author.uri)
34
34
  assert_nil(author.icon_uri)
35
35
  end
36
-
36
+
37
37
  end
38
-
38
+
39
39
  end
40
40
  end
@@ -2,10 +2,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_hel
2
2
 
3
3
  module MingleEvents
4
4
  module Feed
5
-
6
- class CategoryTest < Test::Unit::TestCase
7
-
8
- def test_equality
5
+
6
+ class CategoryTest < MiniTest::Test
7
+
8
+ def test_equality
9
9
  assert_equal(Category::CARD, Category::CARD)
10
10
  assert_equal(Category::CARD, Category.new('card', 'http://www.thoughtworks-studios.com/ns/mingle#categories'))
11
11
  assert_not_equal(Category::CARD, Category::PAGE)
@@ -13,12 +13,12 @@ module MingleEvents
13
13
  assert_not_equal(Category::CARD, Object.new)
14
14
  assert_equal(:foo, {Category::CARD => :foo}[Category.new('card', 'http://www.thoughtworks-studios.com/ns/mingle#categories')])
15
15
  end
16
-
16
+
17
17
  def test_can_lookup_by_mingle_term
18
18
  assert_equal(Category::CARD_CREATION, Category.for_mingle_term('card-creation'))
19
19
  end
20
-
20
+
21
21
  end
22
-
22
+
23
23
  end
24
- end
24
+ end
@@ -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 ChangesTest < Test::Unit::TestCase
7
-
5
+
6
+ class ChangesTest < MiniTest::Test
7
+
8
8
  def test_parse_multiple_changes
9
9
  element_xml_text = %{
10
10
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -27,18 +27,18 @@ module MingleEvents
27
27
  </content>
28
28
  </entry>}
29
29
  entry = Entry.from_snippet(element_xml_text)
30
-
30
+
31
31
  # check that all the changes are built
32
- assert_equal 3, entry.changes.count
32
+ assert_equal 3, entry.changes.count
33
33
  [Category::CARD_CREATION, Category::CARD_TYPE_CHANGE, Category::NAME_CHANGE].each do |change_type|
34
34
  assert entry.changes.find{|c| c[:category] == change_type}
35
35
  end
36
-
36
+
37
37
  # check that a change's detail is built
38
38
  card_type_change = entry.changes.find{|c| c[:category] == Category::CARD_TYPE_CHANGE}
39
39
  assert_equal('Defect', card_type_change[:new_value][:card_type][:name])
40
40
  end
41
-
41
+
42
42
  def test_parse_name_change_from_nil
43
43
  element_xml_text = %{
44
44
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -52,14 +52,14 @@ module MingleEvents
52
52
  </content>
53
53
  </entry>}
54
54
  entry = Entry.from_snippet(element_xml_text)
55
-
55
+
56
56
  change = entry.changes.first
57
57
  assert_equal(Category::NAME_CHANGE, change[:type])
58
58
  assert_equal(Category::NAME_CHANGE, change[:category])
59
59
  assert_nil change[:old_value]
60
60
  assert_equal("Basic email integration", change[:new_value])
61
61
  end
62
-
62
+
63
63
  def test_parse_name_change
64
64
  element_xml_text = %{
65
65
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -73,14 +73,14 @@ module MingleEvents
73
73
  </content>
74
74
  </entry>}
75
75
  entry = Entry.from_snippet(element_xml_text)
76
-
77
- change = entry.changes.first
76
+
77
+ change = entry.changes.first
78
78
  assert_equal(Category::NAME_CHANGE, change[:type])
79
79
  assert_equal(Category::NAME_CHANGE, change[:category])
80
80
  assert_equal("Work with email", change[:old_value])
81
- assert_equal("Basic email integration", change[:new_value])
81
+ assert_equal("Basic email integration", change[:new_value])
82
82
  end
83
-
83
+
84
84
  def test_parse_type_info_when_no_custom_builder_specified
85
85
  element_xml_text = %{
86
86
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -91,11 +91,11 @@ module MingleEvents
91
91
  </content>
92
92
  </entry>}
93
93
  entry = Entry.from_snippet(element_xml_text)
94
-
94
+
95
95
  assert_equal(Category::CARD_CREATION, entry.changes.first[:type])
96
96
  assert_equal(Category::CARD_CREATION, entry.changes.first[:category])
97
97
  end
98
-
98
+
99
99
  def test_parse_card_type_change_from_nil
100
100
  element_xml_text = %{
101
101
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -113,16 +113,16 @@ module MingleEvents
113
113
  </content>
114
114
  </entry>}
115
115
  entry = Entry.from_snippet(element_xml_text)
116
-
116
+
117
117
  change = entry.changes.first
118
-
118
+
119
119
  assert_equal(Category::CARD_TYPE_CHANGE, change[:type])
120
120
  assert_equal(Category::CARD_TYPE_CHANGE, change[:category])
121
121
  assert_nil change[:old_value]
122
122
  assert_equal("Defect", change[:new_value][:card_type][:name])
123
123
  assert_equal("https://mingle.example.com/api/v2/projects/atlas/card_types/27.xml", change[:new_value][:card_type][:url])
124
124
  end
125
-
125
+
126
126
  def test_parse_card_type_change
127
127
  element_xml_text = %{
128
128
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -144,7 +144,7 @@ module MingleEvents
144
144
  </content>
145
145
  </entry>}
146
146
  entry = Entry.from_snippet(element_xml_text)
147
-
147
+
148
148
  change = entry.changes.first
149
149
  assert_equal(Category::CARD_TYPE_CHANGE, change[:type])
150
150
  assert_equal(Category::CARD_TYPE_CHANGE, change[:category])
@@ -153,7 +153,7 @@ module MingleEvents
153
153
  assert_equal("Defect", change[:new_value][:card_type][:name])
154
154
  assert_equal("https://mingle.example.com/api/v2/projects/atlas/card_types/27.xml", change[:new_value][:card_type][:url])
155
155
  end
156
-
156
+
157
157
  def test_parse_card_type_change_to_deleted_type
158
158
  element_xml_text = %{
159
159
  <entry xmlns="http://www.w3.org/2005/Atom">
@@ -175,7 +175,7 @@ module MingleEvents
175
175
  </content>
176
176
  </entry>}
177
177
  entry = Entry.from_snippet(element_xml_text)
178
-
178
+
179
179
  change = entry.changes.first
180
180
  assert_equal(Category::CARD_TYPE_CHANGE, change[:type])
181
181
  assert_equal(Category::CARD_TYPE_CHANGE, change[:category])
@@ -183,15 +183,15 @@ module MingleEvents
183
183
  assert_equal("https://mingle.example.com/api/v2/projects/atlas/card_types/30.xml", change[:old_value][:card_type][:url])
184
184
  assert_equal("Card", change[:new_value][:deleted_card_type][:name])
185
185
  assert_equal(nil, change[:new_value][:deleted_card_type][:url])
186
- end
187
-
186
+ end
187
+
188
188
  def test_parse_card_property_change
189
189
  element_xml_text = %{
190
190
  <entry xmlns="http://www.w3.org/2005/Atom">
191
191
  <content type="application/vnd.mingle+xml">
192
192
  <changes xmlns="http://www.thoughtworks-studios.com/ns/mingle">
193
193
  <change type="property-change">
194
- <property_definition
194
+ <property_definition
195
195
  url="http://mingle.example.com/api/v2/projects/atlas/property_definitions/10418.xml">
196
196
  <name>Priority</name>
197
197
  <position nil="true"></position>
@@ -205,26 +205,26 @@ module MingleEvents
205
205
  </content>
206
206
  </entry>}
207
207
  entry = Entry.from_snippet(element_xml_text)
208
-
208
+
209
209
  change = entry.changes.first
210
210
  assert_equal(Category::PROPERTY_CHANGE, change[:type])
211
211
  assert_equal(Category::PROPERTY_CHANGE, change[:category])
212
212
  assert_equal(
213
- "http://mingle.example.com/api/v2/projects/atlas/property_definitions/10418.xml",
213
+ "http://mingle.example.com/api/v2/projects/atlas/property_definitions/10418.xml",
214
214
  change[:property_definition][:url]
215
215
  )
216
216
  assert_equal("Priority", change[:property_definition][:name])
217
217
  assert_equal("nice", change[:old_value])
218
218
  assert_equal("must", change[:new_value])
219
- end
220
-
219
+ end
220
+
221
221
  def test_parse_card_property_change_from_nil
222
222
  element_xml_text = %{
223
223
  <entry xmlns="http://www.w3.org/2005/Atom">
224
224
  <content type="application/vnd.mingle+xml">
225
225
  <changes xmlns="http://www.thoughtworks-studios.com/ns/mingle">
226
226
  <change type="property-change">
227
- <property_definition
227
+ <property_definition
228
228
  url="http://mingle.example.com/api/v2/projects/atlas/property_definitions/10418.xml">
229
229
  <name>Priority</name>
230
230
  <position nil="true"></position>
@@ -238,19 +238,19 @@ module MingleEvents
238
238
  </content>
239
239
  </entry>}
240
240
  entry = Entry.from_snippet(element_xml_text)
241
-
241
+
242
242
  change = entry.changes.first
243
243
  assert_nil(change[:old_value])
244
244
  assert_equal("must", change[:new_value])
245
- end
246
-
245
+ end
246
+
247
247
  def test_parse_card_property_change_to_nil
248
248
  element_xml_text = %{
249
249
  <entry xmlns="http://www.w3.org/2005/Atom">
250
250
  <content type="application/vnd.mingle+xml">
251
251
  <changes xmlns="http://www.thoughtworks-studios.com/ns/mingle">
252
252
  <change type="property-change">
253
- <property_definition
253
+ <property_definition
254
254
  url="http://mingle.example.com/api/v2/projects/atlas/property_definitions/10418.xml">
255
255
  <name>Priority</name>
256
256
  <position nil="true"></position>
@@ -264,12 +264,62 @@ module MingleEvents
264
264
  </content>
265
265
  </entry>}
266
266
  entry = Entry.from_snippet(element_xml_text)
267
-
267
+
268
268
  change = entry.changes.first
269
269
  assert_equal("nice", change[:old_value])
270
270
  assert_nil(change[:new_value])
271
- end
272
-
273
- end
271
+ end
272
+
273
+ def test_parse_enumeration_name_change
274
+ element_xml_text = %{
275
+ <entry xmlns="http://www.w3.org/2005/Atom">
276
+ <content type="application/vnd.mingle+xml">
277
+ <changes xmlns="http://www.thoughtworks-studios.com/ns/mingle">
278
+ <change type="managed-property-value-change">
279
+ <property_definition url="https://mingle.mingle.thoughtworks.com/api/v2/projects/your_first_project/property_definitions/16348.xml"/>
280
+ <old_value>Testing</old_value>
281
+ <new_value>Verify</new_value>
282
+ </change>
283
+ </changes>
284
+ </content>
285
+ </entry>}
286
+ entry = Entry.from_snippet(element_xml_text)
287
+
288
+ change = entry.changes.first
289
+ assert_equal(Category::MANAGED_PROPERTY_VALUE_CHANGE, change[:type])
290
+ assert_equal(Category::MANAGED_PROPERTY_VALUE_CHANGE, change[:category])
291
+
292
+ assert_equal("https://mingle.mingle.thoughtworks.com/api/v2/projects/your_first_project/property_definitions/16348.xml", change[:property_definition][:url])
293
+ assert_equal('Testing', change[:old_value])
294
+ assert_equal("Verify", change[:new_value])
295
+ end
296
+
297
+ def test_parse_value_with_special_characters
298
+ element_xml_text = %{
299
+ <entry xmlns="http://www.w3.org/2005/Atom">
300
+ <content type="application/vnd.mingle+xml">
301
+ <changes xmlns="http://www.thoughtworks-studios.com/ns/mingle">
302
+ <change type="property-change">
303
+ <property_definition url="https://mingle.mingle-staging.thoughtworks.com/api/v2/projects/mingle1/property_definitions/10088.xml">
304
+ <name>Priority</name>
305
+ <position nil="true"></position>
306
+ <data_type>string</data_type>
307
+ <is_numeric type="boolean">false</is_numeric>
308
+ </property_definition>
309
+ <old_value nil="true"></old_value>
310
+ <new_value>&#160;</new_value>
311
+ </change>
312
+ </changes>
313
+ </content>
314
+ </entry>}
315
+ entry = Entry.from_snippet(element_xml_text)
316
+
317
+ change = entry.changes.first
318
+ assert_equal("\u00A0", change[:new_value])
319
+ assert_equal(nil, change[:old_value])
320
+ end
321
+
322
+ end
323
+
274
324
  end
275
325
  end