ruby-trello 2.0.0 → 2.0.1
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.
- checksums.yaml +5 -5
- data/README.md +57 -8
- data/lib/trello.rb +1 -3
- data/lib/trello/action.rb +6 -6
- data/lib/trello/attachment.rb +13 -10
- data/lib/trello/board.rb +11 -1
- data/lib/trello/card.rb +33 -22
- data/lib/trello/checklist.rb +14 -13
- data/lib/trello/client.rb +1 -1
- data/lib/trello/comment.rb +4 -4
- data/lib/trello/error.rb +12 -0
- data/lib/trello/item.rb +7 -7
- data/lib/trello/item_state.rb +3 -3
- data/lib/trello/label.rb +5 -5
- data/lib/trello/label_name.rb +10 -10
- data/lib/trello/list.rb +6 -6
- data/lib/trello/member.rb +8 -8
- data/lib/trello/notification.rb +6 -6
- data/lib/trello/organization.rb +11 -11
- data/lib/trello/plugin_datum.rb +6 -6
- data/lib/trello/token.rb +6 -5
- data/lib/trello/webhook.rb +5 -5
- data/spec/action_spec.rb +21 -0
- data/spec/board_spec.rb +13 -0
- data/spec/card_spec.rb +65 -0
- data/spec/checklist_spec.rb +39 -3
- data/spec/client_spec.rb +5 -1
- data/spec/item_spec.rb +20 -0
- data/spec/label_spec.rb +20 -0
- data/spec/list_spec.rb +21 -0
- data/spec/member_spec.rb +23 -0
- data/spec/notification_spec.rb +21 -0
- data/spec/organization_spec.rb +26 -0
- data/spec/token_spec.rb +19 -0
- data/spec/webhook_spec.rb +20 -0
- metadata +23 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 77b35b3b765d1056e69ec92a4d403439849c66edfdb01747d590d79026b7ac67
|
|
4
|
+
data.tar.gz: 35173e15c5deb8a4c8404831c2cb524e3b8283cc60ac69d0d9519b9b9b22d66c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 155bdc62579174c62bf3ade75dd2921cdfb29aa5ced74176d90ea62a94fa279f0e164a54cd0970392296fa04dec7d53a293d45bb188f9eeac3f662d23109f309
|
|
7
|
+
data.tar.gz: d4e75692b37cd6d1befa4d14dff5bce2acdca231a90287e898af1cadcaec4d5f006e8fb6ed05aeeb6982ab741a1f93e003bda3b8f3aa1eb9974fcdff9a6fd920
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](http://travis-ci.org/jeremytregunna/ruby-trello) [](https://gemnasium.com/jeremytregunna/ruby-trello)
|
|
5
5
|
[](https://codeclimate.com/github/jeremytregunna/ruby-trello)
|
|
6
6
|
|
|
7
|
-
This library implements the [Trello](http://www.trello.com/) [API](
|
|
7
|
+
This library implements the [Trello](http://www.trello.com/) [API](https://developers.trello.com/).
|
|
8
8
|
|
|
9
9
|
Trello is an awesome tool for organization. Not just aimed at developers, but everybody.
|
|
10
10
|
Seriously, [check it out](http://www.trello.com/).
|
|
@@ -22,12 +22,12 @@ to, please [let us know](https://trello.com/card/spot-a-bug-report-it/4f092b2ee2
|
|
|
22
22
|
|
|
23
23
|
Supports Ruby 2.1.0 or newer.
|
|
24
24
|
|
|
25
|
-
Use version 1.3.0 or earlier for
|
|
26
|
-
Use version 1.4.x or earlier for
|
|
25
|
+
Use version 1.3.0 or earlier for Ruby 1.9.3 support.
|
|
26
|
+
Use version 1.4.x or earlier for Ruby 2.0.0 support.
|
|
27
27
|
|
|
28
28
|
## Configuration
|
|
29
29
|
|
|
30
|
-
####Basic authorization:
|
|
30
|
+
#### Basic authorization:
|
|
31
31
|
|
|
32
32
|
1. Get your API public key from Trello via the irb console:
|
|
33
33
|
|
|
@@ -50,7 +50,7 @@ Trello.configure do |config|
|
|
|
50
50
|
end
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
####2-legged OAuth authorization
|
|
53
|
+
#### 2-legged OAuth authorization
|
|
54
54
|
|
|
55
55
|
```ruby
|
|
56
56
|
Trello.configure do |config|
|
|
@@ -61,7 +61,7 @@ Trello.configure do |config|
|
|
|
61
61
|
end
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
####3-legged OAuth authorization
|
|
64
|
+
#### 3-legged OAuth authorization
|
|
65
65
|
|
|
66
66
|
```ruby
|
|
67
67
|
Trello.configure do |config|
|
|
@@ -72,18 +72,67 @@ Trello.configure do |config|
|
|
|
72
72
|
end
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
All the calls this library
|
|
75
|
+
All the calls this library makes to Trello require authentication using these keys. Be sure to protect them.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
#### Usage
|
|
78
|
+
|
|
79
|
+
So let's say you want to get information about the user *bobtester*. We can do something like this:
|
|
78
80
|
|
|
79
81
|
```ruby
|
|
80
82
|
bob = Trello::Member.find("bobtester")
|
|
83
|
+
|
|
81
84
|
# Print out his name
|
|
82
85
|
puts bob.full_name # "Bob Tester"
|
|
86
|
+
|
|
83
87
|
# Print his bio
|
|
84
88
|
puts bob.bio # A wonderfully delightful test user
|
|
89
|
+
|
|
85
90
|
# How about a list of his boards?
|
|
86
91
|
bob.boards
|
|
92
|
+
|
|
93
|
+
# And then to read the lists of the first board do :
|
|
94
|
+
bob.boards.first.lists
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
##### Accessing specific items
|
|
98
|
+
|
|
99
|
+
There is no find by name method in the trello API, to access a specific item, you have to know it's ID.
|
|
100
|
+
The best way is to pretty print the elements and then find the id of the element you are looking for.
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
# With bob
|
|
104
|
+
pp bob.boards # Will pretty print all boards, allowing us to find our board id
|
|
105
|
+
|
|
106
|
+
# We can now access it's lists
|
|
107
|
+
pp Trello::Board.find( board_id ).lists # will pretty print all lists. Let's get the list id
|
|
108
|
+
|
|
109
|
+
# We can now access the cards of the list
|
|
110
|
+
pp Trello::List.find( list_id ).cards
|
|
111
|
+
|
|
112
|
+
# We can now access the checklists of the card
|
|
113
|
+
pp Trello::Card.find( card_id ).checklists
|
|
114
|
+
|
|
115
|
+
# and so on ...
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
##### Changing a checkbox state
|
|
119
|
+
```ruby
|
|
120
|
+
# First get your checklist id
|
|
121
|
+
checklist = Trello::Checklist.find( checklist_id )
|
|
122
|
+
|
|
123
|
+
# At this point, there is no more ids. To get your checklist item,
|
|
124
|
+
# you have to know it's position (same as in the trello interface).
|
|
125
|
+
# Let's take the first
|
|
126
|
+
checklist_item = checklist.items.first
|
|
127
|
+
|
|
128
|
+
# Then we can read the status
|
|
129
|
+
checklist_item.state # return 'complete' or 'incomplete'
|
|
130
|
+
|
|
131
|
+
# We can update it (note we call update_item_state from checklist, not from checklist_item)
|
|
132
|
+
checklist.update_item_state( checklist_item.id, 'complete' ) # or 'incomplete'
|
|
133
|
+
|
|
134
|
+
# You can also use true or false instead of 'complete' or 'incomplete'
|
|
135
|
+
checklist.update_item_state( checklist_item.id, true ) # or false
|
|
87
136
|
```
|
|
88
137
|
|
|
89
138
|
#### Multiple Users
|
data/lib/trello.rb
CHANGED
|
@@ -37,6 +37,7 @@ require 'addressable/uri'
|
|
|
37
37
|
#
|
|
38
38
|
# Feel free to {peruse and participate in our Trello board}[https://trello.com/board/ruby-trello/4f092b2ee23cb6fe6d1aaabd]. It's completely open to the public.
|
|
39
39
|
module Trello
|
|
40
|
+
autoload :Error, 'trello/error'
|
|
40
41
|
autoload :Action, 'trello/action'
|
|
41
42
|
autoload :Comment, 'trello/comment'
|
|
42
43
|
autoload :Association, 'trello/association'
|
|
@@ -75,9 +76,6 @@ module Trello
|
|
|
75
76
|
# Version of the Trello API that we use by default.
|
|
76
77
|
API_VERSION = 1
|
|
77
78
|
|
|
78
|
-
# Raise this when we hit a Trello error.
|
|
79
|
-
Error = Class.new(StandardError)
|
|
80
|
-
|
|
81
79
|
# This specific error is thrown when your access token is invalid. You should get a new one.
|
|
82
80
|
InvalidAccessToken = Class.new(Error)
|
|
83
81
|
|
data/lib/trello/action.rb
CHANGED
|
@@ -38,12 +38,12 @@ module Trello
|
|
|
38
38
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
39
39
|
# an Action.
|
|
40
40
|
def update_fields(fields)
|
|
41
|
-
attributes[:id] = fields['id']
|
|
42
|
-
attributes[:type] = fields['type']
|
|
43
|
-
attributes[:data] = fields['data']
|
|
44
|
-
attributes[:date] = Time.iso8601(fields['date'])
|
|
45
|
-
attributes[:member_creator_id] = fields['idMemberCreator']
|
|
46
|
-
attributes[:member_participant] = fields['member']
|
|
41
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
42
|
+
attributes[:type] = fields['type'] || attributes[:type]
|
|
43
|
+
attributes[:data] = fields['data'] || attributes[:data]
|
|
44
|
+
attributes[:date] = Time.iso8601(fields['date']) rescue nil if fields.has_key?('date')
|
|
45
|
+
attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id]
|
|
46
|
+
attributes[:member_participant] = fields['member'] || attributes[:member_participant]
|
|
47
47
|
self
|
|
48
48
|
end
|
|
49
49
|
|
data/lib/trello/attachment.rb
CHANGED
|
@@ -7,6 +7,8 @@ module Trello
|
|
|
7
7
|
# @return [String]
|
|
8
8
|
# @!attribute url
|
|
9
9
|
# @return [String]
|
|
10
|
+
# @!attribute pos
|
|
11
|
+
# @return [Float]
|
|
10
12
|
# @!attribute bytes
|
|
11
13
|
# @return [Fixnum]
|
|
12
14
|
# @!attribute date
|
|
@@ -16,21 +18,22 @@ module Trello
|
|
|
16
18
|
# @!attribute mime_type
|
|
17
19
|
# @return [String]
|
|
18
20
|
class Attachment < BasicData
|
|
19
|
-
register_attributes :name, :id, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
|
|
21
|
+
register_attributes :name, :id, :pos, :url, :bytes, :member_id, :date, :is_upload, :mime_type, :previews
|
|
20
22
|
# Update the fields of an attachment.
|
|
21
23
|
#
|
|
22
24
|
# Supply a hash of stringkeyed data retrieved from the Trello API representing
|
|
23
25
|
# an attachment.
|
|
24
26
|
def update_fields(fields)
|
|
25
|
-
attributes[:name] = fields['name']
|
|
26
|
-
attributes[:id] = fields['id']
|
|
27
|
-
attributes[:
|
|
28
|
-
attributes[:
|
|
29
|
-
attributes[:
|
|
30
|
-
attributes[:
|
|
31
|
-
attributes[:
|
|
32
|
-
attributes[:
|
|
33
|
-
attributes[:
|
|
27
|
+
attributes[:name] = fields['name'] || attributes[:name]
|
|
28
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
29
|
+
attributes[:pos] = fields['pos'] || attributes[:pos]
|
|
30
|
+
attributes[:url] = fields['url'] || attributes[:url]
|
|
31
|
+
attributes[:bytes] = fields['bytes'].to_i || attributes[:bytes]
|
|
32
|
+
attributes[:member_id] = fields['idMember'] || attributes[:member_id]
|
|
33
|
+
attributes[:date] = Time.parse(fields['date']).presence || attributes[:date]
|
|
34
|
+
attributes[:is_upload] = fields['isUpload'] if fields.has_key?('isUpload')
|
|
35
|
+
attributes[:mime_type] = fields['mimeType'] || attributes[:mime_type]
|
|
36
|
+
attributes[:previews] = fields['previews'] if fields.has_key?('previews')
|
|
34
37
|
self
|
|
35
38
|
end
|
|
36
39
|
end
|
data/lib/trello/board.rb
CHANGED
|
@@ -151,12 +151,22 @@ module Trello
|
|
|
151
151
|
#
|
|
152
152
|
# This method, when called, can take a hash table with a filter key containing any
|
|
153
153
|
# of the following values:
|
|
154
|
-
# :filter => [ :none, :normal, :owners, :all ] # default :all
|
|
154
|
+
# :filter => [ :none, :normal, :owners, :admins, :all ] # default :all
|
|
155
155
|
many :members, filter: :all
|
|
156
156
|
|
|
157
|
+
# Returns a list of checklists associated with the board.
|
|
158
|
+
#
|
|
159
|
+
# The options hash may have a filter key which can have its value set as any
|
|
160
|
+
# of the following values:
|
|
161
|
+
# :filter => [ :none, :all ] # default :all
|
|
162
|
+
many :checklists, filter: :all
|
|
163
|
+
|
|
157
164
|
# Returns a reference to the organization this board belongs to.
|
|
158
165
|
one :organization, path: :organizations, using: :organization_id
|
|
159
166
|
|
|
167
|
+
# Returns a list of plugins associated with the board
|
|
168
|
+
many :plugin_data, path: "pluginData"
|
|
169
|
+
|
|
160
170
|
def labels(params = {})
|
|
161
171
|
# Set the limit to as high as possible given there is no pagination in this API.
|
|
162
172
|
params[:limit] = 1000 unless params[:limit]
|
data/lib/trello/card.rb
CHANGED
|
@@ -169,28 +169,29 @@ module Trello
|
|
|
169
169
|
#
|
|
170
170
|
# @return [Trello::Card] self
|
|
171
171
|
def update_fields(fields)
|
|
172
|
-
attributes[:id] = fields[SYMBOL_TO_STRING[:id]]
|
|
173
|
-
attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]]
|
|
174
|
-
attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name]
|
|
175
|
-
attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]] || fields[:desc]
|
|
176
|
-
attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil
|
|
177
|
-
attributes[:due]
|
|
178
|
-
attributes[:due_complete] = fields[SYMBOL_TO_STRING[:due_complete]]
|
|
179
|
-
attributes[:
|
|
180
|
-
attributes[:
|
|
181
|
-
attributes[:
|
|
182
|
-
attributes[:
|
|
183
|
-
attributes[:
|
|
184
|
-
attributes[:
|
|
185
|
-
attributes[:
|
|
186
|
-
attributes[:
|
|
187
|
-
attributes[:
|
|
188
|
-
attributes[:
|
|
189
|
-
attributes[:
|
|
190
|
-
attributes[:
|
|
191
|
-
attributes[:
|
|
192
|
-
attributes[:
|
|
193
|
-
attributes[:
|
|
172
|
+
attributes[:id] = fields[SYMBOL_TO_STRING[:id]] || attributes[:id]
|
|
173
|
+
attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]] || attributes[:short_id]
|
|
174
|
+
attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name] || attributes[:name]
|
|
175
|
+
attributes[:desc] = fields[SYMBOL_TO_STRING[:desc]] || fields[:desc] || attributes[:desc]
|
|
176
|
+
attributes[:due] = Time.iso8601(fields[SYMBOL_TO_STRING[:due]]) rescue nil if fields.has_key?(SYMBOL_TO_STRING[:due])
|
|
177
|
+
attributes[:due] = fields[:due] if fields.has_key?(:due)
|
|
178
|
+
attributes[:due_complete] = fields[SYMBOL_TO_STRING[:due_complete]] if fields.has_key?(SYMBOL_TO_STRING[:due_complete])
|
|
179
|
+
attributes[:due_complete] ||= false
|
|
180
|
+
attributes[:closed] = fields[SYMBOL_TO_STRING[:closed]] if fields.has_key?(SYMBOL_TO_STRING[:closed])
|
|
181
|
+
attributes[:url] = fields[SYMBOL_TO_STRING[:url]] || attributes[:url]
|
|
182
|
+
attributes[:short_url] = fields[SYMBOL_TO_STRING[:short_url]] || attributes[:short_url]
|
|
183
|
+
attributes[:board_id] = fields[SYMBOL_TO_STRING[:board_id]] || attributes[:board_id]
|
|
184
|
+
attributes[:member_ids] = fields[SYMBOL_TO_STRING[:member_ids]] || fields[:member_ids] || attributes[:member_ids]
|
|
185
|
+
attributes[:list_id] = fields[SYMBOL_TO_STRING[:list_id]] || fields[:list_id] || attributes[:list_id]
|
|
186
|
+
attributes[:pos] = fields[SYMBOL_TO_STRING[:pos]] || fields[:pos] || attributes[:pos]
|
|
187
|
+
attributes[:labels] = (fields[SYMBOL_TO_STRING[:labels]] || []).map { |lbl| Trello::Label.new(lbl) }.presence || attributes[:labels].presence || []
|
|
188
|
+
attributes[:card_labels] = fields[SYMBOL_TO_STRING[:card_labels]] || fields[:card_labels] || attributes[:card_labels]
|
|
189
|
+
attributes[:last_activity_date] = Time.iso8601(fields[SYMBOL_TO_STRING[:last_activity_date]]) rescue nil if fields.has_key?(SYMBOL_TO_STRING[:last_activity_date])
|
|
190
|
+
attributes[:cover_image_id] = fields[SYMBOL_TO_STRING[:cover_image_id]] || attributes[:cover_image_id]
|
|
191
|
+
attributes[:badges] = fields[SYMBOL_TO_STRING[:badges]] || attributes[:badges]
|
|
192
|
+
attributes[:card_members] = fields[SYMBOL_TO_STRING[:card_members]] || attributes[:card_members]
|
|
193
|
+
attributes[:source_card_id] = fields[SYMBOL_TO_STRING[:source_card_id]] || fields[:source_card_id] || attributes[:source_card_id]
|
|
194
|
+
attributes[:source_card_properties] = fields[SYMBOL_TO_STRING[:source_card_properties]] || fields[:source_card_properties] || attributes[:source_card_properties]
|
|
194
195
|
self
|
|
195
196
|
end
|
|
196
197
|
|
|
@@ -342,6 +343,16 @@ module Trello
|
|
|
342
343
|
end
|
|
343
344
|
end
|
|
344
345
|
|
|
346
|
+
# Moves this card to the given list no matter which board it is on
|
|
347
|
+
def move_to_list_on_any_board(list_id)
|
|
348
|
+
list = List.find(list_id)
|
|
349
|
+
if board.id == list.board_id
|
|
350
|
+
move_to_list(list_id)
|
|
351
|
+
else
|
|
352
|
+
move_to_board(Board.find(list.board_id), list)
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
345
356
|
# Move this card to the given board (and optional list on this board)
|
|
346
357
|
def move_to_board(new_board, new_list = nil)
|
|
347
358
|
unless board_id == new_board.id
|
data/lib/trello/checklist.rb
CHANGED
|
@@ -45,17 +45,17 @@ module Trello
|
|
|
45
45
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
46
46
|
# a checklist.
|
|
47
47
|
def update_fields(fields)
|
|
48
|
-
attributes[:id] = fields['id']
|
|
49
|
-
attributes[:name] = fields['name'] || fields[:name]
|
|
50
|
-
attributes[:description] = fields['desc']
|
|
51
|
-
attributes[:closed] = fields['closed']
|
|
52
|
-
attributes[:url] = fields['url']
|
|
53
|
-
attributes[:check_items] = fields['checkItems']
|
|
54
|
-
attributes[:position] = fields['pos']
|
|
55
|
-
attributes[:board_id] = fields['idBoard']
|
|
56
|
-
attributes[:card_id] = fields['idCard'] || fields[:card_id]
|
|
57
|
-
attributes[:list_id] = fields['idList']
|
|
58
|
-
attributes[:member_ids] = fields['idMembers']
|
|
48
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
49
|
+
attributes[:name] = fields['name'] || fields[:name] || attributes[:name]
|
|
50
|
+
attributes[:description] = fields['desc'] || attributes[:description]
|
|
51
|
+
attributes[:closed] = fields['closed'] if fields.has_key?('closed')
|
|
52
|
+
attributes[:url] = fields['url'] || attributes[:url]
|
|
53
|
+
attributes[:check_items] = fields['checkItems'] if fields.has_key?('checkItems')
|
|
54
|
+
attributes[:position] = fields['pos'] || attributes[:position]
|
|
55
|
+
attributes[:board_id] = fields['idBoard'] || attributes[:board_id]
|
|
56
|
+
attributes[:card_id] = fields['idCard'] || fields[:card_id] || attributes[:card_id]
|
|
57
|
+
attributes[:list_id] = fields['idList'] || attributes[:list_id]
|
|
58
|
+
attributes[:member_ids] = fields['idMembers'] || attributes[:member_ids]
|
|
59
59
|
self
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -109,9 +109,10 @@ module Trello
|
|
|
109
109
|
|
|
110
110
|
# Update a checklist item's state, e.g.: "complete" or "incomplete"
|
|
111
111
|
def update_item_state(item_id, state)
|
|
112
|
+
state = ( state ? 'complete' : 'incomplete' ) unless state.is_a?(String)
|
|
112
113
|
client.put(
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
"/cards/#{card_id}/checkItem/#{item_id}",
|
|
115
|
+
state: state
|
|
115
116
|
)
|
|
116
117
|
end
|
|
117
118
|
|
data/lib/trello/client.rb
CHANGED
|
@@ -96,7 +96,7 @@ module Trello
|
|
|
96
96
|
|
|
97
97
|
unless [200, 201].include? response.code
|
|
98
98
|
Trello.logger.error("[#{response.code} #{name.to_s.upcase} #{uri}]: #{response.body}")
|
|
99
|
-
raise Error, response.
|
|
99
|
+
raise Error.new(response.body, response.code)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
response.body
|
data/lib/trello/comment.rb
CHANGED
|
@@ -27,10 +27,10 @@ module Trello
|
|
|
27
27
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
28
28
|
# a Comment.
|
|
29
29
|
def update_fields(fields)
|
|
30
|
-
attributes[:action_id] = fields['id']
|
|
31
|
-
attributes[:text] = fields['data']['text']
|
|
32
|
-
attributes[:date] = Time.iso8601(fields['date'])
|
|
33
|
-
attributes[:member_creator_id] = fields['idMemberCreator']
|
|
30
|
+
attributes[:action_id] = fields['id'] || attributes[:action_id]
|
|
31
|
+
attributes[:text] = fields['data']['text'] || attributes[:text]
|
|
32
|
+
attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date')
|
|
33
|
+
attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id]
|
|
34
34
|
self
|
|
35
35
|
end
|
|
36
36
|
|
data/lib/trello/error.rb
ADDED
data/lib/trello/item.rb
CHANGED
|
@@ -20,13 +20,13 @@ module Trello
|
|
|
20
20
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
21
21
|
# an item.
|
|
22
22
|
def update_fields(fields)
|
|
23
|
-
attributes[:id] = fields['id']
|
|
24
|
-
attributes[:card_id] = fields['idCard']
|
|
25
|
-
attributes[:checklist_id] = fields['idChecklist']
|
|
26
|
-
attributes[:name] = fields['name']
|
|
27
|
-
attributes[:type] = fields['type']
|
|
28
|
-
attributes[:state] = fields['state']
|
|
29
|
-
attributes[:pos] = fields['pos']
|
|
23
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
24
|
+
attributes[:card_id] = fields['idCard'] || attributes[:card_id]
|
|
25
|
+
attributes[:checklist_id] = fields['idChecklist'] || attributes[:checklist_id]
|
|
26
|
+
attributes[:name] = fields['name'] || attributes[:name]
|
|
27
|
+
attributes[:type] = fields['type'] || attributes[:type]
|
|
28
|
+
attributes[:state] = fields['state'] || attributes[:state]
|
|
29
|
+
attributes[:pos] = fields['pos'] || attributes[:pos]
|
|
30
30
|
self
|
|
31
31
|
end
|
|
32
32
|
|
data/lib/trello/item_state.rb
CHANGED
|
@@ -16,9 +16,9 @@ module Trello
|
|
|
16
16
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
17
17
|
# an item state.
|
|
18
18
|
def update_fields(fields)
|
|
19
|
-
attributes[:id] = fields['id']
|
|
20
|
-
attributes[:state] = fields['state']
|
|
21
|
-
attributes[:item_id] = fields['idCheckItem']
|
|
19
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
20
|
+
attributes[:state] = fields['state'] || attributes[:state]
|
|
21
|
+
attributes[:item_id] = fields['idCheckItem'] || attributes[:item_id]
|
|
22
22
|
self
|
|
23
23
|
end
|
|
24
24
|
|
data/lib/trello/label.rb
CHANGED
|
@@ -64,11 +64,11 @@ module Trello
|
|
|
64
64
|
# Supply a hash of stringkeyed data retrieved from the Trello API representing
|
|
65
65
|
# a label.
|
|
66
66
|
def update_fields(fields)
|
|
67
|
-
attributes[:id] = fields['id']
|
|
68
|
-
attributes[:name] = fields['name'] || fields[:name]
|
|
69
|
-
attributes[:color] = fields['color'] || fields[:color]
|
|
70
|
-
attributes[:board_id] = fields['idBoard'] || fields[:board_id]
|
|
71
|
-
attributes[:uses] = fields['uses']
|
|
67
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
68
|
+
attributes[:name] = fields['name'] || fields[:name] || attributes[:name]
|
|
69
|
+
attributes[:color] = fields['color'] || fields[:color] || attributes[:color]
|
|
70
|
+
attributes[:board_id] = fields['idBoard'] || fields[:board_id] || attributes[:board_id]
|
|
71
|
+
attributes[:uses] = fields['uses'] if fields.has_key?('uses')
|
|
72
72
|
self
|
|
73
73
|
end
|
|
74
74
|
|
data/lib/trello/label_name.rb
CHANGED
|
@@ -9,16 +9,16 @@ module Trello
|
|
|
9
9
|
# Supply a hash of stringkeyed data retrieved from the Trello API representing
|
|
10
10
|
# a label.
|
|
11
11
|
def update_fields(fields)
|
|
12
|
-
attributes[:yellow] = fields['yellow']
|
|
13
|
-
attributes[:red] = fields['red']
|
|
14
|
-
attributes[:orange] = fields['orange']
|
|
15
|
-
attributes[:green] = fields['green']
|
|
16
|
-
attributes[:purple] = fields['purple']
|
|
17
|
-
attributes[:blue] = fields['blue']
|
|
18
|
-
attributes[:sky] = fields['sky']
|
|
19
|
-
attributes[:pink] = fields['pink']
|
|
20
|
-
attributes[:lime] = fields['lime']
|
|
21
|
-
attributes[:black] = fields['black']
|
|
12
|
+
attributes[:yellow] = fields['yellow'] || attributes[:yellow]
|
|
13
|
+
attributes[:red] = fields['red'] || attributes[:red]
|
|
14
|
+
attributes[:orange] = fields['orange'] || attributes[:orange]
|
|
15
|
+
attributes[:green] = fields['green'] || attributes[:green]
|
|
16
|
+
attributes[:purple] = fields['purple'] || attributes[:purple]
|
|
17
|
+
attributes[:blue] = fields['blue'] || attributes[:blue]
|
|
18
|
+
attributes[:sky] = fields['sky'] || attributes[:sky]
|
|
19
|
+
attributes[:pink] = fields['pink'] || attributes[:pink]
|
|
20
|
+
attributes[:lime] = fields['lime'] || attributes[:lime]
|
|
21
|
+
attributes[:black] = fields['black'] || attributes[:black]
|
|
22
22
|
|
|
23
23
|
self
|
|
24
24
|
end
|
data/lib/trello/list.rb
CHANGED
|
@@ -41,12 +41,12 @@ module Trello
|
|
|
41
41
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
42
42
|
# a List.
|
|
43
43
|
def update_fields(fields)
|
|
44
|
-
attributes[:id] = fields['id']
|
|
45
|
-
attributes[:name] = fields['name'] || fields[:name]
|
|
46
|
-
attributes[:closed] = fields['closed']
|
|
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]
|
|
44
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
45
|
+
attributes[:name] = fields['name'] || fields[:name] || attributes[:name]
|
|
46
|
+
attributes[:closed] = fields['closed'] if fields.has_key?('closed')
|
|
47
|
+
attributes[:board_id] = fields['idBoard'] || fields[:board_id] || attributes[:board_id]
|
|
48
|
+
attributes[:pos] = fields['pos'] || fields[:pos] || attributes[:pos]
|
|
49
|
+
attributes[:source_list_id] = fields['idListSource'] || fields[:source_list_id] || attributes[:source_list_id]
|
|
50
50
|
self
|
|
51
51
|
end
|
|
52
52
|
|
data/lib/trello/member.rb
CHANGED
|
@@ -39,14 +39,14 @@ module Trello
|
|
|
39
39
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
40
40
|
# an Member.
|
|
41
41
|
def update_fields(fields)
|
|
42
|
-
attributes[:id] = fields['id']
|
|
43
|
-
attributes[:full_name] = fields['fullName']
|
|
44
|
-
attributes[:email] = fields['email']
|
|
45
|
-
attributes[:username] = fields['username']
|
|
46
|
-
attributes[:initials] = fields['initials']
|
|
47
|
-
attributes[:avatar_id] = fields['avatarHash']
|
|
48
|
-
attributes[:bio] = fields['bio']
|
|
49
|
-
attributes[:url] = fields['url']
|
|
42
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
43
|
+
attributes[:full_name] = fields['fullName'] || attributes[:full_name]
|
|
44
|
+
attributes[:email] = fields['email'] || attributes[:email]
|
|
45
|
+
attributes[:username] = fields['username'] || attributes[:username]
|
|
46
|
+
attributes[:initials] = fields['initials'] || attributes[:initials]
|
|
47
|
+
attributes[:avatar_id] = fields['avatarHash'] || attributes[:avatar_id]
|
|
48
|
+
attributes[:bio] = fields['bio'] || attributes[:bio]
|
|
49
|
+
attributes[:url] = fields['url'] || attributes[:url]
|
|
50
50
|
self
|
|
51
51
|
end
|
|
52
52
|
|
data/lib/trello/notification.rb
CHANGED
|
@@ -25,12 +25,12 @@ module Trello
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def update_fields(fields)
|
|
28
|
-
attributes[:id] = fields['id']
|
|
29
|
-
attributes[:unread] = fields['unread']
|
|
30
|
-
attributes[:type] = fields['type']
|
|
31
|
-
attributes[:date] = fields['date']
|
|
32
|
-
attributes[:data] = fields['data']
|
|
33
|
-
attributes[:member_creator_id] = fields['idMemberCreator']
|
|
28
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
29
|
+
attributes[:unread] = fields['unread'] if fields.has_key?('unread')
|
|
30
|
+
attributes[:type] = fields['type'] || attributes[:type]
|
|
31
|
+
attributes[:date] = fields['date'] || attributes[:date]
|
|
32
|
+
attributes[:data] = fields['data'] || attributes[:data]
|
|
33
|
+
attributes[:member_creator_id] = fields['idMemberCreator'] || attributes[:member_creator_id]
|
|
34
34
|
self
|
|
35
35
|
end
|
|
36
36
|
|
data/lib/trello/organization.rb
CHANGED
|
@@ -34,17 +34,17 @@ module Trello
|
|
|
34
34
|
# Supply a hash of string keyed data retrieved from the Trello API representing
|
|
35
35
|
# an Organization.
|
|
36
36
|
def update_fields(fields)
|
|
37
|
-
attributes[:id] = fields['id']
|
|
38
|
-
attributes[:name] = fields['name']
|
|
39
|
-
attributes[:display_name] = fields['displayName']
|
|
40
|
-
attributes[:description] = fields['desc']
|
|
41
|
-
attributes[:url] = fields['url']
|
|
42
|
-
attributes[:invited] = fields['invited']
|
|
43
|
-
attributes[:website] = fields['website']
|
|
44
|
-
attributes[:logo_hash] = fields['logoHash']
|
|
45
|
-
attributes[:billable_member_count] = fields['billableMemberCount']
|
|
46
|
-
attributes[:active_billable_member_count] = fields['activeBillableMemberCount']
|
|
47
|
-
attributes[:memberships] = fields['memberships']
|
|
37
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
38
|
+
attributes[:name] = fields['name'] || attributes[:name]
|
|
39
|
+
attributes[:display_name] = fields['displayName'] || attributes[:display_name]
|
|
40
|
+
attributes[:description] = fields['desc'] || attributes[:description]
|
|
41
|
+
attributes[:url] = fields['url'] || attributes[:url]
|
|
42
|
+
attributes[:invited] = fields['invited'] if fields.has_key?('invited')
|
|
43
|
+
attributes[:website] = fields['website'] || attributes[:website]
|
|
44
|
+
attributes[:logo_hash] = fields['logoHash'] || attributes[:logo_hash]
|
|
45
|
+
attributes[:billable_member_count] = fields['billableMemberCount'] || attributes[:billable_member_count]
|
|
46
|
+
attributes[:active_billable_member_count] = fields['activeBillableMemberCount'] || attributes[:active_billable_member_count]
|
|
47
|
+
attributes[:memberships] = fields['memberships'] || attributes[:memberships]
|
|
48
48
|
self
|
|
49
49
|
end
|
|
50
50
|
|
data/lib/trello/plugin_datum.rb
CHANGED
|
@@ -21,12 +21,12 @@ module Trello
|
|
|
21
21
|
# Supply a hash of stringkeyed data retrieved from the Trello API representing
|
|
22
22
|
# an attachment.
|
|
23
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
|
|
28
|
-
attributes[:idModel] = fields['idModel']
|
|
29
|
-
attributes[:access] = fields['access']
|
|
24
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
25
|
+
attributes[:idPlugin] = fields['idPlugin'] || attributes[:idPlugin]
|
|
26
|
+
attributes[:scope] = fields['scope'] || attributes[:scope]
|
|
27
|
+
attributes[:value] = JSON.parse(fields['value']).presence if fields.has_key?('value')
|
|
28
|
+
attributes[:idModel] = fields['idModel'] || attributes[:idModel]
|
|
29
|
+
attributes[:access] = fields['access'] || attributes[:access]
|
|
30
30
|
self
|
|
31
31
|
end
|
|
32
32
|
end
|
data/lib/trello/token.rb
CHANGED
|
@@ -23,11 +23,12 @@ module Trello
|
|
|
23
23
|
|
|
24
24
|
# :nodoc:
|
|
25
25
|
def update_fields(fields)
|
|
26
|
-
attributes[:id] = fields['id']
|
|
27
|
-
attributes[:member_id] = fields['idMember']
|
|
28
|
-
attributes[:created_at] = Time.iso8601(fields['dateCreated'])
|
|
29
|
-
attributes[:permissions] = fields['permissions'] ||
|
|
30
|
-
attributes[:
|
|
26
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
27
|
+
attributes[:member_id] = fields['idMember'] || attributes[:member_id]
|
|
28
|
+
attributes[:created_at] = Time.iso8601(fields['dateCreated']) rescue nil if fields.has_key?('dateCreated')
|
|
29
|
+
attributes[:permissions] = fields['permissions'] || attributes[:permissions]
|
|
30
|
+
attributes[:permissions] ||= {}
|
|
31
|
+
attributes[:webhooks] = fields['webhooks'] || attributes[:webhooks]
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
# Returns a reference to the user who authorized the token.
|
data/lib/trello/webhook.rb
CHANGED
|
@@ -48,11 +48,11 @@ module Trello
|
|
|
48
48
|
|
|
49
49
|
# @return [Trello::Webhook] self
|
|
50
50
|
def update_fields(fields)
|
|
51
|
-
attributes[:id] = fields['id']
|
|
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
|
-
attributes[:active] = fields['active']
|
|
51
|
+
attributes[:id] = fields['id'] || attributes[:id]
|
|
52
|
+
attributes[:description] = fields['description'] || fields[:description] || attributes[:description]
|
|
53
|
+
attributes[:id_model] = fields['idModel'] || fields[:id_model] || attributes[:id_model]
|
|
54
|
+
attributes[:callback_url] = fields['callbackURL'] || fields[:callback_url] || attributes[:callback_url]
|
|
55
|
+
attributes[:active] = fields['active'] if fields.has_key?('active')
|
|
56
56
|
self
|
|
57
57
|
end
|
|
58
58
|
|
data/spec/action_spec.rb
CHANGED
|
@@ -124,5 +124,26 @@ module Trello
|
|
|
124
124
|
expect(action.member_creator).to_not be_nil
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
|
+
|
|
128
|
+
describe "#update_fields" do
|
|
129
|
+
it "does not set any fields when the fields argument is empty" do
|
|
130
|
+
expected = {
|
|
131
|
+
'id' => 'id',
|
|
132
|
+
'type' => 'type',
|
|
133
|
+
'data' => 'data',
|
|
134
|
+
'idMemberCreator' => 'member_creator_id',
|
|
135
|
+
'member' => 'member_participant'
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
action = Action.new(expected)
|
|
139
|
+
action.client = client
|
|
140
|
+
|
|
141
|
+
action.update_fields({})
|
|
142
|
+
|
|
143
|
+
expected.each do |key, value|
|
|
144
|
+
expect(action.send(value)).to eq expected[key]
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
127
148
|
end
|
|
128
149
|
end
|
data/spec/board_spec.rb
CHANGED
|
@@ -225,6 +225,19 @@ module Trello
|
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
227
|
|
|
228
|
+
context "checklists" do
|
|
229
|
+
before do
|
|
230
|
+
allow(client)
|
|
231
|
+
.to receive(:get)
|
|
232
|
+
.with("/boards/abcdef123456789123456789/checklists", {filter: :all})
|
|
233
|
+
.and_return checklists_payload
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it "has a list of checklists" do
|
|
237
|
+
expect(board.checklists.count).to be > 0
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
228
241
|
context "organization" do
|
|
229
242
|
before do
|
|
230
243
|
allow(client)
|
data/spec/card_spec.rb
CHANGED
|
@@ -399,6 +399,45 @@ module Trello
|
|
|
399
399
|
card.move_to_board(other_board, other_list)
|
|
400
400
|
end
|
|
401
401
|
|
|
402
|
+
it 'can be moved to a list on the same board' do
|
|
403
|
+
current_board = double(id: 'abcdef123456789123456789')
|
|
404
|
+
other_list = double(
|
|
405
|
+
id: '987654321987654321fedcba',
|
|
406
|
+
board_id: 'abcdef123456789123456789'
|
|
407
|
+
)
|
|
408
|
+
allow(List).to receive(:find).with('987654321987654321fedcba').
|
|
409
|
+
and_return(other_list)
|
|
410
|
+
allow(card).to receive(:board).and_return(current_board)
|
|
411
|
+
payload = {value: other_list.id}
|
|
412
|
+
|
|
413
|
+
expect(client)
|
|
414
|
+
.to receive(:put)
|
|
415
|
+
.with('/cards/abcdef123456789123456789/idList', payload)
|
|
416
|
+
|
|
417
|
+
card.move_to_list_on_any_board(other_list.id)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it 'can be moved to a list on another board' do
|
|
421
|
+
current_board = double(id: 'abcdef123456789123456789')
|
|
422
|
+
other_board = double(id: '987654321987654321fedcba')
|
|
423
|
+
other_list = double(
|
|
424
|
+
id: '987654321987654321aalist',
|
|
425
|
+
board_id: '987654321987654321fedcba'
|
|
426
|
+
)
|
|
427
|
+
allow(List).to receive(:find).with('987654321987654321aalist').
|
|
428
|
+
and_return(other_list)
|
|
429
|
+
allow(card).to receive(:board).and_return(current_board)
|
|
430
|
+
allow(Board).to receive(:find).with('987654321987654321fedcba').
|
|
431
|
+
and_return(other_board)
|
|
432
|
+
payload = { value: other_board.id, idList: other_list.id }
|
|
433
|
+
|
|
434
|
+
expect(client)
|
|
435
|
+
.to receive(:put)
|
|
436
|
+
.with('/cards/abcdef123456789123456789/idBoard', payload)
|
|
437
|
+
|
|
438
|
+
card.move_to_list_on_any_board(other_list.id)
|
|
439
|
+
end
|
|
440
|
+
|
|
402
441
|
it 'should not be moved if new board is identical with old board', focus: true do
|
|
403
442
|
other_board = double(id: 'abcdef123456789123456789')
|
|
404
443
|
expect(client).to_not receive(:put)
|
|
@@ -753,5 +792,31 @@ module Trello
|
|
|
753
792
|
expect(card.due_complete).to be true
|
|
754
793
|
end
|
|
755
794
|
end
|
|
795
|
+
|
|
796
|
+
describe "#update_fields" do
|
|
797
|
+
it "does not set any fields when the fields argument is empty" do
|
|
798
|
+
expected = cards_details.first
|
|
799
|
+
|
|
800
|
+
card = Card.new(expected)
|
|
801
|
+
card.client = client
|
|
802
|
+
|
|
803
|
+
card.update_fields({})
|
|
804
|
+
|
|
805
|
+
expected.each do |key, value|
|
|
806
|
+
if card.respond_to?(key) && key != 'labels'
|
|
807
|
+
expect(card.send(key)).to eq value
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
expect(card.labels).to eq expected['labels'].map { |lbl| Trello::Label.new(lbl) }
|
|
811
|
+
expect(card.short_id).to eq expected['idShort']
|
|
812
|
+
expect(card.short_url).to eq expected['shortUrl']
|
|
813
|
+
expect(card.board_id).to eq expected['idBoard']
|
|
814
|
+
expect(card.member_ids).to eq expected['idMembers']
|
|
815
|
+
expect(card.cover_image_id).to eq expected['idAttachmentCover']
|
|
816
|
+
expect(card.list_id).to eq expected['idList']
|
|
817
|
+
expect(card.card_labels).to eq expected['idLabels']
|
|
818
|
+
end
|
|
819
|
+
end
|
|
820
|
+
end
|
|
756
821
|
end
|
|
757
822
|
end
|
data/spec/checklist_spec.rb
CHANGED
|
@@ -167,12 +167,21 @@ module Trello
|
|
|
167
167
|
expected_item_id = "1234"
|
|
168
168
|
expected_state = "incomplete"
|
|
169
169
|
expected_resource =
|
|
170
|
-
"/cards/abccardid/
|
|
171
|
-
|
|
172
|
-
payload = { value: expected_state }
|
|
170
|
+
"/cards/abccardid/checkItem/#{expected_item_id}"
|
|
171
|
+
payload = { state: expected_state }
|
|
173
172
|
expect(client).to receive(:put).once.with(expected_resource, payload)
|
|
174
173
|
checklist.update_item_state(expected_item_id, expected_state)
|
|
175
174
|
end
|
|
175
|
+
|
|
176
|
+
it "updates an item's with boolean input" do
|
|
177
|
+
expected_item_id = "1234"
|
|
178
|
+
expected_state = "complete"
|
|
179
|
+
expected_resource =
|
|
180
|
+
"/cards/abccardid/checkItem/#{expected_item_id}"
|
|
181
|
+
payload = { state: expected_state }
|
|
182
|
+
expect(client).to receive(:put).once.with(expected_resource, payload)
|
|
183
|
+
checklist.update_item_state(expected_item_id, true)
|
|
184
|
+
end
|
|
176
185
|
end
|
|
177
186
|
|
|
178
187
|
context "board" do
|
|
@@ -256,5 +265,32 @@ module Trello
|
|
|
256
265
|
checklist.copy
|
|
257
266
|
end
|
|
258
267
|
end
|
|
268
|
+
|
|
269
|
+
describe "#update_fields" do
|
|
270
|
+
it "does not set any fields when the fields argument is empty" do
|
|
271
|
+
expected = {
|
|
272
|
+
'id' => 'id',
|
|
273
|
+
'name' => 'name',
|
|
274
|
+
'desc' => 'description',
|
|
275
|
+
'closed' => 'closed',
|
|
276
|
+
'url' => 'url',
|
|
277
|
+
'checkItems' => 'check_items',
|
|
278
|
+
'pos' => 'position',
|
|
279
|
+
'idBoard' => 'board_id',
|
|
280
|
+
'idCard' => 'card_id',
|
|
281
|
+
'idList' => 'list_id',
|
|
282
|
+
'idMembers' => 'member_ids'
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
checklist = Checklist.new(expected)
|
|
286
|
+
checklist.client = client
|
|
287
|
+
|
|
288
|
+
checklist.update_fields({})
|
|
289
|
+
|
|
290
|
+
expected.each do |key, value|
|
|
291
|
+
expect(checklist.send(value)).to eq expected[key]
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
259
295
|
end
|
|
260
296
|
end
|
data/spec/client_spec.rb
CHANGED
|
@@ -50,7 +50,11 @@ describe Client do
|
|
|
50
50
|
.to receive(:try_execute)
|
|
51
51
|
.and_return(response_with_non_200_status)
|
|
52
52
|
|
|
53
|
-
expect { client.get "/xxx" }.to raise_error
|
|
53
|
+
expect { client.get "/xxx" }.to raise_error do |error|
|
|
54
|
+
expect(error).to be_a(Error)
|
|
55
|
+
expect(error.message).to eq("404 error response")
|
|
56
|
+
expect(error.status_code).to eq(404)
|
|
57
|
+
end
|
|
54
58
|
end
|
|
55
59
|
end
|
|
56
60
|
end
|
data/spec/item_spec.rb
CHANGED
|
@@ -51,5 +51,25 @@ module Trello
|
|
|
51
51
|
it { expect(item).not_to be_complete }
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
+
|
|
55
|
+
describe "#update_fields" do
|
|
56
|
+
it "does not set any fields when the fields argument is empty" do
|
|
57
|
+
expected = {
|
|
58
|
+
'id' => 'id',
|
|
59
|
+
'name' => 'name',
|
|
60
|
+
'type' => 'type',
|
|
61
|
+
'state' => 'state',
|
|
62
|
+
'pos' => 'pos'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
item = Item.new(expected)
|
|
66
|
+
|
|
67
|
+
item.update_fields({})
|
|
68
|
+
|
|
69
|
+
expected.each do |key, value|
|
|
70
|
+
expect(item.send(value)).to eq expected[key]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
54
74
|
end
|
|
55
75
|
end
|
data/spec/label_spec.rb
CHANGED
|
@@ -181,5 +181,25 @@ module Trello
|
|
|
181
181
|
expect(label.board).to_not be_nil
|
|
182
182
|
end
|
|
183
183
|
end
|
|
184
|
+
|
|
185
|
+
describe "#update_fields" do
|
|
186
|
+
it "does not set any fields when the fields argument is empty" do
|
|
187
|
+
expected = {
|
|
188
|
+
'id' => 'id',
|
|
189
|
+
'name' => 'name',
|
|
190
|
+
'color' => 'color',
|
|
191
|
+
'idBoard' => 'board_id',
|
|
192
|
+
'uses' => 'uses'
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
label = Label.new(expected)
|
|
196
|
+
|
|
197
|
+
label.update_fields({})
|
|
198
|
+
|
|
199
|
+
expected.each do |key, value|
|
|
200
|
+
expect(label.send(value)).to eq expected[key]
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
184
204
|
end
|
|
185
205
|
end
|
data/spec/list_spec.rb
CHANGED
|
@@ -228,5 +228,26 @@ module Trello
|
|
|
228
228
|
list.close!
|
|
229
229
|
end
|
|
230
230
|
end
|
|
231
|
+
|
|
232
|
+
describe "#update_fields" do
|
|
233
|
+
it "does not set any fields when the fields argument is empty" do
|
|
234
|
+
expected = {
|
|
235
|
+
'id' => 'id',
|
|
236
|
+
'name' => 'name',
|
|
237
|
+
'closed' => 'closed',
|
|
238
|
+
'idBoard' => 'board_id',
|
|
239
|
+
'pos' => 'pos',
|
|
240
|
+
'idListSource' => 'source_list_id'
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
label = List.new(expected)
|
|
244
|
+
|
|
245
|
+
label.update_fields({})
|
|
246
|
+
|
|
247
|
+
expected.each do |key, value|
|
|
248
|
+
expect(label.send(value)).to eq expected[key]
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
231
252
|
end
|
|
232
253
|
end
|
data/spec/member_spec.rb
CHANGED
|
@@ -132,5 +132,28 @@ module Trello
|
|
|
132
132
|
expect { member.id = '42' }.to raise_error NoMethodError
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
|
+
|
|
136
|
+
describe "#update_fields" do
|
|
137
|
+
it "does not set any fields when the fields argument is empty" do
|
|
138
|
+
expected = {
|
|
139
|
+
'id' => 'id',
|
|
140
|
+
'fullName' => 'full_name',
|
|
141
|
+
'email' => 'email',
|
|
142
|
+
'username' => 'username',
|
|
143
|
+
'initials' => 'initials',
|
|
144
|
+
'avatarHash' => 'avatar_id',
|
|
145
|
+
'bio' => 'bio',
|
|
146
|
+
'url' => 'url'
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
member = Member.new(expected)
|
|
150
|
+
|
|
151
|
+
member.update_fields({})
|
|
152
|
+
|
|
153
|
+
expected.each do |key, value|
|
|
154
|
+
expect(member.send(value)).to eq expected[key]
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
135
158
|
end
|
|
136
159
|
end
|
data/spec/notification_spec.rb
CHANGED
|
@@ -118,5 +118,26 @@ module Trello
|
|
|
118
118
|
expect(notification.member_creator_id).to eq notification_details['idMemberCreator']
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
|
+
|
|
122
|
+
describe "#update_fields" do
|
|
123
|
+
it "does not set any fields when the fields argument is empty" do
|
|
124
|
+
expected = {
|
|
125
|
+
'id' => 'id',
|
|
126
|
+
'unread' => 'unread',
|
|
127
|
+
'type' => 'type',
|
|
128
|
+
'date' => 'date',
|
|
129
|
+
'data' => 'data',
|
|
130
|
+
'idMemberCreator' => 'member_creator_id'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
notification = Notification.new(expected)
|
|
134
|
+
|
|
135
|
+
notification.update_fields({})
|
|
136
|
+
|
|
137
|
+
expected.each do |key, value|
|
|
138
|
+
expect(notification.send(value)).to eq expected[key]
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
121
142
|
end
|
|
122
143
|
end
|
data/spec/organization_spec.rb
CHANGED
|
@@ -40,6 +40,32 @@ module Trello
|
|
|
40
40
|
expect(organization.actions.count).to be > 0
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
|
+
|
|
44
|
+
describe "#update_fields" do
|
|
45
|
+
it "does not set any fields when the fields argument is empty" do
|
|
46
|
+
expected = {
|
|
47
|
+
'id' => 'id',
|
|
48
|
+
'name' => 'name',
|
|
49
|
+
'displayName' => 'display_name',
|
|
50
|
+
'desc' => 'description',
|
|
51
|
+
'url' => 'url',
|
|
52
|
+
'invited' => 'invited',
|
|
53
|
+
'website' => 'website',
|
|
54
|
+
'logoHash' => 'logo_hash',
|
|
55
|
+
'billableMemberCount' => 'billable_member_count',
|
|
56
|
+
'activeBillableMemberCount' => 'active_billable_member_count',
|
|
57
|
+
'memberships' => 'memberships'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
organization = Organization.new(expected)
|
|
61
|
+
|
|
62
|
+
organization.update_fields({})
|
|
63
|
+
|
|
64
|
+
expected.each do |key, value|
|
|
65
|
+
expect(organization.send(value)).to eq expected[key]
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
43
69
|
end
|
|
44
70
|
end
|
|
45
71
|
|
data/spec/token_spec.rb
CHANGED
|
@@ -66,5 +66,24 @@ module Trello
|
|
|
66
66
|
expect(token.member).to eq Member.find('abcdef123456789123456789')
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
|
+
|
|
70
|
+
describe "#update_fields" do
|
|
71
|
+
it "does not set any fields when the fields argument is empty" do
|
|
72
|
+
expected = {
|
|
73
|
+
'id' => 'id',
|
|
74
|
+
'idMember' => 'member_id',
|
|
75
|
+
'permissions' => 'permissions',
|
|
76
|
+
'webhooks' => 'webhooks'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
token = Token.new(expected)
|
|
80
|
+
|
|
81
|
+
token.update_fields({})
|
|
82
|
+
|
|
83
|
+
expected.each do |key, value|
|
|
84
|
+
expect(token.send(value)).to eq expected[key]
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
69
88
|
end
|
|
70
89
|
end
|
data/spec/webhook_spec.rb
CHANGED
|
@@ -106,5 +106,25 @@ module Trello
|
|
|
106
106
|
expect(webhook).to be_activated
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
|
+
|
|
110
|
+
describe "#update_fields" do
|
|
111
|
+
it "does not set any fields when the fields argument is empty" do
|
|
112
|
+
expected = {
|
|
113
|
+
'id' => 'id',
|
|
114
|
+
'description' => 'description',
|
|
115
|
+
'idModel' => 'id_model',
|
|
116
|
+
'callbackURL' => 'callback_url',
|
|
117
|
+
'active' => 'active'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
webhook = Webhook.new(expected)
|
|
121
|
+
|
|
122
|
+
webhook.update_fields({})
|
|
123
|
+
|
|
124
|
+
expected.each do |key, value|
|
|
125
|
+
expect(webhook.send(value)).to eq expected[key]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
109
129
|
end
|
|
110
130
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-trello
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Tregunna
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -105,6 +105,7 @@ files:
|
|
|
105
105
|
- lib/trello/core_ext/hash.rb
|
|
106
106
|
- lib/trello/core_ext/string.rb
|
|
107
107
|
- lib/trello/cover_image.rb
|
|
108
|
+
- lib/trello/error.rb
|
|
108
109
|
- lib/trello/has_actions.rb
|
|
109
110
|
- lib/trello/item.rb
|
|
110
111
|
- lib/trello/item_state.rb
|
|
@@ -167,34 +168,34 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
167
168
|
version: '0'
|
|
168
169
|
requirements: []
|
|
169
170
|
rubyforge_project: ruby-trello
|
|
170
|
-
rubygems_version: 2.
|
|
171
|
+
rubygems_version: 2.7.3
|
|
171
172
|
signing_key:
|
|
172
173
|
specification_version: 4
|
|
173
174
|
summary: A wrapper around the trello.com API.
|
|
174
175
|
test_files:
|
|
175
|
-
- spec/action_spec.rb
|
|
176
|
-
- spec/array_spec.rb
|
|
177
176
|
- spec/association_spec.rb
|
|
178
|
-
- spec/
|
|
179
|
-
- spec/
|
|
180
|
-
- spec/card_spec.rb
|
|
181
|
-
- spec/checklist_spec.rb
|
|
182
|
-
- spec/client_spec.rb
|
|
183
|
-
- spec/configuration_spec.rb
|
|
184
|
-
- spec/hash_spec.rb
|
|
185
|
-
- spec/integration/how_to_authorize_spec.rb
|
|
177
|
+
- spec/notification_spec.rb
|
|
178
|
+
- spec/spec_helper.rb
|
|
186
179
|
- spec/integration/how_to_use_boards_spec.rb
|
|
180
|
+
- spec/integration/how_to_authorize_spec.rb
|
|
187
181
|
- spec/integration/integration_test.rb
|
|
188
|
-
- spec/
|
|
189
|
-
- spec/
|
|
190
|
-
- spec/
|
|
191
|
-
- spec/
|
|
182
|
+
- spec/card_spec.rb
|
|
183
|
+
- spec/hash_spec.rb
|
|
184
|
+
- spec/trello_spec.rb
|
|
185
|
+
- spec/board_spec.rb
|
|
192
186
|
- spec/member_spec.rb
|
|
193
|
-
- spec/notification_spec.rb
|
|
194
187
|
- spec/oauth_policy_spec.rb
|
|
188
|
+
- spec/configuration_spec.rb
|
|
189
|
+
- spec/json_utils_spec.rb
|
|
190
|
+
- spec/checklist_spec.rb
|
|
191
|
+
- spec/list_spec.rb
|
|
192
|
+
- spec/webhook_spec.rb
|
|
195
193
|
- spec/organization_spec.rb
|
|
196
|
-
- spec/
|
|
197
|
-
- spec/string_spec.rb
|
|
194
|
+
- spec/basic_auth_policy_spec.rb
|
|
198
195
|
- spec/token_spec.rb
|
|
199
|
-
- spec/
|
|
200
|
-
- spec/
|
|
196
|
+
- spec/string_spec.rb
|
|
197
|
+
- spec/action_spec.rb
|
|
198
|
+
- spec/array_spec.rb
|
|
199
|
+
- spec/client_spec.rb
|
|
200
|
+
- spec/item_spec.rb
|
|
201
|
+
- spec/label_spec.rb
|