tacokit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.pryrc +7 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/Gemfile +28 -0
- data/Guardfile +12 -0
- data/LICENSE +22 -0
- data/README.md +134 -0
- data/Rakefile +8 -0
- data/config.ru +7 -0
- data/lib/tacokit/authorization.rb +46 -0
- data/lib/tacokit/client/actions.rb +54 -0
- data/lib/tacokit/client/boards.rb +124 -0
- data/lib/tacokit/client/cards.rb +143 -0
- data/lib/tacokit/client/checklists.rb +59 -0
- data/lib/tacokit/client/labels.rb +44 -0
- data/lib/tacokit/client/lists.rb +54 -0
- data/lib/tacokit/client/members.rb +91 -0
- data/lib/tacokit/client/notifications.rb +48 -0
- data/lib/tacokit/client/organizations.rb +79 -0
- data/lib/tacokit/client/searches.rb +20 -0
- data/lib/tacokit/client/tokens.rb +41 -0
- data/lib/tacokit/client/types.rb +11 -0
- data/lib/tacokit/client/webhooks.rb +43 -0
- data/lib/tacokit/client.rb +169 -0
- data/lib/tacokit/configuration.rb +60 -0
- data/lib/tacokit/error.rb +31 -0
- data/lib/tacokit/middleware/boom.rb +26 -0
- data/lib/tacokit/middleware/debug.rb +22 -0
- data/lib/tacokit/middleware.rb +15 -0
- data/lib/tacokit/resource.rb +114 -0
- data/lib/tacokit/response.rb +23 -0
- data/lib/tacokit/transform.rb +97 -0
- data/lib/tacokit/utils.rb +51 -0
- data/lib/tacokit/version.rb +3 -0
- data/lib/tacokit.rb +20 -0
- data/script/console +6 -0
- data/spec/cassettes/Tacokit_Client/_connection/authorized_GET_request_with_app_key_and_token_params.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action/returns_a_token_authorized_action.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action/returns_oauth_authorized_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_entities.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_action_resource/returns_action_memberships.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_delete_action/deletes_an_action.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_a_action.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_an_action.json +1 -0
- data/spec/cassettes/Tacokit_Client_Actions/_update_action_text/updates_an_action.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board/returns_a_token_authorized_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board/returns_oauth_authorized_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_field/returns_an_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_cards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_board_resource/returns_board_members.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_create_board/creates_a_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_calendar_key.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_label.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_create_board_resource/creates_a_board_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_a_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_nested_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_update_board_field/updates_a_board_field.json +1 -0
- data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_create_card_comment/creates_a_comment.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist/returns_a_checklist_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_checklist_resource/returns_checklist_prefs.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_create_checklist/creates_a_checklist.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_delete_checklist/deletes_a_checklist.json +1 -0
- data/spec/cassettes/Tacokit_Client_Checklists/_update_checklist/updates_a_checklist.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_create_label/creates_a_label.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_delete_label/deletes_a_label.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_label/returns_a_label_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_label_resource/returns_a_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_labels/returns_a_label_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Labels/_update_label/updates_a_label.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_create_list/creates_a_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list/returns_a_list_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_list_resource/returns_list_cards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Lists/_update_list/updates_a_list.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member/authenticated/returns_self.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member/returns_a_member.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member/returns_self.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member/supports_query_fields_as_string_or_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_member_field.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_field/returns_an_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_board_stars.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_member_resource/returns_member_boards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_a_member.json +1 -0
- data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_nested_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification/returns_a_notification_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification_resource/returns_action_entities.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_notification_resource/returns_notification_board.json +1 -0
- data/spec/cassettes/Tacokit_Client_Notifications/_update_notification/updates_a_notification.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_create_organization/creates_a_organization.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_delete_organization/deletes_a_organization.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization/returns_an_organization_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_hash.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_resource.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_field/returns_an_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_actions.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_boards.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_members.json +1 -0
- data/spec/cassettes/Tacokit_Client_Organizations/_update_organization/updates_a_organization.json +1 -0
- data/spec/cassettes/Tacokit_Client_Searches/_search/returns_search_result.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_delete_token/deletes_a_token.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_token/returns_a_token_for_token_string.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_token_field/returns_a_value.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_token_field/returns_an_array.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_member.json +1 -0
- data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_webhooks.json +1 -0
- data/spec/cassettes/Tacokit_Client_Types/_type/returns_a_type_by_id.json +1 -0
- data/spec/cassettes/Tacokit_Client_Webhooks/_create_webhook/creates_a_webhook.json +1 -0
- data/spec/cassettes/Tacokit_Client_Webhooks/_delete_webhook/deletes_a_webhook.json +1 -0
- data/spec/cassettes/Tacokit_Client_Webhooks/_update_webhook/updates_a_webhook.json +1 -0
- data/spec/cassettes/Tacokit_Client_Webhooks/_webhook/returns_a_webhook_by_short_link.json +1 -0
- data/spec/cassettes/Tacokit_Client_Webhooks/_webhook_field/returns_a_value.json +1 -0
- data/spec/fixtures/taco.png +0 -0
- data/spec/spec_helper.rb +162 -0
- data/spec/tacokit/authorization_spec.rb +47 -0
- data/spec/tacokit/client/actions_spec.rb +100 -0
- data/spec/tacokit/client/boards_spec.rb +168 -0
- data/spec/tacokit/client/cards_spec.rb +192 -0
- data/spec/tacokit/client/checklists_spec.rb +87 -0
- data/spec/tacokit/client/labels_spec.rb +70 -0
- data/spec/tacokit/client/lists_spec.rb +81 -0
- data/spec/tacokit/client/members_spec.rb +114 -0
- data/spec/tacokit/client/notifications_spec.rb +52 -0
- data/spec/tacokit/client/organizations_spec.rb +100 -0
- data/spec/tacokit/client/searches_spec.rb +13 -0
- data/spec/tacokit/client/tokens_spec.rb +49 -0
- data/spec/tacokit/client/types_spec.rb +12 -0
- data/spec/tacokit/client/webhooks_spec.rb +70 -0
- data/spec/tacokit/client_spec.rb +28 -0
- data/spec/tacokit/configuration_spec.rb +51 -0
- data/spec/tacokit/middleware/boom_spec.rb +35 -0
- data/spec/tacokit/resource_spec.rb +26 -0
- data/spec/tacokit/transform_spec.rb +131 -0
- data/spec/tacokit_spec.rb +16 -0
- data/tacokit.gemspec +28 -0
- metadata +436 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Boards do
|
4
|
+
def test_board_link
|
5
|
+
'swezQ9XS'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_board_id
|
9
|
+
'548a675581d1d669c9e8184e'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#board", :vcr do
|
13
|
+
it "returns a token authorized board" do
|
14
|
+
board = app_client.board(test_board_link)
|
15
|
+
|
16
|
+
expect(board.name).to eq('Test Board')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns oauth authorized board' do
|
20
|
+
board = oauth_client.board(test_board_link)
|
21
|
+
|
22
|
+
expect(board.name).to eq('Test Board')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#board_field", :vcr do
|
27
|
+
it "returns a value" do
|
28
|
+
name = app_client.board_field(test_board_link, :name)
|
29
|
+
|
30
|
+
expect(name['_value']).to eq('Test Board')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns an array" do
|
34
|
+
power_ups = app_client.board_field(test_board_link, :power_ups)
|
35
|
+
|
36
|
+
expect(power_ups).to eq([])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns a hash" do
|
40
|
+
label_names = app_client.board_field(test_board_link, :label_names)
|
41
|
+
|
42
|
+
expect(label_names.to_attrs).to include(:green, :yellow, :orange)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#board_resource", :vcr do
|
47
|
+
it "returns board actions" do
|
48
|
+
actions = app_client.board_resource(test_board_link, :actions)
|
49
|
+
|
50
|
+
expect(actions).not_to be_empty
|
51
|
+
|
52
|
+
action = actions.first
|
53
|
+
expect(action.member_creator.full_name).to be_present
|
54
|
+
end
|
55
|
+
|
56
|
+
it "returns board members" do
|
57
|
+
members = app_client.board_resource(test_board_link, :members)
|
58
|
+
|
59
|
+
expect(members).not_to be_empty
|
60
|
+
|
61
|
+
member = members.first
|
62
|
+
expect(member.username).to be_present
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns board cards" do
|
66
|
+
cards = app_client.board_resource(test_board_link, :cards)
|
67
|
+
|
68
|
+
expect(cards).not_to be_empty
|
69
|
+
|
70
|
+
card = cards.first
|
71
|
+
expect(card.pos).to be_present
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#update_board", :vcr do
|
76
|
+
it "updates a board" do
|
77
|
+
board = app_client.update_board(test_board_id, desc: 'This board is for Tacokit testing')
|
78
|
+
|
79
|
+
expect(board.desc).to eq 'This board is for Tacokit testing'
|
80
|
+
assert_requested :put, trello_url_template("boards/#{test_board_id}{?key,token}")
|
81
|
+
end
|
82
|
+
|
83
|
+
it "updates nested resource" do
|
84
|
+
board = app_client.update_board(test_board_id, label_names: { blue: 'Blue Label' })
|
85
|
+
|
86
|
+
expect(board.label_names.to_attrs).to include blue: 'Blue Label'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#create_board", :vcr do
|
91
|
+
before do
|
92
|
+
@board = oauth_client.create_board("Autoboard", desc: "This board was generated by tests")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "creates a board" do
|
96
|
+
expect(@board.name).to eq("Autoboard")
|
97
|
+
expect(@board.desc).to eq("This board was generated by tests")
|
98
|
+
assert_requested :post, trello_url_template("boards{?key,token}"),
|
99
|
+
body: {
|
100
|
+
'name' => 'Autoboard',
|
101
|
+
'desc' => 'This board was generated by tests'
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
after do
|
106
|
+
app_client.update_board @board.id, closed: true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#create_board_resource", :vcr do
|
111
|
+
it "creates a board label" do
|
112
|
+
@label = label = app_client.create_board_resource test_board_id, 'labels', name: "Autolabel", color: 'blue'
|
113
|
+
|
114
|
+
expect(label.name).to eq "Autolabel"
|
115
|
+
expect(label.color).to eq "blue"
|
116
|
+
|
117
|
+
assert_requested :post, trello_url_template("boards/#{test_board_id}/labels{?key,token}"),
|
118
|
+
body: {
|
119
|
+
'name' => 'Autolabel',
|
120
|
+
'color' => 'blue'
|
121
|
+
}
|
122
|
+
app_client.delete_label @label.id
|
123
|
+
end
|
124
|
+
|
125
|
+
it "creates a board calendar key" do
|
126
|
+
key = app_client.create_board_resource test_board_id, 'calendar_key', 'generate', foo: 'bar'
|
127
|
+
|
128
|
+
expect(key.id).to_not be_nil
|
129
|
+
assert_requested :post, trello_url_template("boards/#{test_board_id}/calendarKey/generate{?key,token}")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#update_board_field", :vcr do
|
134
|
+
it "updates a board field" do
|
135
|
+
board = app_client.update_board_field(test_board_id, 'desc', 'This board is for Tacokit testing')
|
136
|
+
|
137
|
+
expect(board.desc).to eq 'This board is for Tacokit testing'
|
138
|
+
assert_requested :put, trello_url_template("boards/#{test_board_id}/desc{?key,token}"), body: { value: 'This board is for Tacokit testing' }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#add_board_member", :vcr do
|
143
|
+
it "adds invites member to board" do
|
144
|
+
@member = member = app_client.add_board_member(test_board_id, 'rosskaff+tacokit2@gmail.com', 'Taco Kit2')
|
145
|
+
|
146
|
+
expect(member.email).to eq 'rosskaff+tacokit2@gmail.com'
|
147
|
+
end
|
148
|
+
|
149
|
+
after do
|
150
|
+
app_client.delete("boards/#{test_board_id}/members/#{@member.id}")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#update_board_resource", :vcr do
|
155
|
+
before do
|
156
|
+
@member = app_client.add_board_member(test_board_id, 'rosskaff+tacokit3@gmail.com', 'Taco Kit3')
|
157
|
+
end
|
158
|
+
|
159
|
+
it "updates member" do
|
160
|
+
membership = app_client.update_board_resource(test_board_id, 'members', @member.id, type: 'normal')
|
161
|
+
expect(membership.id).to_not be_nil
|
162
|
+
end
|
163
|
+
|
164
|
+
after do
|
165
|
+
app_client.delete("boards/#{test_board_id}/members/#{@member.id}")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Cards do
|
4
|
+
def test_card_link
|
5
|
+
'k7GHJj7Q'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_card_id
|
9
|
+
'548dd95c8ca25ac9d0d9ce71'
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_list_id
|
13
|
+
'548dd948ffd374221926b4c8'
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#card", :vcr do
|
17
|
+
it "returns a card by short link" do
|
18
|
+
card = app_client.card(test_card_link)
|
19
|
+
|
20
|
+
expect(card.name).to eq 'Card 1'
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a card by id" do
|
24
|
+
card = app_client.card(test_card_id)
|
25
|
+
|
26
|
+
expect(card.name).to eq 'Card 1'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#card_field", :vcr do
|
31
|
+
it "returns a value" do
|
32
|
+
field = app_client.card_field(test_card_link, :email)
|
33
|
+
|
34
|
+
expect(field['_value']).to be_present
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns an array" do
|
38
|
+
field = app_client.card_field(test_card_link, :labels)
|
39
|
+
|
40
|
+
expect(field).to be_any
|
41
|
+
|
42
|
+
label = field.first
|
43
|
+
expect(label.to_attrs).to include(color: "green")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns a hash" do
|
47
|
+
field = app_client.card_field(test_card_link, :labels)
|
48
|
+
|
49
|
+
expect(field.first.to_attrs).to include(color: "green")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#card_resource", :vcr do
|
54
|
+
it "returns card actions" do
|
55
|
+
actions = app_client.card_resource(test_card_link, :actions)
|
56
|
+
|
57
|
+
expect(actions).to be_any
|
58
|
+
end
|
59
|
+
|
60
|
+
it "returns card board" do
|
61
|
+
board = app_client.card_resource(test_card_link, :board)
|
62
|
+
|
63
|
+
expect(board.name).to be_present
|
64
|
+
end
|
65
|
+
|
66
|
+
it "returns card check item states" do
|
67
|
+
states = app_client.card_resource(test_card_link, :check_item_states)
|
68
|
+
|
69
|
+
expect(states).to be_any
|
70
|
+
|
71
|
+
state = states.first
|
72
|
+
expect(state.state).to be_present
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#update_card", :vcr do
|
77
|
+
it "updates a card" do
|
78
|
+
card = app_client.update_card test_card_link,
|
79
|
+
desc: 'This card is for Tacokit testing',
|
80
|
+
labels: ['blue', 'green']
|
81
|
+
|
82
|
+
expect(card.desc).to eq 'This card is for Tacokit testing'
|
83
|
+
expect(card.labels.size).to eq(2)
|
84
|
+
assert_requested :put, trello_url_template("cards/#{test_card_link}{?key,token}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#create_card", :vcr do
|
89
|
+
before do
|
90
|
+
@card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "creates a card" do
|
94
|
+
expect(@card.name).to eq "Autocard"
|
95
|
+
expect(@card.desc).to eq "This is an autogenerated card"
|
96
|
+
assert_requested :post, trello_url_template("cards{?key,token}"),
|
97
|
+
body: {
|
98
|
+
'idList' => test_list_id,
|
99
|
+
'name' => 'Autocard',
|
100
|
+
'desc' => 'This is an autogenerated card'
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
after do
|
105
|
+
app_client.delete_card(@card.id)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#delete_card", :vcr do
|
110
|
+
before do
|
111
|
+
@card = app_client.create_card test_list_id, "Autocard"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "deletes a card" do
|
115
|
+
app_client.delete_card(@card.id)
|
116
|
+
|
117
|
+
assert_requested :delete, trello_url_template("cards/#{@card.id}{?key,token}")
|
118
|
+
expect { app_client.card(@card.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#create_card_attachment", :vcr do
|
123
|
+
before do
|
124
|
+
@card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "uploads local file" do
|
128
|
+
file_path = File.expand_path('../../../fixtures/taco.png', __FILE__)
|
129
|
+
expect(File.exist?(file_path)).to be_truthy
|
130
|
+
|
131
|
+
attachment = app_client.create_card_attachment(@card.id, file_path, 'image/png', name: 'taco')
|
132
|
+
|
133
|
+
expect(attachment.name).to eq('taco')
|
134
|
+
|
135
|
+
# TODO: mime_type for upload is not persisted on Trello
|
136
|
+
# expect(attachment.mime_type).to eq('image/png')
|
137
|
+
end
|
138
|
+
|
139
|
+
it "attaches external url" do
|
140
|
+
url = 'http://cl.ly/image/2p1x3K1X160b/taco.png'
|
141
|
+
attachment = app_client.create_card_attachment(@card.id, url, 'image/png', name: 'taco')
|
142
|
+
|
143
|
+
expect(attachment.name).to eq('taco')
|
144
|
+
|
145
|
+
# TODO: mime_type for upload is not persisted on Trello
|
146
|
+
# expect(attachment.mime_type).to eq('image/png')
|
147
|
+
end
|
148
|
+
|
149
|
+
after do
|
150
|
+
app_client.delete_card(@card.id)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#create_card_comment", :vcr do
|
155
|
+
before do
|
156
|
+
@card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
|
157
|
+
end
|
158
|
+
|
159
|
+
it "creates a comment" do
|
160
|
+
comment = app_client.create_card_comment(@card.id, "I'm singing, I'm singing, I'm singing!")
|
161
|
+
|
162
|
+
expect(comment.data.text).to eq "I'm singing, I'm singing, I'm singing!"
|
163
|
+
expect(comment.data.card.id).to eq @card.id
|
164
|
+
|
165
|
+
actions = app_client.card_resource(@card.id, "actions")
|
166
|
+
expect(actions.map(&:id)).to include(comment.id)
|
167
|
+
end
|
168
|
+
|
169
|
+
after do
|
170
|
+
app_client.delete_card(@card.id)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "#delete_card_resource", :vcr do
|
175
|
+
before do
|
176
|
+
@card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
|
177
|
+
@comment = app_client.create_card_comment(@card.id, "I'm singing, I'm singing, I'm singing!")
|
178
|
+
end
|
179
|
+
|
180
|
+
it "deletes resource" do
|
181
|
+
app_client.delete_card_resource @card.id, "actions", @comment.id, "comments"
|
182
|
+
|
183
|
+
actions = app_client.card_resource(@card.id, "actions")
|
184
|
+
|
185
|
+
expect(actions).to be_empty
|
186
|
+
end
|
187
|
+
|
188
|
+
after do
|
189
|
+
app_client.delete_card(@card.id)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Checklists do
|
4
|
+
def test_checklist_id
|
5
|
+
'548ddd3f5402eb674035334f'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_card_id
|
9
|
+
'548dd95c8ca25ac9d0d9ce71'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#checklist", :vcr do
|
13
|
+
it "returns a checklist by id" do
|
14
|
+
checklist = app_client.checklist(test_checklist_id)
|
15
|
+
|
16
|
+
expect(checklist.name).to eq 'Checklist 1'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#checklist_field", :vcr do
|
21
|
+
it "returns a value" do
|
22
|
+
field = app_client.checklist_field(test_checklist_id, :pos)
|
23
|
+
|
24
|
+
expect(field['_value']).to be_present
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#checklist_resource", :vcr do
|
29
|
+
it "returns checklist actions" do
|
30
|
+
items = app_client.checklist_resource(test_checklist_id, :check_items)
|
31
|
+
|
32
|
+
expect(items).to be_any
|
33
|
+
expect(items.first.state).to be_present
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns checklist board" do
|
37
|
+
board = app_client.checklist_resource(test_checklist_id, :board)
|
38
|
+
|
39
|
+
expect(board.name).to be_present
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#update_checklist", :vcr do
|
45
|
+
it "updates a checklist" do
|
46
|
+
checklist = app_client.update_checklist test_checklist_id,
|
47
|
+
name: 'Test Checklist 1'
|
48
|
+
|
49
|
+
expect(checklist.name).to eq 'Test Checklist 1'
|
50
|
+
assert_requested :put, trello_url_template("checklists/#{test_checklist_id}{?key,token}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#create_checklist", :vcr do
|
55
|
+
before do
|
56
|
+
@checklist = app_client.create_checklist test_card_id, "Autochecklist", pos: "top"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "creates a checklist" do
|
60
|
+
expect(@checklist.name).to eq "Autochecklist"
|
61
|
+
expect(@checklist.pos).to be >= 1
|
62
|
+
assert_requested :post, trello_url_template("checklists{?key,token}"),
|
63
|
+
body: {
|
64
|
+
'name' => 'Autochecklist',
|
65
|
+
'pos' => 'top',
|
66
|
+
'idCard' => test_card_id
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
after do
|
71
|
+
app_client.delete_checklist(@checklist.id)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "#delete_checklist", :vcr do
|
76
|
+
before do
|
77
|
+
@checklist = app_client.create_checklist test_card_id, "Autochecklist"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "deletes a checklist" do
|
81
|
+
app_client.delete_checklist(@checklist.id)
|
82
|
+
|
83
|
+
expect { app_client.checklist(@checklist.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
|
84
|
+
assert_requested :delete, trello_url_template("checklists/#{@checklist.id}{?key,token}")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Labels do
|
4
|
+
def test_label_id
|
5
|
+
'548a675574d650d567d52ad0'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_board_id
|
9
|
+
'548a675581d1d669c9e8184e'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#label", :vcr do
|
13
|
+
it "returns a label by id" do
|
14
|
+
label = app_client.label(test_label_id)
|
15
|
+
expect(label.name).to match(/Label/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#label_resource", :vcr do
|
20
|
+
it "returns a board" do
|
21
|
+
board = app_client.label_resource(test_label_id, :board)
|
22
|
+
|
23
|
+
expect(board.name).to be_present
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#update_label", :vcr do
|
28
|
+
it "updates a label" do
|
29
|
+
label = app_client.update_label test_label_id, name: 'Test Label 1'
|
30
|
+
|
31
|
+
expect(label.name).to eq 'Test Label 1'
|
32
|
+
assert_requested :put, trello_url_template("labels/#{test_label_id}{?key,token}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#create_label", :vcr do
|
37
|
+
before do
|
38
|
+
@label = app_client.create_label test_board_id, "Test Label X", "sky"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "creates a label" do
|
42
|
+
expect(@label.name).to eq "Test Label X"
|
43
|
+
expect(@label.color).to eq "sky"
|
44
|
+
|
45
|
+
assert_requested :post, trello_url_template("labels{?key,token}"),
|
46
|
+
body: {
|
47
|
+
'idBoard' => test_board_id,
|
48
|
+
'name' => 'Test Label X',
|
49
|
+
'color' => 'sky'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
after do
|
54
|
+
app_client.delete_label(@label.id)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#delete_label", :vcr do
|
59
|
+
before do
|
60
|
+
@label = app_client.create_label test_board_id, "Test Label X", "sky"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "deletes a label" do
|
64
|
+
app_client.delete_label(@label.id)
|
65
|
+
|
66
|
+
assert_requested :delete, trello_url_template("labels/#{@label.id}{?key,token}")
|
67
|
+
expect { app_client.label(@label.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Lists do
|
4
|
+
def test_list_id
|
5
|
+
'548dd948ffd374221926b4c8'
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_board_id
|
9
|
+
'548a675581d1d669c9e8184e'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#list", :vcr do
|
13
|
+
it "returns a list by id" do
|
14
|
+
list = app_client.list(test_list_id)
|
15
|
+
|
16
|
+
expect(list.name).to eq 'List 1'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#list_field", :vcr do
|
21
|
+
it "returns a value" do
|
22
|
+
field = app_client.list_field(test_list_id, :pos)
|
23
|
+
|
24
|
+
expect(field['_value']).to be_present
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#list_resource", :vcr do
|
29
|
+
it "returns list actions" do
|
30
|
+
actions = app_client.list_resource(test_list_id, :actions)
|
31
|
+
|
32
|
+
expect(actions).to be_any
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns list board" do
|
36
|
+
board = app_client.list_resource(test_list_id, :board)
|
37
|
+
|
38
|
+
expect(board.name).to be_present
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns list cards" do
|
42
|
+
cards = app_client.list_resource(test_list_id, :cards)
|
43
|
+
|
44
|
+
expect(cards).to be_any
|
45
|
+
|
46
|
+
card = cards.first
|
47
|
+
expect(card.name).to be_present
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#update_list", :vcr do
|
52
|
+
it "updates a list" do
|
53
|
+
list = app_client.update_list test_list_id,
|
54
|
+
name: 'Test List 1'
|
55
|
+
|
56
|
+
expect(list.name).to eq 'Test List 1'
|
57
|
+
assert_requested :put, trello_url_template("lists/#{test_list_id}{?key,token}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#create_list", :vcr do
|
62
|
+
before do
|
63
|
+
@list = app_client.create_list test_board_id, "Autolist", pos: 'bottom'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "creates a list" do
|
67
|
+
expect(@list.name).to eq "Autolist"
|
68
|
+
expect(@list.pos).to be >= 1
|
69
|
+
assert_requested :post, trello_url_template("lists{?key,token}"),
|
70
|
+
body: {
|
71
|
+
'name' => 'Autolist',
|
72
|
+
'pos' => 'bottom',
|
73
|
+
'idBoard' => test_board_id
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
after do
|
78
|
+
app_client.update_list @list.id, closed: true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Members do
|
4
|
+
|
5
|
+
describe "#member", :vcr do
|
6
|
+
it "returns a member" do
|
7
|
+
member = app_client.member("rossta")
|
8
|
+
|
9
|
+
expect(member.username).to eq("rossta")
|
10
|
+
assert_requested :get, trello_url_template("members/rossta{?key,token}")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns self" do
|
14
|
+
member = app_client.member
|
15
|
+
|
16
|
+
expect(member.full_name).to eq("Taco Kit")
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises error for missing token" do
|
20
|
+
app_client.configuration.app_token = nil
|
21
|
+
|
22
|
+
expect { app_client.member }.to raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it "supports query fields as string or array" do
|
26
|
+
member = app_client.member "tacokit",
|
27
|
+
boards: 'all',
|
28
|
+
board_fields: 'name,short_url',
|
29
|
+
fields: ['username', 'full_name']
|
30
|
+
|
31
|
+
expect(member.username).to eq("tacokit")
|
32
|
+
expect(member.full_name).to eq("Taco Kit")
|
33
|
+
|
34
|
+
board = member.boards.first
|
35
|
+
expect(board.name).to eq("Test Board")
|
36
|
+
expect(board.short_url).to match(%r{^https://trello.com})
|
37
|
+
end
|
38
|
+
|
39
|
+
context "authenticated" do
|
40
|
+
it "returns self" do
|
41
|
+
member = oauth_client.member
|
42
|
+
|
43
|
+
expect(member.username).to eq("tacokit")
|
44
|
+
expect(member.full_name).to eq("Taco Kit")
|
45
|
+
assert_requested :get, trello_url("members/me")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#member_field", :vcr do
|
52
|
+
it "returns a value" do
|
53
|
+
field = app_client.member_field('tacokit', 'full_name')
|
54
|
+
|
55
|
+
expect(field['_value']).to eq('Taco Kit')
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns an array" do
|
59
|
+
field = app_client.member_field('tacokit', :id_organizations)
|
60
|
+
|
61
|
+
expect(field).to include(test_org_id)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns a resource" do
|
65
|
+
field = app_client.member_field('tacokit', :prefs)
|
66
|
+
|
67
|
+
expect(field.to_attrs).to include(color_blind: true)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "#member_resource", :vcr do
|
72
|
+
it "returns member actions" do
|
73
|
+
actions = app_client.member_resource('tacokit', :actions)
|
74
|
+
|
75
|
+
expect(actions).not_to be_empty
|
76
|
+
|
77
|
+
action = actions.first
|
78
|
+
expect(action.member_creator.full_name).to be_present
|
79
|
+
end
|
80
|
+
|
81
|
+
it "returns member boards" do
|
82
|
+
boards = app_client.member_resource('tacokit', :boards)
|
83
|
+
|
84
|
+
expect(boards).not_to be_empty
|
85
|
+
|
86
|
+
board = boards.first
|
87
|
+
expect(board.name).to be_present
|
88
|
+
end
|
89
|
+
|
90
|
+
it "returns member board stars" do
|
91
|
+
stars = app_client.member_resource('tacokit', :board_stars)
|
92
|
+
|
93
|
+
expect(stars).not_to be_empty
|
94
|
+
|
95
|
+
star = stars.first
|
96
|
+
expect(star.pos).to be_present
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#update_member", :vcr do
|
101
|
+
it "updates a member" do
|
102
|
+
member = oauth_client.update_member('tacokit', bio: 'Tacokit puts the Trello API on Ruby')
|
103
|
+
|
104
|
+
expect(member.bio).to eq 'Tacokit puts the Trello API on Ruby'
|
105
|
+
assert_requested :put, trello_url_template("members/tacokit{?key,token}")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "updates nested resource" do
|
109
|
+
member = oauth_client.update_member('tacokit', prefs: { color_blind: true })
|
110
|
+
|
111
|
+
expect(member.prefs.color_blind).to eq true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|