ruby-trello 1.5.1 → 1.6.0

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: 3131b86cac06b4df9efe8f417ab1bd32de3cbdb1
4
- data.tar.gz: 862affe69703265224606c58b6a72cb5e8c1f668
3
+ metadata.gz: b666e156d0e650e1f3a28d42dfdc0eaff8b8c147
4
+ data.tar.gz: 232b7631c884e4126aba17d87dcde5fa7e3b44be
5
5
  SHA512:
6
- metadata.gz: 3f6f8f608417641e88c05ab8df2ebdb5e50bff8f522070be335d3be733d9eca5f6cd5470e34de6542875a9d1dfbb4b2dd78147403d035b2c4e931ebfb15c42e1
7
- data.tar.gz: 1e53a8176105929d6c972888e3d6b218bbba627b92abcef67b6e660119ac5371dbca524c4fd2990751750a267ad318fc67803a95dc083dfc17b743053534c562
6
+ metadata.gz: 4195f7cabbe3497ce58ca381d35703e05fca562895abaaf305351d70418ea2e54d13e72be42c2fa548920350a2e01f7a80ab88cd10d66cf876f4e77361e2ddb0
7
+ data.tar.gz: 134a4f52ae538a3d4c68004a2ae9b5852c36a98d7841c9becc456b9fdabe7130a0a2b70a8a684d0a7de2f67906ddc511f41c03e90629888d2391930b906d3c9f
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Ruby Trello API
2
2
 
3
3
  [![Stories in Ready](http://badge.waffle.io/jeremytregunna/ruby-trello.png)](http://waffle.io/jeremytregunna/ruby-trello)
4
- [![Build Status](https://secure.travis-ci.org/jeremytregunna/ruby-trello.png)](http://travis-ci.org/jeremytregunna/ruby-trello) [![Dependency Status](https://gemnasium.com/jeremytregunna/ruby-trello.png)](https://gemnasium.com/jeremytregunna/ruby-trello.png)
4
+ [![Build Status](https://secure.travis-ci.org/jeremytregunna/ruby-trello.png)](http://travis-ci.org/jeremytregunna/ruby-trello) [![Dependency Status](https://gemnasium.com/jeremytregunna/ruby-trello.png)](https://gemnasium.com/jeremytregunna/ruby-trello)
5
5
  [![Code Climate](https://codeclimate.com/github/jeremytregunna/ruby-trello/badges/gpa.svg)](https://codeclimate.com/github/jeremytregunna/ruby-trello)
6
6
 
7
7
  This library implements the [Trello](http://www.trello.com/) [API](http://trello.com/api).
@@ -59,6 +59,7 @@ module Trello
59
59
  autoload :MultiAssociation, 'trello/multi_association'
60
60
  autoload :Notification, 'trello/notification'
61
61
  autoload :Organization, 'trello/organization'
62
+ autoload :PluginDatum, 'trello/plugin_datum'
62
63
  autoload :Request, 'trello/net'
63
64
  autoload :TInternet, 'trello/net'
64
65
  autoload :Token, 'trello/token'
@@ -24,7 +24,7 @@ module Trello
24
24
  client.find(:action, id, params)
25
25
  end
26
26
 
27
- def search(query, opts={})
27
+ def search(query, opts = {})
28
28
  response = client.get("/search/", { query: query }.merge(opts))
29
29
  parse_json(response).except("options").each_with_object({}) do |(key, data), result|
30
30
  klass = "Trello::#{key.singularize.capitalize}".constantize
@@ -90,8 +90,10 @@ module Trello
90
90
  options = opts.dup
91
91
  resource = options.delete(:in) || self.class.to_s.split("::").last.downcase.pluralize
92
92
  klass = options.delete(:via) || Trello.const_get(name.to_s.singularize.camelize)
93
+ path = options.delete(:path) || name
93
94
  params = options.merge(args[0] || {})
94
- resources = client.find_many(klass, "/#{resource}/#{id}/#{name}", params)
95
+
96
+ resources = client.find_many(klass, "/#{resource}/#{id}/#{path}", params)
95
97
  MultiAssociation.new(self, resources).proxy
96
98
  end
97
99
  end
@@ -87,15 +87,17 @@ module Trello
87
87
  end
88
88
 
89
89
  def update_fields(fields)
90
- attributes[:id] = fields['id'] if fields['id']
91
- attributes[:name] = fields['name'] if fields['name']
92
- attributes[:description] = fields['desc'] if fields['desc']
93
- attributes[:closed] = fields['closed'] if fields.has_key?('closed')
94
- attributes[:starred] = fields['starred'] if fields.has_key?('starred')
95
- attributes[:url] = fields['url'] if fields['url']
96
- attributes[:organization_id] = fields['idOrganization'] if fields['idOrganization']
97
- attributes[:prefs] = fields['prefs'] || {}
98
- attributes[:last_activity_date] = Time.iso8601(fields['dateLastActivity']) rescue nil
90
+ attributes[:id] = fields['id'] || fields[:id] if fields['id'] || fields[:id]
91
+ attributes[:name] = fields['name'] || fields[:name] if fields['name'] || fields[:name]
92
+ attributes[:description] = fields['desc'] || fields[:desc] if fields['desc'] || fields[:desc]
93
+ attributes[:closed] = fields['closed'] if fields.has_key?('closed')
94
+ attributes[:closed] = fields[:closed] if fields.has_key?(:closed)
95
+ attributes[:starred] = fields['starred'] if fields.has_key?('starred')
96
+ attributes[:starred] = fields[:starred] if fields.has_key?(:starred)
97
+ attributes[:url] = fields['url'] if fields['url']
98
+ attributes[:organization_id] = fields['idOrganization'] || fields[:organization_id] if fields['idOrganization'] || fields[:organization_id]
99
+ attributes[:prefs] = fields['prefs'] || fields[:prefs] || {}
100
+ attributes[:last_activity_date] = Time.iso8601(fields['dateLastActivity']) rescue nil
99
101
  self
100
102
  end
101
103
 
@@ -155,7 +157,7 @@ module Trello
155
157
  # Returns a reference to the organization this board belongs to.
156
158
  one :organization, path: :organizations, using: :organization_id
157
159
 
158
- def labels(params={})
160
+ def labels(params = {})
159
161
  # Set the limit to as high as possible given there is no pagination in this API.
160
162
  params[:limit] = 1000 unless params[:limit]
161
163
  labels = Label.from_response client.get("/boards/#{id}/labels", params)
@@ -43,7 +43,7 @@ module Trello
43
43
  # @return [Array<String>] Array of strings
44
44
 
45
45
  class Card < BasicData
46
- register_attributes :id, :short_id, :name, :desc, :due, :closed, :url, :short_url,
46
+ register_attributes :id, :short_id, :name, :desc, :due, :due_complete, :closed, :url, :short_url,
47
47
  :board_id, :member_ids, :list_id, :pos, :last_activity_date, :labels, :card_labels,
48
48
  :cover_image_id, :badges, :card_members, :source_card_id, :source_card_properties,
49
49
  readonly: [ :id, :short_id, :url, :short_url, :last_activity_date, :badges, :card_members ]
@@ -59,6 +59,7 @@ module Trello
59
59
  name: 'name',
60
60
  desc: 'desc',
61
61
  due: 'due',
62
+ due_complete: 'dueComplete',
62
63
  closed: 'closed',
63
64
  url: 'url',
64
65
  short_url: 'shortUrl',
@@ -122,6 +123,7 @@ module Trello
122
123
  'idMembers' => options[:member_ids],
123
124
  'idLabels' => options[:card_labels],
124
125
  'due' => options[:due],
126
+ 'due_complete' => options[:due_complete] || false,
125
127
  'pos' => options[:pos],
126
128
  'idCardSource' => options[:source_card_id],
127
129
  'keepFromSource' => options.key?(:source_card_properties) ? options[:source_card_properties] : 'all'
@@ -146,6 +148,7 @@ module Trello
146
148
  # @option fields [String] :desc A string with a length from 0 to
147
149
  # 16384.
148
150
  # @option fields [Date] :due A date, or `nil`.
151
+ # @option fields [Boolean] :due_complete
149
152
  # @option fields [Boolean] :closed
150
153
  # @option fields [String] :url
151
154
  # @option fields [String] :short_url
@@ -168,24 +171,26 @@ module Trello
168
171
  def update_fields(fields)
169
172
  attributes[:id] = fields[SYMBOL_TO_STRING[:id]]
170
173
  attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]]
171
- attributes[:name] = fields[SYMBOL_TO_STRING[:name]]
172
- attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]]
174
+ attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name]
175
+ attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]] || fields[:desc]
173
176
  attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil
177
+ attributes[:due] ||= fields[:due]
178
+ attributes[:due_complete] = fields[SYMBOL_TO_STRING[:due_complete]] || false
174
179
  attributes[:closed] = fields[SYMBOL_TO_STRING[:closed]]
175
180
  attributes[:url] = fields[SYMBOL_TO_STRING[:url]]
176
181
  attributes[:short_url] = fields[SYMBOL_TO_STRING[:short_url]]
177
182
  attributes[:board_id] = fields[SYMBOL_TO_STRING[:board_id]]
178
- attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]]
179
- attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]]
180
- attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]]
183
+ attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]] || fields[:member_ids]
184
+ attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]] || fields[:list_id]
185
+ attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]] || fields[:pos]
181
186
  attributes[:labels] = (fields[SYMBOL_TO_STRING[:labels]] || []).map { |lbl| Trello::Label.new(lbl) }
182
- attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]]
187
+ attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]] || fields[:card_labels]
183
188
  attributes[:last_activity_date] = Time.iso8601(fields[SYMBOL_TO_STRING[:last_activity_date]]) rescue nil
184
189
  attributes[:cover_image_id] = fields[SYMBOL_TO_STRING[:cover_image_id]]
185
190
  attributes[:badges] = fields[SYMBOL_TO_STRING[:badges]]
186
191
  attributes[:card_members] = fields[SYMBOL_TO_STRING[:card_members]]
187
- attributes[:source_card_id] = fields[SYMBOL_TO_STRING[:source_card_id]]
188
- attributes[:source_card_properties] = fields[SYMBOL_TO_STRING[:source_card_properties]]
192
+ attributes[:source_card_id] = fields[SYMBOL_TO_STRING[:source_card_id]] || fields[:source_card_id]
193
+ attributes[:source_card_properties] = fields[SYMBOL_TO_STRING[:source_card_properties]] || fields[:source_card_properties]
189
194
  self
190
195
  end
191
196
 
@@ -201,6 +206,9 @@ module Trello
201
206
  # :filter => [ :none, :all ] # default :all
202
207
  many :checklists, filter: :all
203
208
 
209
+ # Returns a list of plugins associated with the card
210
+ many :plugin_data, path: "pluginData"
211
+
204
212
  def check_item_states
205
213
  states = CheckItemState.from_response client.get("/cards/#{self.id}/checkItemStates")
206
214
  MultiAssociation.new(self, states).proxy
@@ -247,6 +255,7 @@ module Trello
247
255
  idLabels: card_labels,
248
256
  pos: pos,
249
257
  due: due,
258
+ dueComplete: due_complete,
250
259
  idCardSource: source_card_id,
251
260
  keepFromSource: source_card_properties
252
261
  })
@@ -397,7 +406,7 @@ module Trello
397
406
  end
398
407
 
399
408
  # Add an attachment to this card
400
- def add_attachment(attachment, name='')
409
+ def add_attachment(attachment, name = '')
401
410
  # Is it a file object or a string (url)?
402
411
  if attachment.respond_to?(:path) && attachment.respond_to?(:read)
403
412
  client.post("/cards/#{id}/attachments", {
@@ -46,14 +46,14 @@ module Trello
46
46
  # a checklist.
47
47
  def update_fields(fields)
48
48
  attributes[:id] = fields['id']
49
- attributes[:name] = fields['name']
49
+ attributes[:name] = fields['name'] || fields[:name]
50
50
  attributes[:description] = fields['desc']
51
51
  attributes[:closed] = fields['closed']
52
52
  attributes[:url] = fields['url']
53
53
  attributes[:check_items] = fields['checkItems']
54
54
  attributes[:position] = fields['pos']
55
55
  attributes[:board_id] = fields['idBoard']
56
- attributes[:card_id] = fields['idCard']
56
+ attributes[:card_id] = fields['idCard'] || fields[:card_id]
57
57
  attributes[:list_id] = fields['idList']
58
58
  attributes[:member_ids] = fields['idMembers']
59
59
  self
@@ -103,7 +103,7 @@ module Trello
103
103
  end
104
104
 
105
105
  # Add an item to the checklist
106
- def add_item(name, checked=false, position='bottom')
106
+ def add_item(name, checked = false, position = 'bottom')
107
107
  client.post("/checklists/#{id}/checkItems", {name: name, checked: checked, pos: position})
108
108
  end
109
109
 
@@ -65,9 +65,9 @@ module Trello
65
65
  # a label.
66
66
  def update_fields(fields)
67
67
  attributes[:id] = fields['id']
68
- attributes[:name] = fields['name']
69
- attributes[:color] = fields['color']
70
- attributes[:board_id] = fields['idBoard']
68
+ attributes[:name] = fields['name'] || fields[:name]
69
+ attributes[:color] = fields['color'] || fields[:color]
70
+ attributes[:board_id] = fields['idBoard'] || fields[:board_id]
71
71
  attributes[:uses] = fields['uses']
72
72
  self
73
73
  end
@@ -42,11 +42,11 @@ module Trello
42
42
  # a List.
43
43
  def update_fields(fields)
44
44
  attributes[:id] = fields['id']
45
- attributes[:name] = fields['name']
45
+ attributes[:name] = fields['name'] || fields[:name]
46
46
  attributes[:closed] = fields['closed']
47
- attributes[:board_id] = fields['idBoard']
48
- attributes[:pos] = fields['pos']
49
- attributes[:source_list_id] = fields['idListSource']
47
+ attributes[:board_id] = fields['idBoard'] || fields[:board_id]
48
+ attributes[:pos] = fields['pos'] || fields[:pos]
49
+ attributes[:source_list_id] = fields['idListSource'] || fields[:source_list_id]
50
50
  self
51
51
  end
52
52
 
@@ -0,0 +1,34 @@
1
+ module Trello
2
+ # A file or url that is linked to a Trello card
3
+ #
4
+ # @!attribute id
5
+ # @return [String]
6
+ # @!attribute idPlugin
7
+ # @return [String]
8
+ # @!attribute scope
9
+ # @return [String]
10
+ # @!attribute idModel
11
+ # @return [String]
12
+ # @!attribute value
13
+ # @return [String]
14
+ # @!attribute access
15
+ # @return [String]
16
+ class PluginDatum < BasicData
17
+ # Update the fields of a plugin.
18
+ register_attributes :id, :idPlugin, :scope, :idModel, :value, :access
19
+
20
+
21
+ # Supply a hash of stringkeyed data retrieved from the Trello API representing
22
+ # an attachment.
23
+ def update_fields(fields)
24
+ attributes[:id] = fields['id']
25
+ attributes[:idPlugin] = fields['idPlugin']
26
+ attributes[:scope] = fields['scope']
27
+ attributes[:value] = JSON.parse fields['value']
28
+ attributes[:idModel] = fields['idModel']
29
+ attributes[:access] = fields['access']
30
+ self
31
+ end
32
+ end
33
+
34
+ end
@@ -49,9 +49,9 @@ module Trello
49
49
  # @return [Trello::Webhook] self
50
50
  def update_fields(fields)
51
51
  attributes[:id] = fields['id']
52
- attributes[:description] = fields['description']
53
- attributes[:id_model] = fields['idModel']
54
- attributes[:callback_url] = fields['callbackURL']
52
+ attributes[:description] = fields['description'] || fields[:description]
53
+ attributes[:id_model] = fields['idModel'] || fields[:id_model]
54
+ attributes[:callback_url] = fields['callbackURL'] || fields[:callback_url]
55
55
  attributes[:active] = fields['active']
56
56
  self
57
57
  end
@@ -5,6 +5,9 @@ describe Array, '#jsoned_into' do
5
5
  include Helpers
6
6
 
7
7
  it "should convert an array of parsed json into cards" do
8
- expect(cards_details.jsoned_into(Trello::Card)).to eq([cards_details.first.jsoned_into(Trello::Card)])
8
+ expected = cards_details.map do |card_details|
9
+ card_details.jsoned_into(Trello::Card)
10
+ end
11
+ expect(cards_details.jsoned_into(Trello::Card)).to eq(expected)
9
12
  end
10
13
  end
@@ -273,7 +273,28 @@ module Trello
273
273
  expect(board.organization_id).to eq expected['idOrganization']
274
274
  end
275
275
 
276
- it "sets any attributes supplied in the fields argument"
276
+ it "initializes all fields from response-like formatted hash" do
277
+ board_details = boards_details.first
278
+ board = Board.new(board_details)
279
+ expect(board.id).to eq board_details['id']
280
+ expect(board.name).to eq board_details['name']
281
+ expect(board.description).to eq board_details['desc']
282
+ expect(board.closed).to eq board_details['closed']
283
+ expect(board.starred).to eq board_details['starred']
284
+ expect(board.organization_id).to eq board_details['idOrganization']
285
+ expect(board.url).to eq board_details['url']
286
+ expect(board.last_activity_date).to eq board_details['dateLastActivity']
287
+ end
288
+
289
+ it "initializes all fields from options-like formatted hash" do
290
+ board_details = boards_details[1]
291
+ board = Board.new(board_details)
292
+ expect(board.name).to eq board_details[:name]
293
+ expect(board.description).to eq board_details[:desc]
294
+ expect(board.closed).to eq board_details[:closed]
295
+ expect(board.starred).to eq board_details[:starred]
296
+ expect(board.organization_id).to eq board_details[:organization_id]
297
+ end
277
298
  end
278
299
 
279
300
  describe "#save" do
@@ -39,8 +39,44 @@ module Trello
39
39
  let(:client) { Trello.client }
40
40
 
41
41
  it "creates a new record" do
42
- card = Card.new(cards_details.first)
43
- expect(card).to be_valid
42
+ cards_details.each do |card_details|
43
+ card = Card.new(card_details)
44
+ expect(card).to be_valid
45
+ end
46
+ end
47
+
48
+ it 'properly initializes all fields from response-like formatted hash' do
49
+ card_details = cards_details.first
50
+ card = Card.new(card_details)
51
+ expect(card.id).to eq(card_details['id'])
52
+ expect(card.short_id).to eq(card_details['idShort'])
53
+ expect(card.name).to eq(card_details['name'])
54
+ expect(card.desc).to eq(card_details['desc'])
55
+ expect(card.closed).to eq(card_details['closed'])
56
+ expect(card.list_id).to eq(card_details['idList'])
57
+ expect(card.board_id).to eq(card_details['idBoard'])
58
+ expect(card.cover_image_id).to eq(card_details['idAttachmentCover'])
59
+ expect(card.member_ids).to eq(card_details['idMembers'])
60
+ expect(card.labels).to eq(card_details['labels'].map { |lbl| Trello::Label.new(lbl) })
61
+ expect(card.card_labels).to eq(card_details['idLabels'])
62
+ expect(card.url).to eq(card_details['url'])
63
+ expect(card.short_url).to eq(card_details['shortUrl'])
64
+ expect(card.pos).to eq(card_details['pos'])
65
+ expect(card.last_activity_date).to eq(card_details['dateLastActivity'])
66
+ end
67
+
68
+ it 'properly initializes all fields from options-like formatted hash' do
69
+ card_details = cards_details[1]
70
+ card = Card.new(card_details)
71
+ expect(card.name).to eq(card_details[:name])
72
+ expect(card.list_id).to eq(card_details[:list_id])
73
+ expect(card.desc).to eq(card_details[:desc])
74
+ expect(card.member_ids).to eq(card_details[:member_ids])
75
+ expect(card.card_labels).to eq(card_details[:card_labels])
76
+ expect(card.due).to eq(card_details[:due])
77
+ expect(card.pos).to eq(card_details[:pos])
78
+ expect(card.source_card_id).to eq(card_details[:source_card_id])
79
+ expect(card.source_card_properties).to eq(card_details[:source_card_properties])
44
80
  end
45
81
 
46
82
  it 'must not be valid if not given a name' do
@@ -63,7 +99,7 @@ module Trello
63
99
  result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
64
100
 
65
101
  expected_payload = {name: "Test Card", desc: nil, idList: "abcdef123456789123456789",
66
- idMembers: nil, idLabels: "abcdef123456789123456789", pos: nil, due: nil, idCardSource: nil, keepFromSource: 'all'}
102
+ idMembers: nil, idLabels: "abcdef123456789123456789", pos: nil, due: nil, dueComplete: false, idCardSource: nil, keepFromSource: 'all'}
67
103
 
68
104
  expect(client)
69
105
  .to receive(:post)
@@ -83,7 +119,7 @@ module Trello
83
119
  result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
84
120
 
85
121
  expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
86
- idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: 'all'}
122
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, dueComplete: false, idCardSource: cards_details.first['id'], keepFromSource: 'all'}
87
123
 
88
124
  expect(client)
89
125
  .to receive(:post)
@@ -98,13 +134,13 @@ module Trello
98
134
  it 'creates a duplicate card with source due date and checklists and saves it on Trello', refactor: true do
99
135
  payload = {
100
136
  source_card_id: cards_details.first['id'],
101
- source_card_properties: ['due','checklists']
137
+ source_card_properties: ['due', 'checklists']
102
138
  }
103
139
 
104
140
  result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
105
141
 
106
142
  expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
107
- idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: ['due','checklists']}
143
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, dueComplete: false, idCardSource: cards_details.first['id'], keepFromSource: ['due', 'checklists']}
108
144
 
109
145
  expect(client)
110
146
  .to receive(:post)
@@ -125,7 +161,7 @@ module Trello
125
161
  result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
126
162
 
127
163
  expected_payload = {name: nil, desc: nil, idList: "abcdef123456789123456789",
128
- idMembers: nil, idLabels: nil, pos: nil, due: nil, idCardSource: cards_details.first['id'], keepFromSource: nil}
164
+ idMembers: nil, idLabels: nil, pos: nil, due: nil, dueComplete: false, idCardSource: cards_details.first['id'], keepFromSource: nil}
129
165
 
130
166
  expect(client)
131
167
  .to receive(:post)
@@ -561,6 +597,40 @@ module Trello
561
597
  end
562
598
  end
563
599
 
600
+ context "plugins" do
601
+ it "can list the existing plugins with correct fields" do
602
+ allow(client)
603
+ .to receive(:get)
604
+ .with("/boards/abcdef123456789123456789", {})
605
+ .and_return JSON.generate(boards_details.first)
606
+
607
+ allow(client)
608
+ .to receive(:get)
609
+ .with("/cards/abcdef123456789123456789/pluginData", {})
610
+ .and_return plugin_data_payload
611
+
612
+ expect(card.board).to_not be_nil
613
+ expect(card.plugin_data).to_not be_nil
614
+
615
+ first_plugin = card.plugin_data.first
616
+ expect(first_plugin.id).to eq plugin_data_details[0]["id"]
617
+ expect(first_plugin.idPlugin).to eq plugin_data_details[0]["idPlugin"]
618
+ expect(first_plugin.scope).to eq plugin_data_details[0]["scope"]
619
+ expect(first_plugin.idModel).to eq plugin_data_details[0]["idModel"]
620
+ expect(first_plugin.value).to eq JSON.parse plugin_data_details[0]["value"]
621
+ expect(first_plugin.access).to eq plugin_data_details[0]["access"]
622
+
623
+ second_plugin = card.plugin_data[1]
624
+ expect(second_plugin.id).to eq plugin_data_details[1]["id"]
625
+ expect(second_plugin.idPlugin).to eq plugin_data_details[1]["idPlugin"]
626
+ expect(second_plugin.scope).to eq plugin_data_details[1]["scope"]
627
+ expect(second_plugin.idModel).to eq plugin_data_details[1]["idModel"]
628
+ expect(second_plugin.value).to eq JSON.parse plugin_data_details[1]["value"]
629
+ expect(second_plugin.access).to eq plugin_data_details[1]["access"]
630
+
631
+ end
632
+ end
633
+
564
634
  context "attachments" do
565
635
  it "can add an attachment" do
566
636
  f = File.new('spec/list_spec.rb', 'r')
@@ -649,5 +719,19 @@ module Trello
649
719
  card.close!
650
720
  end
651
721
  end
722
+
723
+ describe "can mark due_complete" do
724
+ it "updates the due completed attribute to true" do
725
+ card.due = Time.now
726
+ card.save
727
+
728
+ expect(card.due).to_not be_nil
729
+
730
+ card.due_complete = true
731
+ card.save
732
+
733
+ expect(card.due_complete).to_be true
734
+ end
735
+ end
652
736
  end
653
737
  end
@@ -42,7 +42,7 @@ module Trello
42
42
 
43
43
  attributes = checklists_details.first.merge(payload).except("idBoard")
44
44
  result = JSON.generate(attributes)
45
-
45
+
46
46
 
47
47
  expected_payload = {name: "Test Checklist", idCard: cards_details.first['id']}
48
48
 
@@ -55,6 +55,29 @@ module Trello
55
55
 
56
56
  expect(checklist).to be_a Checklist
57
57
  end
58
+
59
+ it 'initializes all fields from response-like hash' do
60
+ checklist_details = checklists_details.first
61
+ checklist = Checklist.new(checklist_details)
62
+ expect(checklist.id).to eq checklist_details['id']
63
+ expect(checklist.name).to eq checklist_details['name']
64
+ expect(checklist.description).to eq checklist_details['desc']
65
+ expect(checklist.closed).to eq checklist_details['closed']
66
+ expect(checklist.position).to eq checklist_details['pos']
67
+ expect(checklist.url).to eq checklist_details['url']
68
+ expect(checklist.board_id).to eq checklist_details['idBoard']
69
+ expect(checklist.card_id).to eq checklist_details['idCard']
70
+ expect(checklist.list_id).to eq checklist_details['idList']
71
+ expect(checklist.member_ids).to eq checklist_details['idMembers']
72
+ expect(checklist.check_items).to eq checklist_details['checkItems']
73
+ end
74
+
75
+ it 'initializes required fields from options-like hash' do
76
+ checklist_details = checklists_details[1]
77
+ checklist = Checklist.new(checklist_details)
78
+ expect(checklist.name).to eq checklist_details[:name]
79
+ expect(checklist.card_id).to eq checklist_details[:card_id]
80
+ end
58
81
  end
59
82
 
60
83
  context "deleting" do
@@ -37,6 +37,24 @@ module Trello
37
37
  expect(Label.new(label_details.first)).to be_valid
38
38
  end
39
39
 
40
+ it "initializes all fields from response-like formatted hash" do
41
+ details = label_details.first
42
+ label = Label.new(details)
43
+ expect(label.color).to eq details['color']
44
+ expect(label.name).to eq details['name']
45
+ expect(label.id).to eq details['id']
46
+ expect(label.uses).to eq details['uses']
47
+ expect(label.board_id).to eq details['idBoard']
48
+ end
49
+
50
+ it "initializes required fields from options-like formatted hash" do
51
+ details = label_options
52
+ label = Label.new(details)
53
+ expect(label.name).to eq details[:name]
54
+ expect(label.board_id).to eq details[:board_id]
55
+ expect(label.color).to eq details[:color]
56
+ end
57
+
40
58
  it 'must not be valid if not given a name' do
41
59
  expect(Label.new('idBoard' => lists_details.first['board_id'])).to_not be_valid
42
60
  end
@@ -53,6 +53,26 @@ module Trello
53
53
  expect(list).to_not be_valid
54
54
  end
55
55
 
56
+ it 'initializes all fields from response-like formatted hash' do
57
+ list_details = lists_details.first
58
+ list = List.new(list_details)
59
+ expect(list.id).to eq(list_details['id'])
60
+ expect(list.name).to eq(list_details['name'])
61
+ expect(list.closed).to eq(list_details['closed'])
62
+ expect(list.board_id).to eq(list_details['idBoard'])
63
+ expect(list.pos).to eq(list_details['pos'])
64
+ expect(list.source_list_id).to eq(list_details['idListSource'])
65
+ end
66
+
67
+ it 'initializes required fields from options-like formatted hash' do
68
+ list_details = lists_details[1]
69
+ list = List.new(list_details)
70
+ expect(list.name).to eq list_details[:name]
71
+ expect(list.board_id).to eq list_details[:board_id]
72
+ expect(list.pos).to eq list_details[:pos]
73
+ expect(list.source_list_id).to eq list_details[:source_list_id]
74
+ end
75
+
56
76
  it 'creates a new record and saves it on Trello', refactor: true do
57
77
  payload = {
58
78
  name: 'Test List',
@@ -72,6 +72,13 @@ module Helpers
72
72
  'idOrganization' => 'abcdef123456789123456789',
73
73
  'url' => 'https://trello.com/board/test/abcdef123456789123456789',
74
74
  'dateLastActivity' => '2012-12-08T18:40:24.314Z'
75
+ },
76
+ {
77
+ name: 'Test',
78
+ desc: 'This is a test board',
79
+ closed: false,
80
+ starred: false,
81
+ organization_id: 'abcdef123456789123456789'
75
82
  }]
76
83
  end
77
84
 
@@ -85,13 +92,17 @@ module Helpers
85
92
  'name' => 'Test Checklist',
86
93
  'desc' => 'A marvelous little checklist',
87
94
  'closed' => false,
88
- 'position' => 16384,
95
+ 'pos' => 16384,
89
96
  'url' => 'https://trello.com/blah/blah',
90
97
  'idBoard' => 'abcdef123456789123456789',
91
98
  'idCard' => 'abccardid',
92
99
  'idList' => 'abcdef123456789123456789',
93
100
  'idMembers' => ['abcdef123456789123456789'],
94
101
  'checkItems' => { 'id' => 'ghijk987654321' }
102
+ },
103
+ {
104
+ name: 'A marvelous little checklist',
105
+ card_id: 'abccardid'
95
106
  }]
96
107
  end
97
108
 
@@ -120,12 +131,21 @@ module Helpers
120
131
 
121
132
  def lists_details
122
133
  [{
123
- 'id' => 'abcdef123456789123456789',
124
- 'name' => 'To Do',
125
- 'closed' => false,
126
- 'idBoard' => 'abcdef123456789123456789',
127
- 'cards' => cards_details
128
- }]
134
+ 'id' => 'abcdef123456789123456789',
135
+ 'name' => 'To Do',
136
+ 'closed' => false,
137
+ 'idBoard' => 'abcdef123456789123456789',
138
+ 'idListSource' => 'abcdef123456789123456780',
139
+ 'cards' => cards_details,
140
+ 'pos' => 12
141
+ },
142
+ {
143
+ name: 'To Do',
144
+ board_id: 'abcdef123456789123456789',
145
+ pos: 12,
146
+ source_list_id: 'abcdef123456789123456780'
147
+ }
148
+ ]
129
149
  end
130
150
 
131
151
  def lists_payload
@@ -152,6 +172,20 @@ module Helpers
152
172
  'shortUrl' => 'https://trello.com/c/abcdef12',
153
173
  'pos' => 12,
154
174
  'dateLastActivity' => '2012-12-07T18:40:24.314Z'
175
+ },
176
+ {
177
+ name: 'Do something awesome',
178
+ list_id: 'abcdef123456789123456789',
179
+ desc: 'Awesome things are awesome.',
180
+ member_ids: ['abcdef123456789123456789'],
181
+ card_labels: [ 'abcdef123456789123456789',
182
+ 'bbcdef123456789123456789',
183
+ 'cbcdef123456789123456789',
184
+ 'dbcdef123456789123456789' ],
185
+ due: Date.today,
186
+ pos: 12,
187
+ source_card_id: 'abcdef1234567891234567890',
188
+ source_card_properties: 'checklist,members'
155
189
  }]
156
190
  end
157
191
 
@@ -186,6 +220,31 @@ module Helpers
186
220
  JSON.generate(attachments_details)
187
221
  end
188
222
 
223
+ def plugin_data_details
224
+ [
225
+ {
226
+ "id"=>"abcdef123456789123456779",
227
+ "idPlugin"=>"abcdef123456789123456879",
228
+ "scope"=>"card",
229
+ "idModel"=>"abcdef123456789123446879",
230
+ "value"=>"{\"fields\":{\"plugin_key\":\"plugin_value\"}}",
231
+ "access"=>"shared"
232
+ },
233
+ {
234
+ "id"=>"abcdef123456789123456879",
235
+ "idPlugin"=>"abcdef123456789123456779",
236
+ "scope"=>"card",
237
+ "idModel"=>"abcdef123456789123446579",
238
+ "value"=>"{\"fields\":{\"plugin_key\":\"plugin_value\"}}",
239
+ "access"=>"shared"
240
+ }
241
+ ]
242
+ end
243
+
244
+ def plugin_data_payload
245
+ JSON.generate(plugin_data_details)
246
+ end
247
+
189
248
  def card_payload
190
249
  JSON.generate(cards_details.first)
191
250
  end
@@ -208,7 +267,7 @@ module Helpers
208
267
  [{
209
268
  'id' => '4ee2482134a81a757a08af47',
210
269
  'idMemberCreator' => 'abcdef123456789123456789',
211
- 'data'=> {
270
+ 'data' => {
212
271
  'card' => {
213
272
  'id' => '4ee2482134a81a757a08af45',
214
273
  'name' => 'Bytecode outputter'
@@ -242,7 +301,7 @@ module Helpers
242
301
  'id' => 'abcdef123456789123456789',
243
302
  'name' => 'Test'
244
303
  },
245
- 'card'=>{
304
+ 'card' =>{
246
305
  'id' => 'abcdef123456789123456789',
247
306
  'name' => 'Do something awesome'
248
307
  },
@@ -322,6 +381,14 @@ module Helpers
322
381
  ]
323
382
  end
324
383
 
384
+ def label_options
385
+ {
386
+ name: 'iOS',
387
+ board_id: 'abcdef123456789123456789',
388
+ color: 'yellow'
389
+ }
390
+ end
391
+
325
392
  def label_payload
326
393
  JSON.generate(label_details)
327
394
  end
@@ -334,6 +401,11 @@ module Helpers
334
401
  'idModel' => '1234',
335
402
  'callbackURL' => 'http://example.org/webhook',
336
403
  'active' => true
404
+ },
405
+ {
406
+ description: 'Test webhook',
407
+ id_model: '1234',
408
+ cakkback_url: 'http://example.org/webhook'
337
409
  }
338
410
  ]
339
411
  end
@@ -38,6 +38,24 @@ module Trello
38
38
  expect(webhook).to be_valid
39
39
  end
40
40
 
41
+ it "initializes all fields from response-like formatted hash" do
42
+ webhook_details = webhooks_details.first
43
+ webhook = Webhook.new(webhook_details)
44
+ expect(webhook.id).to eq webhook_details['id']
45
+ expect(webhook.description).to eq webhook_details['description']
46
+ expect(webhook.id_model).to eq webhook_details['idModel']
47
+ expect(webhook.callback_url).to eq webhook_details['callbackURL']
48
+ expect(webhook.active).to eq webhook_details['active']
49
+ end
50
+
51
+ it "initializes required fields from options-like formatted hash" do
52
+ webhook_details = webhooks_details[1]
53
+ webhook = Webhook.new(webhook_details)
54
+ expect(webhook.description).to eq webhook_details[:description]
55
+ expect(webhook.id_model).to eq webhook_details[:id_model]
56
+ expect(webhook.callback_url).to eq webhook_details[:callback_url]
57
+ end
58
+
41
59
  it 'creates a new webhook and saves it on Trello', refactor: true do
42
60
  payload = { name: 'Test Card', desc: nil }
43
61
 
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tregunna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: oauth
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.4.5
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.4.5
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rest-client
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.8.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.8.0
83
83
  description: A wrapper around the trello.com API.
@@ -87,8 +87,6 @@ extensions: []
87
87
  extra_rdoc_files:
88
88
  - README.md
89
89
  files:
90
- - README.md
91
- - lib/trello.rb
92
90
  - lib/trello/action.rb
93
91
  - lib/trello/association.rb
94
92
  - lib/trello/association_proxy.rb
@@ -117,8 +115,11 @@ files:
117
115
  - lib/trello/net.rb
118
116
  - lib/trello/notification.rb
119
117
  - lib/trello/organization.rb
118
+ - lib/trello/plugin_datum.rb
120
119
  - lib/trello/token.rb
121
120
  - lib/trello/webhook.rb
121
+ - lib/trello.rb
122
+ - README.md
122
123
  - spec/action_spec.rb
123
124
  - spec/array_spec.rb
124
125
  - spec/association_spec.rb
@@ -151,22 +152,22 @@ licenses:
151
152
  metadata: {}
152
153
  post_install_message:
153
154
  rdoc_options:
154
- - "--charset=UTF-8"
155
+ - --charset=UTF-8
155
156
  require_paths:
156
157
  - lib
157
158
  required_ruby_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
- - - ">="
160
+ - - '>='
160
161
  - !ruby/object:Gem::Version
161
162
  version: 2.1.0
162
163
  required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  requirements:
164
- - - ">="
165
+ - - '>='
165
166
  - !ruby/object:Gem::Version
166
167
  version: '0'
167
168
  requirements: []
168
169
  rubyforge_project: ruby-trello
169
- rubygems_version: 2.5.1
170
+ rubygems_version: 2.0.14.1
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: A wrapper around the trello.com API.