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,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Notifications do
|
4
|
+
def test_notification_id
|
5
|
+
'549102431b607566bafc93ab'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#notification", :vcr do
|
9
|
+
it "returns a notification by id" do
|
10
|
+
notification = app_client.notification(test_notification_id)
|
11
|
+
|
12
|
+
expect(notification.data).to include("text")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#notification_field", :vcr do
|
17
|
+
it "returns a value" do
|
18
|
+
field = app_client.notification_field(test_notification_id, :type)
|
19
|
+
|
20
|
+
expect(field['_value']).to be_present
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a resource" do
|
24
|
+
field = app_client.notification_field(test_notification_id, :data)
|
25
|
+
|
26
|
+
expect(field).to be_a(Tacokit::Resource)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#notification_resource", :vcr do
|
31
|
+
it "returns action entities" do
|
32
|
+
entities = app_client.notification_resource(test_notification_id, :entities)
|
33
|
+
|
34
|
+
expect(entities).to be_any
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns notification board" do
|
38
|
+
board = app_client.notification_resource(test_notification_id, :board)
|
39
|
+
|
40
|
+
expect(board.name).to be_present
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#update_notification", :vcr do
|
45
|
+
it "updates a notification" do
|
46
|
+
notification = oauth_client.update_notification(test_notification_id, unread: false)
|
47
|
+
|
48
|
+
expect(notification.unread).to be false
|
49
|
+
assert_requested :put, trello_url_template("notifications/#{test_notification_id}{?key,token}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Organizations do
|
4
|
+
|
5
|
+
describe "#organization", :vcr do
|
6
|
+
it "returns an organization by id" do
|
7
|
+
org = app_client.organization(test_org_name)
|
8
|
+
|
9
|
+
expect(org.name).to eq 'teamtacokit'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#organization_field", :vcr do
|
14
|
+
it "returns a value" do
|
15
|
+
field = app_client.organization_field(test_org_name, :desc)
|
16
|
+
|
17
|
+
expect(field['_value']).to eq('Tacokit the organization')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns an array" do
|
21
|
+
field = app_client.organization_field(test_org_name, :premium_features)
|
22
|
+
|
23
|
+
expect(field).to be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns a resource" do
|
27
|
+
field = app_client.organization_field(test_org_name, :prefs)
|
28
|
+
|
29
|
+
expect(field.to_attrs).to include(permission_level: "public")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#organization_resource", :vcr do
|
34
|
+
it "returns organization actions" do
|
35
|
+
actions = app_client.organization_resource(test_org_name, :actions)
|
36
|
+
|
37
|
+
expect(actions).not_to be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns organization boards" do
|
41
|
+
boards = app_client.organization_resource(test_org_name, :boards)
|
42
|
+
|
43
|
+
expect(boards).not_to be_empty
|
44
|
+
|
45
|
+
board = boards.first
|
46
|
+
expect(board.name).to be_present
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns organization members" do
|
50
|
+
members = app_client.organization_resource(test_org_name, :members)
|
51
|
+
|
52
|
+
expect(members).not_to be_empty
|
53
|
+
|
54
|
+
member = members.first
|
55
|
+
expect(member.username).to be_present
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#update_organization", :vcr do
|
60
|
+
it "updates a organization" do
|
61
|
+
organization = oauth_client.update_organization(test_org_name, desc: 'This organization is for Tacokit collaboration')
|
62
|
+
|
63
|
+
expect(organization.desc).to eq 'This organization is for Tacokit collaboration'
|
64
|
+
assert_requested :put, trello_url_template("organizations/#{test_org_name}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#create_organization", :vcr do
|
69
|
+
before do
|
70
|
+
@organization = app_client.create_organization "Autoorganization", desc: "This is an autogenerated organization"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "creates a organization" do
|
74
|
+
expect(@organization.display_name).to eq "Autoorganization"
|
75
|
+
expect(@organization.desc).to eq "This is an autogenerated organization"
|
76
|
+
assert_requested :post, trello_url_template("organizations{?key,token}"),
|
77
|
+
body: {
|
78
|
+
'displayName' => 'Autoorganization',
|
79
|
+
'desc' => 'This is an autogenerated organization'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
after do
|
84
|
+
app_client.delete_organization(@organization.id)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "#delete_organization", :vcr do
|
89
|
+
before do
|
90
|
+
@organization = app_client.create_organization "Autoorganization"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "deletes a organization" do
|
94
|
+
app_client.delete_organization(@organization.id)
|
95
|
+
|
96
|
+
assert_requested :delete, trello_url_template("organizations/#{@organization.id}{?key,token}")
|
97
|
+
expect { app_client.organization(@organization.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Tokens do
|
4
|
+
|
5
|
+
describe "#token", :vcr do
|
6
|
+
it "returns a token for token string" do
|
7
|
+
token = app_client.token(test_trello_app_token)
|
8
|
+
|
9
|
+
expect(token.identifier).to be_present
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#token_field", :vcr do
|
14
|
+
it "returns a value" do
|
15
|
+
field = app_client.token_field(test_trello_app_token, :date_created)
|
16
|
+
|
17
|
+
expect(field['_value']).to be_present
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns an array" do
|
21
|
+
field = app_client.token_field(test_trello_app_token, :permissions)
|
22
|
+
|
23
|
+
expect(field).to be_any
|
24
|
+
expect(field.first.read).to be_present
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#token_resource", :vcr do
|
29
|
+
it "returns token member" do
|
30
|
+
member = app_client.token_resource(test_trello_app_token, :member)
|
31
|
+
|
32
|
+
expect(member).to be_present
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns token webhooks" do
|
36
|
+
webhooks = app_client.token_resource(test_trello_app_token, :webhooks)
|
37
|
+
|
38
|
+
expect(webhooks).to be_any
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#delete_token", :vcr do
|
43
|
+
it "deletes a token" do
|
44
|
+
expect { app_client.delete_token('faketokenid') }.to raise_error(Tacokit::Error) # 400, invalid token
|
45
|
+
|
46
|
+
assert_requested :delete, trello_url_template("tokens/faketokenid{?key,token}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client::Webhooks do
|
4
|
+
def test_webhook_id
|
5
|
+
'5491ff14d60e03635c260393'
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#webhook", :vcr do
|
9
|
+
it "returns a webhook by short link" do
|
10
|
+
webhook = app_client.webhook(test_webhook_id)
|
11
|
+
|
12
|
+
expect(webhook.callback_url).to match(%r{https://[^/]*/webhook})
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#webhook_field", :vcr do
|
17
|
+
it "returns a value" do
|
18
|
+
field = app_client.webhook_field(test_webhook_id, :callback_url)
|
19
|
+
|
20
|
+
expect(field['_value']).to be_present
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#update_webhook", :vcr do
|
25
|
+
it "updates a webhook" do
|
26
|
+
webhook = app_client.update_webhook(test_webhook_id, description: 'This webhook is for Tacokit testing')
|
27
|
+
|
28
|
+
expect(webhook.description).to eq 'This webhook is for Tacokit testing'
|
29
|
+
assert_requested :put, trello_url_template("webhooks/#{test_webhook_id}{?key,token}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#create_webhook", :vcr do
|
34
|
+
before do
|
35
|
+
@webhook = app_client.create_webhook \
|
36
|
+
test_trello_app_token,
|
37
|
+
test_org_id,
|
38
|
+
tacokit_web_endpoint("webhook?create_webhook")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "creates a webhook" do
|
42
|
+
expect(@webhook.callback_url).to match(%r{https://[^/]*/webhook})
|
43
|
+
assert_requested :post, trello_url_template("webhooks{?key,token}"),
|
44
|
+
body: {
|
45
|
+
'callbackURL' => tacokit_web_endpoint("webhook?create_webhook"),
|
46
|
+
'idModel' => test_org_id
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
after do
|
51
|
+
app_client.delete_webhook(@webhook.id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#delete_webhook", :vcr do
|
56
|
+
before do
|
57
|
+
@webhook = app_client.create_webhook \
|
58
|
+
test_trello_app_token,
|
59
|
+
test_org_id,
|
60
|
+
tacokit_web_endpoint("webhook?delete_webhook")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "deletes a webhook" do
|
64
|
+
app_client.delete_webhook(@webhook.id)
|
65
|
+
|
66
|
+
expect { app_client.webhook(@webhook.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
|
67
|
+
assert_requested :delete, trello_url_template("webhooks/#{@webhook.id}{?key,token}")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Client do
|
4
|
+
describe "#configuration" do
|
5
|
+
it "accepts configuration" do
|
6
|
+
opts = { app_key: "joel", app_secret: "0ns0ftw@re" }
|
7
|
+
client = Tacokit::Client.new(opts)
|
8
|
+
expect(client.app_key).to eq("joel")
|
9
|
+
expect(client.app_secret).to eq("0ns0ftw@re")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#connection", :vcr do
|
14
|
+
it "authorized GET request with app key and token params" do
|
15
|
+
client = Tacokit::Client.new(test_client_credentials)
|
16
|
+
boards = client.get("members/me/boards")
|
17
|
+
|
18
|
+
board = boards.first
|
19
|
+
|
20
|
+
expect(board.name).to eq 'Test Board'
|
21
|
+
assert_requested :get, trello_url_template('members/me/boards{?key,token}')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#inspect" do
|
26
|
+
it { expect(Tacokit::Client.new({}).inspect).to match %r{Tacokit::Client} }
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Configuration do
|
4
|
+
let(:configuration) { Tacokit::Configuration.new }
|
5
|
+
|
6
|
+
it 'has an app_key attribute' do
|
7
|
+
configuration.app_key = 'app_key'
|
8
|
+
expect(configuration.app_key).to eq('app_key')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'has an app_secret attribute' do
|
12
|
+
configuration.app_secret = 'app_secret'
|
13
|
+
expect(configuration.app_secret).to eq('app_secret')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has an oauth_token attribute' do
|
17
|
+
configuration.oauth_token = 'oauth_token'
|
18
|
+
expect(configuration.oauth_token).to eq('oauth_token')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has an oauth_token_secret attribute' do
|
22
|
+
configuration.oauth_secret = 'oauth_secret'
|
23
|
+
expect(configuration.oauth_secret).to eq('oauth_secret')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has a developer public key attribute' do
|
27
|
+
configuration.app_key = 'app_key'
|
28
|
+
expect(configuration.app_key).to eq('app_key')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'has a member token attribute' do
|
32
|
+
configuration.app_secret = 'app_secret'
|
33
|
+
expect(configuration.app_secret).to eq('app_secret')
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#initialize' do
|
37
|
+
it 'sets key attributes provided as a hash' do
|
38
|
+
configuration = Tacokit::Configuration.new \
|
39
|
+
app_key: 'app_key',
|
40
|
+
app_secret: 'app_secret',
|
41
|
+
oauth_token: 'oauth_token',
|
42
|
+
oauth_secret: 'oauth_secret'
|
43
|
+
|
44
|
+
expect(configuration.app_key).to eq('app_key')
|
45
|
+
expect(configuration.app_secret).to eq('app_secret')
|
46
|
+
expect(configuration.oauth_token).to eq('oauth_token')
|
47
|
+
expect(configuration.oauth_secret).to eq('oauth_secret')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit::Middleware::Boom do
|
4
|
+
let(:app) { Object.new }
|
5
|
+
let(:env) { Faraday::Env.new }
|
6
|
+
let(:middleware) { described_class.new(app) }
|
7
|
+
|
8
|
+
describe "#on_complete" do
|
9
|
+
|
10
|
+
it "raises 404" do
|
11
|
+
env[:status] = 404
|
12
|
+
expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ResourceNotFound)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "raises 407" do
|
16
|
+
env[:status] = 407
|
17
|
+
expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ConnectionFailed)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "raises 400" do
|
21
|
+
env[:status] = 400
|
22
|
+
expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::ClientError)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises 401" do
|
26
|
+
env[:status] = 401
|
27
|
+
expect{middleware.on_complete(env)}.to raise_error(Tacokit::Error::Unauthorized)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does nothing" do
|
31
|
+
env[:status] = 200
|
32
|
+
expect{middleware.on_complete(env)}.not_to raise_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe Tacokit::Resource do
|
5
|
+
let(:client) { OpenStruct.new }
|
6
|
+
|
7
|
+
def build_resource(attrs = {})
|
8
|
+
described_class.new(client, attrs)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#initialize" do
|
12
|
+
it "responds to given attributes" do
|
13
|
+
resource = build_resource(one: 'one', 'two' => :two)
|
14
|
+
|
15
|
+
expect(resource.one).to eq 'one'
|
16
|
+
expect(resource.two).to eq :two
|
17
|
+
end
|
18
|
+
|
19
|
+
it "responds to deep attributes" do
|
20
|
+
resource = build_resource(deep: { merge: { attribute: 'ftw' }})
|
21
|
+
|
22
|
+
expect(resource.deep.merge.attribute).to eq 'ftw'
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Tacokit
|
4
|
+
describe Transform do
|
5
|
+
subject(:transform) { Transform.new }
|
6
|
+
|
7
|
+
describe "#serialize" do
|
8
|
+
def process(body)
|
9
|
+
transform.serialize(body)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "does not change no body" do
|
13
|
+
result = process(nil)
|
14
|
+
expect(result).to be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not change empty body" do
|
18
|
+
result = process('')
|
19
|
+
expect(result).to eq ''
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not change string body" do
|
23
|
+
result = process('{a: 1}')
|
24
|
+
expect(result).to eq '{a: 1}'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "does not change empty hash body" do
|
28
|
+
result = process({})
|
29
|
+
expect(result).to eq({})
|
30
|
+
end
|
31
|
+
|
32
|
+
context "hash body" do
|
33
|
+
it "it stringifies keys" do
|
34
|
+
result = process(hello: 'world')
|
35
|
+
|
36
|
+
expect(result).to eq 'hello' => 'world'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "lower camelizes keys" do
|
40
|
+
result = process(hello_world: 'hello_world', biggie_smalls: 'biggie_smalls')
|
41
|
+
|
42
|
+
expect(result).to include('helloWorld' => 'hello_world')
|
43
|
+
expect(result).to include('biggieSmalls' => 'biggie_smalls')
|
44
|
+
end
|
45
|
+
|
46
|
+
it "flattens nested keys" do
|
47
|
+
result = process(prefs: { 'showSidebar' => true })
|
48
|
+
|
49
|
+
expect(result).to eq('prefs/showSidebar' => true)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "coverts id suffix to prefix" do
|
53
|
+
result = process('card_id' => "a"*10)
|
54
|
+
|
55
|
+
expect(result).to eq('idCard' => "a"*10)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "coverts ids suffix to prefix and pluralizes" do
|
59
|
+
result = process('card_ids' => "a"*10)
|
60
|
+
|
61
|
+
expect(result).to eq('idCards' => "a"*10)
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "special cases" do
|
65
|
+
|
66
|
+
it "callbackURL" do
|
67
|
+
result = process(callback_url: 'http://example.com')
|
68
|
+
|
69
|
+
expect(result).to eq('callbackURL' => 'http://example.com')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#deserialize" do
|
78
|
+
def process(body)
|
79
|
+
transform.deserialize(body)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "does not change no body" do
|
83
|
+
result = process(nil)
|
84
|
+
expect(result).to be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it "does not change empty body" do
|
88
|
+
result = process('')
|
89
|
+
expect(result).to eq ''
|
90
|
+
end
|
91
|
+
|
92
|
+
it "does not change string body" do
|
93
|
+
result = process('{a: 1}')
|
94
|
+
expect(result).to eq '{a: 1}'
|
95
|
+
end
|
96
|
+
|
97
|
+
it "does not change empty hash body" do
|
98
|
+
result = process({})
|
99
|
+
expect(result).to eq({})
|
100
|
+
end
|
101
|
+
|
102
|
+
context "hash body" do
|
103
|
+
it "it stringifies keys" do
|
104
|
+
result = process(hello: 'world')
|
105
|
+
|
106
|
+
expect(result).to eq 'hello' => 'world'
|
107
|
+
end
|
108
|
+
|
109
|
+
it "underscores keys" do
|
110
|
+
result = process(helloWorld: 'helloWorld', biggieSmalls: 'biggieSmalls')
|
111
|
+
|
112
|
+
expect(result).to include('hello_world' => 'helloWorld')
|
113
|
+
expect(result).to include('biggie_smalls' => 'biggieSmalls')
|
114
|
+
end
|
115
|
+
|
116
|
+
it "coverts id prefix to suffix" do
|
117
|
+
result = process('idCard' => "a"*10, 'idBoardPinned' => '123')
|
118
|
+
|
119
|
+
expect(result).to eq('card_id' => "a"*10, 'board_pinned_id' => '123')
|
120
|
+
end
|
121
|
+
|
122
|
+
it "coverts ids suffix to prefix and pluralizes" do
|
123
|
+
result = process('idCards' => "a"*10, 'idBoardsPinned' => ["123"])
|
124
|
+
|
125
|
+
expect(result).to eq('card_ids' => "a"*10, 'boards_pinned_ids' => ["123"])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Tacokit do
|
4
|
+
|
5
|
+
describe "#method_missing" do
|
6
|
+
it "forwards messages to client" do
|
7
|
+
expect(Tacokit.client).to receive(:open_app_key)
|
8
|
+
Tacokit.open_app_key
|
9
|
+
end
|
10
|
+
|
11
|
+
it "raises otherwise" do
|
12
|
+
expect { Tacokit.no_method }.to raise_error(NoMethodError)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/tacokit.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tacokit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tacokit"
|
8
|
+
spec.version = Tacokit::VERSION
|
9
|
+
spec.authors = ["Ross Kaffenberger"]
|
10
|
+
spec.email = ["rosskaff@gmail.com"]
|
11
|
+
spec.summary = %q{A simple wrapper for the Trello API.}
|
12
|
+
spec.description = %q{A ruby toolkit for the Trello API. Provides an alternative to the original Trello Ruby wrapper, ruby-trello.}
|
13
|
+
spec.homepage = "http://rossta.github.io/tacokit.rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "faraday"
|
22
|
+
spec.add_dependency "faraday_middleware"
|
23
|
+
spec.add_dependency "simple_oauth"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
28
|
+
end
|