mingle-api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94199aaae96d4214cecaf879930b8cea304b36f9
4
- data.tar.gz: a0d01b5477bc18c396343320352e3beee40b466a
3
+ metadata.gz: e3b92dc4e3ee97b73989ae149169b01d557ca851
4
+ data.tar.gz: c30f9f566d55bba6ae60813868e699b973bd9a33
5
5
  SHA512:
6
- metadata.gz: b9200be2eb9fca66d9e947dbd7f59b521cc911e1ca4845d9d621603fad06b3da9f77f30bdef5d76c445896f9666903de6accb2e6d7cc6e9f7fb6c83adaef0872
7
- data.tar.gz: 63440ec88b25d78fa9af6e7386a106616933bd61cb1da12cef41262d2bb5285a83d309174d198722f091b123ff0c9917b0b9be51ba3a8902338d9ed8f4b04f85
6
+ metadata.gz: db70cbc86a8adf54a2ee2d67d21a88d2491b971e1a3253f0532de99c9731a3f29046f34beaf7a7e71d45e6398cd1f3abf267da88c41d64cc033c18dfdde83ded
7
+ data.tar.gz: b414e86ab1d521cf99c32f9d51cb87cd85f78737cbc0fa833f6e2afb8ffe77a2d3f9088d2e134969f836f94993a24159aa1f1e1b586872030ae1973ab7dacc4f
@@ -46,18 +46,18 @@ class Mingle
46
46
  "project[template]" => false,
47
47
  "template_name" => options[:template] ? "yml_#{options[:template]}_template" : nil
48
48
  })
49
- OpenStruct.new(:identifier => identifier, :url => url('projects', identifier))
49
+ OpenStruct.new(:identifier => identifier, :name => name, :url => url('projects', identifier))
50
50
  end
51
51
 
52
- def cards(project_identifier)
53
- list(fetch(:projects, project_identifier, :cards), CARD)
52
+ def cards(project)
53
+ list(fetch(:projects, project_identifier(project), :cards), CARD)
54
54
  end
55
55
 
56
- def card(project_identifier, number)
57
- ostruct(fetch(:projects, project_identifier, :cards, number), CARD)
56
+ def card(project, number)
57
+ ostruct(fetch(:projects, project_identifier(project), :cards, number), CARD)
58
58
  end
59
59
 
60
- def create_card(project_identifier, attrs)
60
+ def create_card(project, attrs)
61
61
  params = [
62
62
  ["card[name]", attrs[:name]],
63
63
  ["card[card_type_name]", attrs[:type]],
@@ -72,9 +72,9 @@ class Mingle
72
72
  params << ["card[properties][][name]", name]
73
73
  params << ["card[properties][][value]", value]
74
74
  end
75
- resp = @http.post(v2(:projects, project_identifier, :cards), params)
75
+ resp = @http.post(v2(:projects, project_identifier(project), :cards), params)
76
76
  number = resp[2]["location"].split("/").last.split('.').first
77
- OpenStruct.new(:number => number, :url => url('projects', project_identifier, 'cards', number))
77
+ OpenStruct.new(:number => number, :url => url('projects', project_identifier(project), 'cards', number))
78
78
  end
79
79
 
80
80
  def site_api_url
@@ -86,6 +86,10 @@ class Mingle
86
86
  end
87
87
 
88
88
  private
89
+ def project_identifier(proj)
90
+ proj.respond_to?(:identifier) ? proj.identifier : proj.to_s
91
+ end
92
+
89
93
  def url(*parts)
90
94
  File.join(site_url, *parts)
91
95
  end
@@ -1,5 +1,5 @@
1
1
  module Mingle
2
2
  module Api
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -20,6 +20,7 @@ class MingleTest < Minitest::Test
20
20
  mingle = create_basic_auth_mingle
21
21
  project = mingle.create_project("Hello #{t.to_i}", description: "proj created at #{t}", template: 'kanban')
22
22
  assert_equal "hello_#{t.to_i}", project.identifier
23
+ assert_equal "Hello #{t.to_i}", project.name
23
24
  assert_equal "https://xiao-test100.mingle.thoughtworks.com/projects/hello_#{t.to_i}", project.url
24
25
 
25
26
  proj = mingle.project(project.identifier)
@@ -30,6 +31,8 @@ class MingleTest < Minitest::Test
30
31
  mingle = create_hmac_auth_mingle
31
32
  cards = mingle.cards('your_first_project')
32
33
  assert cards.size > 0
34
+ cards = mingle.cards(OpenStruct.new(:identifier => 'your_first_project'))
35
+ assert cards.size > 0
33
36
  end
34
37
 
35
38
  def test_find_card_by_number
@@ -40,7 +43,7 @@ class MingleTest < Minitest::Test
40
43
  assert_equal 'New', card1.status
41
44
  assert_equal 'xli_test100', card1.owner
42
45
 
43
- card2 = mingle.card('your_first_project', 2)
46
+ card2 = mingle.card(OpenStruct.new(:identifier => 'your_first_project'), 2)
44
47
  assert_equal 'card name', card2.name
45
48
  assert_equal 'Story', card2.type
46
49
  assert_equal 'New', card2.status
@@ -60,4 +63,11 @@ class MingleTest < Minitest::Test
60
63
  assert_equal 'New', card.status
61
64
  assert_equal 'Must', card.priority
62
65
  end
66
+
67
+ def test_create_simple_card
68
+ mingle = create_hmac_auth_mingle
69
+ card = mingle.create_card(OpenStruct.new(:identifier => 'your_first_project'), name: 'must have card name and type', type: 'Story')
70
+ assert card.number
71
+ assert_equal "https://xiao-test100.mingle.thoughtworks.com/projects/your_first_project/cards/#{card.number}", card.url
72
+ end
63
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiao Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api-auth