jiralicious 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/.document +5 -5
  2. data/.gitignore +11 -11
  3. data/.rspec +1 -1
  4. data/.ruby-gemset +1 -1
  5. data/.travis.yml +10 -10
  6. data/Gemfile +4 -4
  7. data/LICENSE +22 -22
  8. data/README.md +99 -94
  9. data/Rakefile +16 -16
  10. data/gemfiles/newest.gemfile +3 -3
  11. data/gemfiles/oldest.gemfile +6 -6
  12. data/jiralicious.gemspec +37 -37
  13. data/lib/jiralicious.rb +2 -0
  14. data/lib/jiralicious/base.rb +226 -226
  15. data/lib/jiralicious/component.rb +103 -0
  16. data/lib/jiralicious/custom_field_option.rb +45 -45
  17. data/lib/jiralicious/errors.rb +27 -27
  18. data/lib/jiralicious/field.rb +58 -58
  19. data/lib/jiralicious/issue/fields.rb +197 -197
  20. data/lib/jiralicious/issue/watchers.rb +92 -92
  21. data/lib/jiralicious/project.rb +116 -64
  22. data/lib/jiralicious/session.rb +61 -61
  23. data/lib/jiralicious/version.rb +4 -4
  24. data/lib/jiralicious/versions.rb +150 -0
  25. data/spec/components_spec.rb +74 -0
  26. data/spec/configuration_spec.rb +41 -41
  27. data/spec/field_parser_spec.rb +73 -73
  28. data/spec/fixtures/avatar.json +6 -6
  29. data/spec/fixtures/avatar_custom.json +15 -15
  30. data/spec/fixtures/avatar_list.json +15 -15
  31. data/spec/fixtures/avatar_temp.json +6 -6
  32. data/spec/fixtures/comment_single.json +28 -28
  33. data/spec/fixtures/component.json +39 -0
  34. data/spec/fixtures/component_ric.json +4 -0
  35. data/spec/fixtures/component_updated.json +39 -0
  36. data/spec/fixtures/jira.yml +7 -7
  37. data/spec/fixtures/project_componets.json +80 -0
  38. data/spec/fixtures/project_versions.json +22 -0
  39. data/spec/fixtures/test.json +23 -23
  40. data/spec/fixtures/version.json +11 -0
  41. data/spec/fixtures/version_ric.json +5 -0
  42. data/spec/fixtures/version_uic.json +4 -0
  43. data/spec/fixtures/version_updated.json +11 -0
  44. data/spec/issue_spec.rb +385 -385
  45. data/spec/jiralicious_spec.rb +16 -16
  46. data/spec/project_spec.rb +25 -2
  47. data/spec/search_result_spec.rb +54 -54
  48. data/spec/support/configuration.rb +11 -11
  49. data/spec/support/http.rb +147 -111
  50. data/spec/versions_spec.rb +84 -0
  51. metadata +189 -170
  52. checksums.yaml +0 -7
@@ -1,4 +1,4 @@
1
- module Jiralicious
2
- # Current Jiralicious Version
3
- VERSION = "0.4.3"
4
- end
1
+ module Jiralicious
2
+ # Current Jiralicious Version
3
+ VERSION = "0.5.0"
4
+ end
@@ -0,0 +1,150 @@
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ class Version < Jiralicious::Field
4
+ ##
5
+ # Holds the version Key
6
+ #
7
+ property :version_key, :from => :id
8
+
9
+ class << self
10
+ ##
11
+ # Creates a new version
12
+ #
13
+ # [Arguments]
14
+ # :details (required) Version details to be created
15
+ #
16
+ def create(details)
17
+ response = fetch({:method => :post, :body => details})
18
+ new(response.parsed_response)
19
+ end
20
+
21
+ ##
22
+ # Moves the version to a new position
23
+ #
24
+ # [Arguments]
25
+ # :key (required) Version key
26
+ #
27
+ # :options (optional) Hash of options
28
+ #
29
+ # position
30
+ # An absolute position, which may have a value of 'First', 'Last', 'Earlier' or 'Later'
31
+ # after
32
+ # A version to place this version after. The value should be the self link of another version
33
+ #
34
+ def move(key, options = {})
35
+ if options.include?(:position)
36
+ options[:position] = options[:position].downcase.capitalize
37
+ end
38
+ fetch({:method => :post, :key => "#{key}/move", :body => options})
39
+ end
40
+
41
+ ##
42
+ # Removes/Deletes a Version from the Issue
43
+ #
44
+ # [Arguments]
45
+ # :key (required) Version key
46
+ #
47
+ # :options (optional) Hash of options
48
+ #
49
+ def remove(key, options = {})
50
+ fetch({:method => :delete, :key => key, :body_to_params => true, :body => options}).parsed_response
51
+ end
52
+
53
+ ##
54
+ # Returns the number of Issues associated with the Version
55
+ #
56
+ # [Arguments]
57
+ # :id (required) Version to count
58
+ #
59
+ def related_issue_counts(id)
60
+ response = fetch({:key => "#{id}/relatedIssueCounts"})
61
+ response.parsed_response['key'] = id
62
+ Field.new(response.parsed_response)
63
+ end
64
+
65
+ ##
66
+ # Updates a version
67
+ #
68
+ # [Arguments]
69
+ # :id (required) Version to be updated
70
+ #
71
+ # :details (required) Details of the version to be updated
72
+ #
73
+ def update(id, details)
74
+ response = fetch({:method => :put, :key => id, :body => details})
75
+ new(response.parsed_response)
76
+ end
77
+
78
+ ##
79
+ # Returns the number of Unresolved Issues associated with the Version
80
+ #
81
+ # [Arguments]
82
+ # :id (required) Version to count
83
+ #
84
+ def unresolved_issue_count(id)
85
+ response = fetch({:key => "#{id}/unresolvedIssueCount"})
86
+ response.parsed_response['key'] = id
87
+ Field.new(response.parsed_response)
88
+ end
89
+ end
90
+
91
+ ##
92
+ # Finds all versions based on the provided Issue Key
93
+ #
94
+ def find
95
+ self.class.find(self.version_key)
96
+ end
97
+
98
+ ##
99
+ # Moves the version to a new position
100
+ #
101
+ # [Arguments]
102
+ # :options (optional) Hash of options
103
+ #
104
+ # position
105
+ # An absolute position, which may have a value of 'First', 'Last', 'Earlier' or 'Later'
106
+ # after
107
+ # A version to place this version after. The value should be the self link of another version
108
+ #
109
+ def move(options = {})
110
+ self.class.move(self.version_key, options)
111
+ end
112
+
113
+ ##
114
+ # Removes/Deletes a Version from the Issue
115
+ #
116
+ # [Arguments]
117
+ # :options (optional) Hash of options
118
+ #
119
+ def remove(options = {})
120
+ self.class.remove(self.version_key, options)
121
+ end
122
+
123
+ ##
124
+ # Returns the number of Issues associated with the Version
125
+ #
126
+ def related_issue_counts
127
+ self.class.related_issue_counts(self.version_key)
128
+ end
129
+
130
+ ##
131
+ # Updates a version
132
+ #
133
+ # [Arguments]
134
+ # :details (required) Details of the version to be updated
135
+ #
136
+ def update(details)
137
+ details.each do |k, v|
138
+ self.send("#{k.to_s}=", v)
139
+ end
140
+ self.class.update(self.version_key, details)
141
+ end
142
+
143
+ ##
144
+ # Returns the number of Unresolved Issues associated with the Version
145
+ #
146
+ def unresolved_issue_count
147
+ self.class.unresolved_issue_count(self.version_key).issuesUnresolvedCount
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Jiralicious, "Project Components Class: " do
5
+
6
+ before :each do
7
+ Jiralicious.configure do |config|
8
+ config.username = "jstewart"
9
+ config.password = "topsecret"
10
+ config.uri = "http://jstewart:topsecret@localhost"
11
+ config.auth_type = :basic
12
+ config.api_version = "latest"
13
+ end
14
+
15
+ FakeWeb.register_uri(:post,
16
+ "#{Jiralicious.rest_path}/component/",
17
+ :status => "200",
18
+ :body => component_json)
19
+ FakeWeb.register_uri(:get,
20
+ "#{Jiralicious.rest_path}/component/10000",
21
+ :status => "200",
22
+ :body => component_json)
23
+ FakeWeb.register_uri(:delete,
24
+ "#{Jiralicious.rest_path}/component/10000",
25
+ :status => "200",
26
+ :body => nil)
27
+ FakeWeb.register_uri(:put,
28
+ "#{Jiralicious.rest_path}/component/10000",
29
+ :status => "200",
30
+ :body => component_updated_json)
31
+ FakeWeb.register_uri(:get,
32
+ "#{Jiralicious.rest_path}/component/10000/relatedIssueCounts",
33
+ :status => "200",
34
+ :body => component_ric_json)
35
+
36
+ end
37
+
38
+ it "find a component" do
39
+ component = Jiralicious::Component.find(10000)
40
+ component.component_key.should == "10000"
41
+ component.name.should == "Component 1"
42
+ component.lead.name.should == "fred"
43
+ component.isAssigneeTypeValid.should == false
44
+ end
45
+
46
+ it "create a new component" do
47
+ component = Jiralicious::Component.create({:name=>"Component 1", :description=>"This is a JIRA component", :leadUserName=>"fred", :assigneeType=>"PROJECT_LEAD",:isAssigneeTypeValid=>false,:project=>"DEMO"})
48
+ component.component_key.should == "10000"
49
+ component.name.should == "Component 1"
50
+ component.lead.name.should == "fred"
51
+ component.isAssigneeTypeValid.should == false
52
+ component.assigneeType.should == "PROJECT_LEAD"
53
+ end
54
+
55
+ it "update a component" do
56
+ component = Jiralicious::Component.update(10000, {:name=>"Component 2", :description=>"This is a JIRA component. Updated Component.", :leadUserName=>"fred", :assigneeType=>"PROJECT_LEAD",:isAssigneeTypeValid=>false,:project=>"DEMO"})
57
+ component.component_key.should == "10000"
58
+ component.name.should == "Component 2"
59
+ component.lead.name.should == "fred"
60
+ component.isAssigneeTypeValid.should == false
61
+ component.description.should == "This is a JIRA component. Updated Component."
62
+ end
63
+
64
+ it "delete a component" do
65
+ component = Jiralicious::Component.remove(10000)
66
+ component.should == nil
67
+ end
68
+
69
+ it "component related issue count" do
70
+ component = Jiralicious::Component.find(10000)
71
+ count = component.related_issue_counts
72
+ count.should == 23
73
+ end
74
+ end
@@ -1,41 +1,41 @@
1
- # encoding: utf-8
2
- require "spec_helper"
3
-
4
- describe Jiralicious::Configuration do
5
- before :each do
6
- Jiralicious.reset
7
- end
8
-
9
- it "sets the options to their default value" do
10
- Jiralicious.username.should be_nil
11
- Jiralicious.password.should be_nil
12
- Jiralicious.uri.should be_nil
13
- Jiralicious.api_version.should == "latest"
14
- Jiralicious.auth_type.should == :basic
15
- end
16
-
17
- it "allows setting of options in a block" do
18
- Jiralicious.configure do |config|
19
- config.username = "jstewart"
20
- config.password = "derp"
21
- config.uri = "http://example.com/foo/bar"
22
- config.api_version = "2.0aplha"
23
- config.auth_type = :cookie_session
24
- end
25
-
26
- Jiralicious.username.should == "jstewart"
27
- Jiralicious.password.should == "derp"
28
- Jiralicious.uri.should == "http://example.com/foo/bar"
29
- Jiralicious.api_version.should == "2.0aplha"
30
- Jiralicious.auth_type.should == :cookie_session
31
- end
32
-
33
- it "loads the yml in the specified format into the configuation variables" do
34
- Jiralicious.load_yml(jira_yml)
35
- Jiralicious.username.should == "jira_admin"
36
- Jiralicious.password.should == "jira_admin"
37
- Jiralicious.uri.should == "http://localhost:8080"
38
- Jiralicious.api_version.should == "latest"
39
- Jiralicious.auth_type.should == :basic
40
- end
41
- end
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+
4
+ describe Jiralicious::Configuration do
5
+ before :each do
6
+ Jiralicious.reset
7
+ end
8
+
9
+ it "sets the options to their default value" do
10
+ Jiralicious.username.should be_nil
11
+ Jiralicious.password.should be_nil
12
+ Jiralicious.uri.should be_nil
13
+ Jiralicious.api_version.should == "latest"
14
+ Jiralicious.auth_type.should == :basic
15
+ end
16
+
17
+ it "allows setting of options in a block" do
18
+ Jiralicious.configure do |config|
19
+ config.username = "jstewart"
20
+ config.password = "derp"
21
+ config.uri = "http://example.com/foo/bar"
22
+ config.api_version = "2.0aplha"
23
+ config.auth_type = :cookie_session
24
+ end
25
+
26
+ Jiralicious.username.should == "jstewart"
27
+ Jiralicious.password.should == "derp"
28
+ Jiralicious.uri.should == "http://example.com/foo/bar"
29
+ Jiralicious.api_version.should == "2.0aplha"
30
+ Jiralicious.auth_type.should == :cookie_session
31
+ end
32
+
33
+ it "loads the yml in the specified format into the configuation variables" do
34
+ Jiralicious.load_yml(jira_yml)
35
+ Jiralicious.username.should == "jira_admin"
36
+ Jiralicious.password.should == "jira_admin"
37
+ Jiralicious.uri.should == "http://localhost:8080"
38
+ Jiralicious.api_version.should == "latest"
39
+ Jiralicious.auth_type.should == :basic
40
+ end
41
+ end
@@ -1,73 +1,73 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- class ParserMock
5
- include Jiralicious::Parsers::FieldParser
6
-
7
- def initialize(parsed)
8
- parse!(parsed)
9
- end
10
- end
11
-
12
- describe Jiralicious::Parsers::FieldParser do
13
- context "parse!" do
14
- before :each do
15
- @parsed_data = {
16
- "testfield" => {"name" => "testfield", "value" => "Test Data"},
17
- "without_hash" => "test",
18
- "methods" => {"name" => "methods", "value" => "Test Data 2"},
19
- "testField" => {"name" => "testField", "value" => "Test Data 3"},
20
- "test_field_dash" => {"name" => "test-field-dash", "value" => "Test Data 4"},
21
- "test_field_space" => {"name" => "test field space", "value" => "Test Data 5"},
22
- "test_field_hash" => {"name" => "test_field_hash", "value" => {"it" => "is a Hash"}},
23
- "test_field_array" => {"name" => "test_field_array", "value" => ["Not a hash"]},
24
- "test_field_array_with_hash" => {"name" => "test_field_array_with_hash",
25
- "value" => [{"try" => "this"}]}
26
- }
27
- @parsed_class = ParserMock.new(@parsed_data)
28
- end
29
-
30
- it "raises an error when a hash is not passed in" do
31
- lambda { ParserMock.new }.should raise_error(ArgumentError)
32
- end
33
-
34
- it "creates a hash to store data from the fields internally" do
35
- @parsed_class.instance_variable_get("@jiralicious_field_parser_data").
36
- should be_instance_of(Hash)
37
- end
38
-
39
- context "defining methods" do
40
- it "defines getter methods on the object it's called in" do
41
- @parsed_class.testfield.should == "Test Data"
42
- end
43
-
44
- it "prefixes a defined method with jira_ when the method already exists" do
45
- @parsed_class.jira_methods.should == "Test Data 2"
46
- end
47
-
48
- it "downcases java idiom method names" do
49
- @parsed_class.test_field.should == "Test Data 3"
50
- end
51
-
52
- it "converts nonword to underscore" do
53
- @parsed_class.test_field_dash.should == "Test Data 4"
54
- @parsed_class.test_field_space.should == "Test Data 5"
55
- end
56
- end
57
-
58
- context "mashifying data" do
59
- it "makes hashes a mash" do
60
- @parsed_class.test_field_hash.should be_instance_of(Hashie::Mash)
61
- end
62
-
63
- it "recursively makes array elements mashes" do
64
- @parsed_class.test_field_array_with_hash.
65
- first.should be_instance_of(Hashie::Mash)
66
- end
67
-
68
- it "leaves array data alone when it's not a hash" do
69
- @parsed_class.test_field_array.should == ["Not a hash"]
70
- end
71
- end
72
- end
73
- end
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ class ParserMock
5
+ include Jiralicious::Parsers::FieldParser
6
+
7
+ def initialize(parsed)
8
+ parse!(parsed)
9
+ end
10
+ end
11
+
12
+ describe Jiralicious::Parsers::FieldParser do
13
+ context "parse!" do
14
+ before :each do
15
+ @parsed_data = {
16
+ "testfield" => {"name" => "testfield", "value" => "Test Data"},
17
+ "without_hash" => "test",
18
+ "methods" => {"name" => "methods", "value" => "Test Data 2"},
19
+ "testField" => {"name" => "testField", "value" => "Test Data 3"},
20
+ "test_field_dash" => {"name" => "test-field-dash", "value" => "Test Data 4"},
21
+ "test_field_space" => {"name" => "test field space", "value" => "Test Data 5"},
22
+ "test_field_hash" => {"name" => "test_field_hash", "value" => {"it" => "is a Hash"}},
23
+ "test_field_array" => {"name" => "test_field_array", "value" => ["Not a hash"]},
24
+ "test_field_array_with_hash" => {"name" => "test_field_array_with_hash",
25
+ "value" => [{"try" => "this"}]}
26
+ }
27
+ @parsed_class = ParserMock.new(@parsed_data)
28
+ end
29
+
30
+ it "raises an error when a hash is not passed in" do
31
+ lambda { ParserMock.new }.should raise_error(ArgumentError)
32
+ end
33
+
34
+ it "creates a hash to store data from the fields internally" do
35
+ @parsed_class.instance_variable_get("@jiralicious_field_parser_data").
36
+ should be_instance_of(Hash)
37
+ end
38
+
39
+ context "defining methods" do
40
+ it "defines getter methods on the object it's called in" do
41
+ @parsed_class.testfield.should == "Test Data"
42
+ end
43
+
44
+ it "prefixes a defined method with jira_ when the method already exists" do
45
+ @parsed_class.jira_methods.should == "Test Data 2"
46
+ end
47
+
48
+ it "downcases java idiom method names" do
49
+ @parsed_class.test_field.should == "Test Data 3"
50
+ end
51
+
52
+ it "converts nonword to underscore" do
53
+ @parsed_class.test_field_dash.should == "Test Data 4"
54
+ @parsed_class.test_field_space.should == "Test Data 5"
55
+ end
56
+ end
57
+
58
+ context "mashifying data" do
59
+ it "makes hashes a mash" do
60
+ @parsed_class.test_field_hash.should be_instance_of(Hashie::Mash)
61
+ end
62
+
63
+ it "recursively makes array elements mashes" do
64
+ @parsed_class.test_field_array_with_hash.
65
+ first.should be_instance_of(Hashie::Mash)
66
+ end
67
+
68
+ it "leaves array data alone when it's not a hash" do
69
+ @parsed_class.test_field_array.should == ["Not a hash"]
70
+ end
71
+ end
72
+ end
73
+ end