tacokit 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +4 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +2 -1
  6. data/README.md +140 -47
  7. data/Rakefile +13 -0
  8. data/bin/_guard-core +16 -0
  9. data/bin/console +14 -0
  10. data/bin/guard +16 -0
  11. data/bin/rake +16 -0
  12. data/bin/rspec +16 -0
  13. data/bin/rubocop +16 -0
  14. data/bin/setup +7 -0
  15. data/lib/tacokit/authorization.rb +8 -9
  16. data/lib/tacokit/client.rb +14 -20
  17. data/lib/tacokit/client/actions.rb +30 -14
  18. data/lib/tacokit/client/boards.rb +112 -16
  19. data/lib/tacokit/client/cards.rb +251 -72
  20. data/lib/tacokit/client/checklists.rb +25 -14
  21. data/lib/tacokit/client/labels.rb +11 -4
  22. data/lib/tacokit/client/lists.rb +66 -13
  23. data/lib/tacokit/client/members.rb +118 -42
  24. data/lib/tacokit/client/notifications.rb +29 -2
  25. data/lib/tacokit/client/organizations.rb +13 -5
  26. data/lib/tacokit/client/searches.rb +17 -2
  27. data/lib/tacokit/client/tokens.rb +8 -2
  28. data/lib/tacokit/client/types.rb +4 -2
  29. data/lib/tacokit/client/webhooks.rb +17 -4
  30. data/lib/tacokit/collection.rb +6 -5
  31. data/lib/tacokit/configuration.rb +10 -2
  32. data/lib/tacokit/middleware.rb +16 -0
  33. data/lib/tacokit/resource.rb +7 -6
  34. data/lib/tacokit/transform.rb +2 -4
  35. data/lib/tacokit/utils.rb +7 -4
  36. data/lib/tacokit/version.rb +2 -1
  37. data/tacokit.gemspec +4 -4
  38. metadata +17 -273
  39. data/spec/cassettes/Tacokit_Client/_connection/authorized_GET_request_with_app_key_and_token_params.json +0 -1
  40. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_a_token_authorized_action.json +0 -1
  41. data/spec/cassettes/Tacokit_Client_Actions/_action/returns_oauth_authorized_board.json +0 -1
  42. data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +0 -1
  43. data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +0 -1
  44. data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +0 -1
  45. data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +0 -1
  46. data/spec/cassettes/Tacokit_Client_Actions/_delete_action/deletes_an_action.json +0 -1
  47. data/spec/cassettes/Tacokit_Client_Actions/_update_action/updates_an_action.json +0 -1
  48. data/spec/cassettes/Tacokit_Client_Actions/_update_action_text/updates_an_action.json +0 -1
  49. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +0 -1
  50. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_a_token_authorized_board.json +0 -1
  51. data/spec/cassettes/Tacokit_Client_Boards/_board/returns_oauth_authorized_board.json +0 -1
  52. data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +0 -1
  53. data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +0 -1
  54. data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +0 -1
  55. data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +0 -1
  56. data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +0 -1
  57. data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +0 -1
  58. data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +0 -1
  59. data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +0 -1
  60. data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +0 -1
  61. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_a_board.json +0 -1
  62. data/spec/cassettes/Tacokit_Client_Boards/_update_board/updates_nested_resource.json +0 -1
  63. data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +0 -1
  64. data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +0 -1
  65. data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +0 -1
  66. data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +0 -1
  67. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +0 -1
  68. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +0 -1
  69. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +0 -1
  70. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +0 -1
  71. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +0 -1
  72. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +0 -1
  73. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +0 -1
  74. data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +0 -1
  75. data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +0 -1
  76. data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +0 -1
  77. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +0 -1
  78. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +0 -1
  79. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +0 -1
  80. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +0 -1
  81. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +0 -1
  82. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +0 -1
  83. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +0 -1
  84. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +0 -1
  85. data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +0 -1
  86. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +0 -1
  87. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +0 -1
  88. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +0 -1
  89. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +0 -1
  90. data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +0 -1
  91. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +0 -1
  92. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +0 -1
  93. data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +0 -1
  94. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +0 -1
  95. data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +0 -1
  96. data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +0 -1
  97. data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +0 -1
  98. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +0 -1
  99. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +0 -1
  100. data/spec/cassettes/Tacokit_Client_Checklists/_checklist/returns_a_checklist_by_id.json +0 -1
  101. data/spec/cassettes/Tacokit_Client_Checklists/_create_checklist/creates_a_checklist.json +0 -1
  102. data/spec/cassettes/Tacokit_Client_Checklists/_delete_checklist/deletes_a_checklist.json +0 -1
  103. data/spec/cassettes/Tacokit_Client_Checklists/_update_checklist/updates_a_checklist.json +0 -1
  104. data/spec/cassettes/Tacokit_Client_Labels/_create_label/creates_a_label.json +0 -1
  105. data/spec/cassettes/Tacokit_Client_Labels/_delete_label/deletes_a_label.json +0 -1
  106. data/spec/cassettes/Tacokit_Client_Labels/_label/returns_a_label_by_id.json +0 -1
  107. data/spec/cassettes/Tacokit_Client_Labels/_update_label/updates_a_label.json +0 -1
  108. data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +0 -1
  109. data/spec/cassettes/Tacokit_Client_Lists/_create_list/creates_a_list.json +0 -1
  110. data/spec/cassettes/Tacokit_Client_Lists/_list/returns_a_list_by_id.json +0 -1
  111. data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +0 -1
  112. data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +0 -1
  113. data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +0 -1
  114. data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +0 -1
  115. data/spec/cassettes/Tacokit_Client_Lists/_update_list/updates_a_list.json +0 -1
  116. data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +0 -1
  117. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_for_me_with_options_as_first_arg.json +0 -1
  118. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +0 -1
  119. data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +0 -1
  120. data/spec/cassettes/Tacokit_Client_Members/_member/accepts_a_resource.json +0 -1
  121. data/spec/cassettes/Tacokit_Client_Members/_member/authenticated/returns_self.json +0 -1
  122. data/spec/cassettes/Tacokit_Client_Members/_member/returns_a_member.json +0 -1
  123. data/spec/cassettes/Tacokit_Client_Members/_member/returns_self.json +0 -1
  124. data/spec/cassettes/Tacokit_Client_Members/_member/supports_query_fields_as_string_or_array.json +0 -1
  125. data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +0 -1
  126. data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +0 -1
  127. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +0 -1
  128. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_a_member.json +0 -1
  129. data/spec/cassettes/Tacokit_Client_Members/_update_member/updates_nested_resource.json +0 -1
  130. data/spec/cassettes/Tacokit_Client_Notifications/_notification/returns_a_notification_by_id.json +0 -1
  131. data/spec/cassettes/Tacokit_Client_Notifications/_update_notification/updates_a_notification.json +0 -1
  132. data/spec/cassettes/Tacokit_Client_Organizations/_create_organization/creates_a_organization.json +0 -1
  133. data/spec/cassettes/Tacokit_Client_Organizations/_delete_organization/deletes_a_organization.json +0 -1
  134. data/spec/cassettes/Tacokit_Client_Organizations/_organization/returns_an_organization_by_id.json +0 -1
  135. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_actions.json +0 -1
  136. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_boards.json +0 -1
  137. data/spec/cassettes/Tacokit_Client_Organizations/_organization_resource/returns_organization_members.json +0 -1
  138. data/spec/cassettes/Tacokit_Client_Organizations/_update_organization/updates_a_organization.json +0 -1
  139. data/spec/cassettes/Tacokit_Client_Searches/_search/returns_search_result.json +0 -1
  140. data/spec/cassettes/Tacokit_Client_Tokens/_delete_token/deletes_a_token.json +0 -1
  141. data/spec/cassettes/Tacokit_Client_Tokens/_token/returns_a_token_for_token_string.json +0 -1
  142. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_member.json +0 -1
  143. data/spec/cassettes/Tacokit_Client_Tokens/_token_resource/returns_token_webhooks.json +0 -1
  144. data/spec/cassettes/Tacokit_Client_Types/_type/returns_a_type_by_id.json +0 -1
  145. data/spec/cassettes/Tacokit_Client_Webhooks/_create_webhook/creates_a_webhook.json +0 -1
  146. data/spec/cassettes/Tacokit_Client_Webhooks/_delete_webhook/deletes_a_webhook.json +0 -1
  147. data/spec/cassettes/Tacokit_Client_Webhooks/_update_webhook/updates_a_webhook.json +0 -1
  148. data/spec/cassettes/Tacokit_Client_Webhooks/_webhook/returns_a_webhook_by_short_link.json +0 -1
  149. data/spec/fixtures/taco.png +0 -0
  150. data/spec/spec_helper.rb +0 -171
  151. data/spec/tacokit/authorization_spec.rb +0 -47
  152. data/spec/tacokit/client/actions_spec.rb +0 -137
  153. data/spec/tacokit/client/boards_spec.rb +0 -171
  154. data/spec/tacokit/client/cards_spec.rb +0 -446
  155. data/spec/tacokit/client/checklists_spec.rb +0 -89
  156. data/spec/tacokit/client/labels_spec.rb +0 -62
  157. data/spec/tacokit/client/lists_spec.rb +0 -131
  158. data/spec/tacokit/client/members_spec.rb +0 -145
  159. data/spec/tacokit/client/notifications_spec.rb +0 -25
  160. data/spec/tacokit/client/organizations_spec.rb +0 -79
  161. data/spec/tacokit/client/searches_spec.rb +0 -11
  162. data/spec/tacokit/client/tokens_spec.rb +0 -33
  163. data/spec/tacokit/client/types_spec.rb +0 -11
  164. data/spec/tacokit/client/webhooks_spec.rb +0 -61
  165. data/spec/tacokit/client_spec.rb +0 -28
  166. data/spec/tacokit/configuration_spec.rb +0 -50
  167. data/spec/tacokit/middleware/raise_error_spec.rb +0 -34
  168. data/spec/tacokit/resource_spec.rb +0 -151
  169. data/spec/tacokit/transform_spec.rb +0 -133
  170. data/spec/tacokit_spec.rb +0 -14
@@ -1,47 +0,0 @@
1
- require "spec_helper"
2
- require "launchy"
3
-
4
- describe Tacokit::Authorization do
5
- before do
6
- allow(Launchy).to receive(:open)
7
- end
8
-
9
- describe "#get_app_key" do
10
- it "launches app key endpoint" do
11
- expect(Launchy).to receive(:open).with("https://trello.com/1/appKey/generate")
12
-
13
- Tacokit.client.get_app_key
14
- end
15
-
16
- it "doesn't require launchy", :silence_warnings do
17
- allow(Launchy).to receive(:open).and_raise(LoadError)
18
-
19
- Tacokit.client.get_app_key
20
- end
21
- end
22
-
23
- describe "#authorize" do
24
- it "launches authorize endpoint" do
25
- authorize_url = "https://trello.com/1/authorize?key=#{test_trello_app_key}&name=Tacokit&response_type=token"
26
- expect(Launchy).to receive(:open).with(authorize_url)
27
-
28
- Tacokit.client.authorize
29
- end
30
- end
31
-
32
- describe "#authorize_url" do
33
- it "returns the url to authorize user via web flow" do
34
- uri = Addressable::URI.parse Tacokit.authorize_url(
35
- app_name: "Tacokit", key: test_trello_app_key, scope: "read")
36
-
37
- expect(uri.scheme).to eq "https"
38
- expect(uri.host).to eq "trello.com"
39
-
40
- params = uri.query_values
41
- expect(params["key"]).to eq test_trello_app_key
42
- expect(params["app_name"]).to eq "Tacokit"
43
- expect(params["response_type"]).to eq "token"
44
- expect(params["scope"]).to eq "read"
45
- end
46
- end
47
- end
@@ -1,137 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Tacokit::Client::Actions do
4
- def test_action_id
5
- "548e3153ea7ca8f9cd3cb77b"
6
- end
7
-
8
- def test_card_id
9
- "548dd95c8ca25ac9d0d9ce71"
10
- end
11
-
12
- describe "#action", :vcr do
13
- it "returns a token authorized action" do
14
- action = app_client.action(test_action_id)
15
-
16
- expect(action.type).to be_present
17
- expect(action.data).to be_any
18
- end
19
-
20
- it "returns oauth authorized board" do
21
- action = oauth_client.action(test_action_id)
22
-
23
- expect(action.type).to be_present
24
- expect(action.data).to be_any
25
- end
26
- end
27
-
28
- describe "#action_board", :vcr do
29
- before do
30
- @action = app_client.add_comment(test_card_id, "Get action resource test. Booya!")
31
- end
32
-
33
- it "returns action board" do
34
- board = app_client.action_board(@action.id)
35
-
36
- expect(board.name).to be_present
37
- end
38
-
39
- after do
40
- app_client.delete_action(@action.id)
41
- end
42
- end
43
-
44
- describe "#action_card", :vcr do
45
- before do
46
- @action = app_client.add_comment(test_card_id, "Get action resource test. Booya!")
47
- end
48
-
49
- it "returns action card" do
50
- card = app_client.action_card(@action.id)
51
-
52
- expect(card.name).to be_present
53
- end
54
-
55
- after do
56
- app_client.delete_action(@action.id)
57
- end
58
- end
59
-
60
- describe "#action_entities", :vcr do
61
- before do
62
- @action = app_client.add_comment(test_card_id, "Get action resource test. Booya!")
63
- end
64
-
65
- it "returns action entities" do
66
- entities = app_client.action_entities(@action.id)
67
-
68
- expect(entities).to be_any
69
- expect(entities.map(&:type)).to include("comment")
70
- end
71
-
72
- after do
73
- app_client.delete_action(@action.id)
74
- end
75
- end
76
-
77
- describe "#action_list", :vcr do
78
- before do
79
- @action = app_client.add_comment(test_card_id, "Get action resource test. Booya!")
80
- end
81
-
82
- it "returns action list" do
83
- list = app_client.action_list(@action.id)
84
-
85
- expect(list.name).to be_present
86
- end
87
-
88
- after do
89
- app_client.delete_action(@action.id)
90
- end
91
- end
92
-
93
- describe "#update_action", :vcr do
94
- before do
95
- @action = app_client.add_comment(test_card_id, "Update action test. Booya!")
96
- end
97
-
98
- it "updates an action" do
99
- action = app_client.update_action(@action.id, text: "@tacokit Thanks for the invite, bud")
100
-
101
- expect(action.data.text).to eq "@tacokit Thanks for the invite, bud"
102
- end
103
-
104
- after do
105
- app_client.delete_action(@action.id)
106
- end
107
- end
108
-
109
- describe "#update_action_text", :vcr do
110
- before do
111
- @action = app_client.add_comment test_card_id, "Update action test. Booya!"
112
- end
113
-
114
- it "updates an action" do
115
- action = app_client.update_action_text(@action.id, "@tacokit Thanks for the invite, bud")
116
-
117
- expect(action.data.text).to eq "@tacokit Thanks for the invite, bud"
118
- end
119
-
120
- after do
121
- app_client.delete_action(@action.id)
122
- end
123
- end
124
-
125
- describe "#delete_action", :vcr do
126
- before do
127
- @action = app_client.add_comment(test_card_id, "Delete action test. Booya!")
128
- end
129
-
130
- it "deletes an action" do
131
- app_client.delete_action(@action.id)
132
-
133
- assert_requested :delete, trello_url_template("actions/#{@action.id}{?key,token}")
134
- expect { app_client.action(@action.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
135
- end
136
- end
137
- end
@@ -1,171 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Tacokit::Client::Boards do
4
- describe "#board", :vcr do
5
- it "returns a token authorized board" do
6
- board = app_client.board(test_board_link)
7
-
8
- expect(board.name).to eq("Test Board")
9
- end
10
-
11
- it "returns oauth authorized board" do
12
- board = oauth_client.board(test_board_link)
13
-
14
- expect(board.name).to eq("Test Board")
15
- end
16
- end
17
-
18
- describe "#board_actions", :vcr do
19
- it "returns board actions" do
20
- actions = app_client.board_actions(test_board_link)
21
-
22
- expect(actions).not_to be_empty
23
-
24
- action = actions.first
25
- expect(action.member_creator.full_name).to be_present
26
- end
27
- end
28
-
29
- describe "#board_stars", :vcr do
30
- it "returns board stars" do
31
- stars = app_client.board_stars(test_board_link)
32
-
33
- expect(stars).not_to be_empty
34
-
35
- expect(stars.first.board_id).to eq(test_board_id)
36
- end
37
- end
38
-
39
- describe "#board_cards", :vcr do
40
- it "returns board cards" do
41
- cards = app_client.board_cards(test_board_link)
42
-
43
- expect(cards).not_to be_empty
44
-
45
- card = cards.first
46
- expect(card.pos).to be_present
47
- end
48
- end
49
-
50
- describe "#board_checklists", :vcr do
51
- it "returns board checklists" do
52
- checklists = app_client.board_checklists(test_board_link)
53
-
54
- expect(checklists).not_to be_empty
55
-
56
- checklist = checklists.first
57
- expect(checklist.name).to eq "Test Checklist 1"
58
- end
59
- end
60
-
61
- describe "#board_labels", :vcr do
62
- it "returns board labels" do
63
- labels = app_client.board_labels(test_board_link)
64
-
65
- expect(labels).not_to be_empty
66
-
67
- blue_labels = labels.select { |l| l.name =~ /^Blue/ }
68
- expect(blue_labels.map(&:name)).to include "Blue Label"
69
- end
70
- end
71
-
72
- describe "#board_lists", :vcr do
73
- it "returns board lists" do
74
- lists = app_client.board_lists(test_board_link)
75
-
76
- expect(lists).not_to be_empty
77
-
78
- list = lists.detect { |l| l.name =~ /^List/ }
79
- expect(list.name).to eq "List 1"
80
- end
81
- end
82
-
83
- describe "#board_members", :vcr do
84
- it "returns board members" do
85
- members = app_client.board_members(test_board_link)
86
-
87
- expect(members).not_to be_empty
88
-
89
- member = members.first
90
- expect(member.username).to eq "rossta"
91
- end
92
- end
93
-
94
- describe "#board_preferences", :vcr do
95
- it "returns preferences for a board" do
96
- prefs = app_client.board_preferences(test_board_link)
97
-
98
- expect(prefs.show_sidebar).to be_truthy
99
- end
100
- end
101
-
102
- describe "#board_organization", :vcr do
103
- it "returns board organization" do
104
- organization = app_client.board_organization(test_board_link)
105
-
106
- expect(organization.name).to eq "teamtacokit"
107
- end
108
- end
109
-
110
- describe "#update_board", :vcr do
111
- it "updates a board" do
112
- board = app_client.update_board(test_board_id, desc: "This board is for Tacokit testing")
113
-
114
- expect(board.desc).to eq "This board is for Tacokit testing"
115
- assert_requested :put, trello_url_template("boards/#{test_board_id}{?key,token}")
116
- end
117
-
118
- it "updates nested resource" do
119
- board = app_client.update_board(test_board_id, label_names: { blue: "Blue Label" })
120
-
121
- expect(board.label_names.to_attrs).to include blue: "Blue Label"
122
- end
123
- end
124
-
125
- pending "#create_board", :vcr do
126
- before do
127
- @board = oauth_client.create_board("Autoboard", desc: "This board was generated by tests")
128
- end
129
-
130
- it "creates a board" do
131
- expect(@board.name).to eq("Autoboard")
132
- expect(@board.desc).to eq("This board was generated by tests")
133
- assert_requested :post, trello_url_template("boards{?key,token}"),
134
- body: {
135
- "name" => "Autoboard",
136
- "desc" => "This board was generated by tests"
137
- }
138
- end
139
-
140
- after do
141
- app_client.update_board @board.id, closed: true
142
- end
143
- end
144
-
145
- describe "#add_board_member", :vcr do
146
- it "adds invites member to board" do
147
- @member = member = app_client.add_board_member(test_board_id, "rossta+tacokit2@example.com", "Taco Kit2")
148
-
149
- expect(member.email).to eq "rossta+tacokit2@example.com"
150
- end
151
-
152
- after do
153
- app_client.delete("boards/#{test_board_id}/members/#{@member.id}")
154
- end
155
- end
156
-
157
- describe "#update_board_member", :vcr do
158
- before do
159
- @member = app_client.add_board_member(test_board_id, "rossta+tacokit@example.com", "Taco Kit3")
160
- end
161
-
162
- it "updates member" do
163
- membership = app_client.update_board_member(test_board_id, @member.id, "normal")
164
- expect(membership.id).to_not be_nil
165
- end
166
-
167
- after do
168
- app_client.delete("boards/#{test_board_id}/members/#{@member.id}")
169
- end
170
- end
171
- end
@@ -1,446 +0,0 @@
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
- describe "#card", :vcr do
13
- it "returns a card by short link" do
14
- card = app_client.card(test_card_link)
15
-
16
- expect(card.name).to eq "Card 1"
17
- end
18
-
19
- it "returns a card by id" do
20
- card = app_client.card(test_card_id)
21
-
22
- expect(card.name).to eq "Card 1"
23
- end
24
-
25
- it "returns a card by card resource" do
26
- card = app_client.card(test_card_link)
27
-
28
- card = app_client.card(card)
29
-
30
- expect(card.name).to eq "Card 1"
31
- end
32
- end
33
-
34
- describe "#card_actions", :vcr do
35
- it "returns card actions" do
36
- actions = app_client.card_actions(test_card_link)
37
-
38
- expect(actions).to be_any
39
- end
40
- end
41
-
42
- describe "#card_board", :vcr do
43
- it "returns card board" do
44
- board = app_client.card_board(test_card_link)
45
-
46
- expect(board.name).to eq("Test Board")
47
- end
48
- end
49
-
50
- describe "#attachments", :vcr do
51
- before do
52
- url = "http://cl.ly/image/2p1x3K1X160b/taco.png"
53
- @attachment = app_client.create_card_attachment(test_card_link, url, "image/png", name: "taco")
54
- end
55
-
56
- it "returns attachments" do
57
- attachments = app_client.attachments(test_card_link)
58
-
59
- expect(attachments.first.name).to eq("taco")
60
- end
61
-
62
- it "returns an attachment" do
63
- attachment = app_client.attachment(test_card_link, @attachment.id)
64
-
65
- expect(attachment.name).to eq("taco")
66
- end
67
-
68
- after do
69
- app_client.remove_attachment(test_card_link, @attachment.id)
70
- end
71
- end
72
-
73
- describe "#checklists", :vcr do
74
- it "returns check_item_states" do
75
- check_item_state = app_client.check_item_states(test_card_link).first
76
- expect(check_item_state.state).to eq("complete")
77
- end
78
-
79
- it "returns checklists" do
80
- checklist = app_client.checklists(test_card_link).first
81
-
82
- expect(checklist.name).to eq("Test Checklist 1")
83
- end
84
- end
85
-
86
- describe "#card_list", :vcr do
87
- it "returns a list" do
88
- list = app_client.card_list(test_card_link)
89
-
90
- expect(list.name).to eq("List 1")
91
- end
92
- end
93
-
94
- describe "#card_members", :vcr do
95
- before do
96
- @member_1 = app_client.member
97
- @member_2 = app_client.member("rossta")
98
-
99
- app_client.update_card test_card_link, member_ids: [@member_1.id, @member_2.id]
100
- end
101
-
102
- it "returns members" do
103
- members = app_client.card_members(test_card_link)
104
-
105
- expect(members.size).to eq(2)
106
- expect(members.first.id).to eq(@member_1.id)
107
- expect(members.last.id).to eq(@member_2.id)
108
- end
109
-
110
- it "returns members voted" do
111
- members = app_client.card_members_voted(test_card_link)
112
-
113
- expect(members).to be_empty
114
- end
115
-
116
- after do
117
- app_client.update_card test_card_link, member_ids: []
118
- end
119
- end
120
-
121
- describe "#stickers", :vcr do
122
- before do
123
- @sticker = app_client.add_sticker(test_card_link, "star")
124
- end
125
-
126
- it "returns stickers" do
127
- stickers = app_client.stickers(test_card_link)
128
-
129
- expect(stickers.size).to eq(1)
130
- expect(stickers.first.image).to eq("star")
131
- end
132
-
133
- after do
134
- app_client.remove_sticker(test_card_link, @sticker.id)
135
- end
136
- end
137
-
138
- describe "#update_card", :vcr do
139
- before do
140
- @member_1 = app_client.member
141
- @member_2 = app_client.member("rossta")
142
- end
143
-
144
- it "updates a card" do
145
- card = app_client.update_card test_card_link,
146
- desc: "This card is for Tacokit testing",
147
- labels: %w[blue green],
148
- member_ids: [@member_1.id, @member_2.id]
149
-
150
- expect(card.desc).to eq "This card is for Tacokit testing"
151
- expect(card.labels.size).to eq(2)
152
- expect(card.member_ids.size).to eq(2)
153
- assert_requested :put, trello_url_template("cards/#{test_card_link}{?key,token}")
154
- end
155
-
156
- after do
157
- app_client.update_card test_card_link, member_ids: []
158
- end
159
- end
160
-
161
- describe "#update_comment", :vcr do
162
- before do
163
- @comment = app_client.add_comment(test_card_link, "I'm singing, I'm singing, I'm singing!")
164
- end
165
-
166
- it "updates a comment" do
167
- app_client.update_comment(test_card_link, @comment.id, "I'm not singing")
168
- actions = app_client.card_actions(test_card_link)
169
-
170
- comment = actions.first.data
171
- expect(comment.text).to eq("I'm not singing")
172
- end
173
-
174
- after do
175
- app_client.remove_comment test_card_link, @comment.id
176
- end
177
- end
178
-
179
- describe "#update_checklist_item", :vcr do
180
- before do
181
- @checklist = app_client.post("cards/#{test_card_link}/checklists", name: "Test Checklist Actions")
182
- @checkitem = app_client.post("cards/#{test_card_link}/checklist/#{@checklist.id}/checkItem", name: "Working for a living")
183
- end
184
-
185
- it "updates checklist item" do
186
- checkitem = app_client.update_check_item(test_card_link, @checklist.id, @checkitem.id, name: "Going on vacation instead")
187
-
188
- expect(checkitem.id).to eq(@checkitem.id)
189
- expect(checkitem.name).to eq("Going on vacation instead")
190
- end
191
-
192
- after do
193
- app_client.delete("cards/#{test_card_link}/checklists/#{@checklist.id}")
194
- end
195
- end
196
-
197
- describe "#archive_card", :vcr do
198
- before do
199
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
200
- end
201
-
202
- it "archives card" do
203
- card = app_client.archive_card(@card.id)
204
-
205
- expect(card.closed).to be_truthy
206
- end
207
-
208
- it "restore card" do
209
- app_client.archive_card(@card.id)
210
- card = app_client.restore_card(@card.id)
211
-
212
- expect(card.closed).to be_falsey
213
- end
214
-
215
- after do
216
- app_client.delete_card(@card.id)
217
- end
218
- end
219
-
220
- describe "#move_card", :vcr do
221
- before do
222
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
223
- @other_board_id = "5496c2a593901c2eb3af5bc6"
224
- @other_board_list_id = "54b280a866e198c7596baca1"
225
- end
226
-
227
- it "moves card to board" do
228
- expect(@card.board_id).to eq(test_board_id)
229
-
230
- card = app_client.move_card(@card.id, board_id: @other_board_id)
231
- expect(card.board_id).to eq(@other_board_id)
232
- end
233
-
234
- it "moves card to list" do
235
- expect(@card.list_id).to eq(test_list_id)
236
-
237
- card = app_client.move_card(@card.id, board_id: @other_board_id)
238
- expect(card.board_id).to eq(@other_board_id)
239
- end
240
-
241
- it "moves card to another board list" do
242
- card = app_client.move_card(@card.id, board_id: @other_board_id, list_id: @other_board_list_id)
243
-
244
- expect(card.board_id).to eq(@other_board_id)
245
- expect(card.list_id).to eq(@other_board_list_id)
246
- end
247
-
248
- it "moves card to a new position" do
249
- bottom_pos = app_client.move_card(@card.id, pos: "bottom").pos
250
-
251
- top_pos = app_client.move_card(@card.id, pos: "top").pos
252
-
253
- expect(bottom_pos).to be > top_pos
254
- end
255
-
256
- it "raises error if missing options" do
257
- expect { app_client.move_card(@card.id) }.to raise_error(ArgumentError)
258
- expect { app_client.move_card @card.id, :foo }.to raise_error(ArgumentError)
259
- expect { app_client.move_card @card.id, foo: :bar }.to raise_error(ArgumentError)
260
- end
261
-
262
- after do
263
- app_client.delete_card(@card.id)
264
- end
265
- end
266
-
267
- describe "#add_member_to_card", :vcr do
268
- before do
269
- @member = app_client.member("rossta")
270
- @card = app_client.card(test_card_link)
271
- end
272
-
273
- it "adds member to card" do
274
- members = app_client.add_member_to_card(test_card_link, @member.id)
275
-
276
- expect(members.size).to eq(@card.member_ids.size + 1)
277
- expect(members.map(&:id)).to include(@member.id)
278
- end
279
-
280
- after do
281
- app_client.update_card test_card_link, member_ids: []
282
- end
283
- end
284
-
285
- describe "#create_card", :vcr do
286
- before do
287
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
288
- end
289
-
290
- it "creates a card" do
291
- expect(@card.name).to eq "Autocard"
292
- expect(@card.desc).to eq "This is an autogenerated card"
293
- assert_requested :post, trello_url_template("cards{?key,token}"),
294
- body: {
295
- "idList" => test_list_id,
296
- "name" => "Autocard",
297
- "desc" => "This is an autogenerated card"
298
- }
299
- end
300
-
301
- after do
302
- app_client.delete_card(@card.id)
303
- end
304
- end
305
-
306
- describe "#create_card_attachment", :vcr do
307
- before do
308
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
309
- end
310
-
311
- it "uploads local file" do
312
- file_path = File.expand_path("../../../fixtures/taco.png", __FILE__)
313
- expect(File.exist?(file_path)).to be_truthy
314
-
315
- attachment = app_client.create_card_attachment(@card.id, file_path, "image/png", name: "taco")
316
-
317
- expect(attachment.name).to eq("taco")
318
-
319
- # TODO: mime_type for upload is not persisted on Trello
320
- # expect(attachment.mime_type).to eq("image/png")
321
- end
322
-
323
- it "attaches external url" do
324
- url = "http://cl.ly/image/2p1x3K1X160b/taco.png"
325
- attachment = app_client.create_card_attachment(@card.id, url, "image/png", name: "taco")
326
-
327
- expect(attachment.name).to eq("taco")
328
-
329
- # TODO: mime_type for upload is not persisted on Trello
330
- # expect(attachment.mime_type).to eq("image/png")
331
- end
332
-
333
- after do
334
- app_client.delete_card(@card.id)
335
- end
336
- end
337
-
338
- describe "#add_comment", :vcr do
339
- before do
340
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
341
- end
342
-
343
- it "creates a comment" do
344
- comment = app_client.add_comment(@card.id, "I'm singing, I'm singing, I'm singing!")
345
-
346
- expect(comment.data.text).to eq "I'm singing, I'm singing, I'm singing!"
347
- expect(comment.data.card.id).to eq @card.id
348
-
349
- actions = app_client.card_actions(@card.id)
350
- expect(actions.map(&:id)).to include(comment.id)
351
- end
352
-
353
- after do
354
- app_client.delete_card(@card.id)
355
- end
356
- end
357
-
358
- describe "#start_checklist", :vcr do
359
- before do
360
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
361
- end
362
-
363
- it "adds new checklist by name" do
364
- checklist = app_client.start_checklist(@card.id, "Making a list")
365
-
366
- expect(checklist.name).to eq("Making a list")
367
- expect(checklist.card_id).to eq(@card.id)
368
- end
369
-
370
- it "copies a checklist by id" do
371
- source_checklist = app_client.start_checklist(@card.id, "Making a list")
372
- app_client.add_checklist_item(source_checklist.id, "Test Checklist Item")
373
-
374
- new_checklist = app_client.copy_checklist(@card.id, source_checklist.id)
375
-
376
- expect(new_checklist.id).to_not eq(source_checklist.id)
377
- expect(new_checklist.check_items.size).to eq(1)
378
- expect(new_checklist.check_items.first.name).to eq("Test Checklist Item")
379
-
380
- assert_requested :post, trello_url_template("cards/#{@card.id}/checklists{?key,token}"),
381
- body: { "idChecklistSource" => source_checklist.id }
382
- end
383
-
384
- after do
385
- app_client.delete_card(@card.id)
386
- end
387
- end
388
-
389
- describe "#add_label", :vcr do
390
- it "adds label to card" do
391
- label = app_client.add_label(test_card_link, "red")
392
-
393
- expect(label.color).to eq("red")
394
- end
395
-
396
- after do
397
- app_client.delete("card/#{test_card_link}/labels/red")
398
- end
399
- end
400
-
401
- describe "#vote", :vcr do
402
- before do
403
- @card = app_client.create_card test_list_id, "Autocard", desc: "This is an autogenerated card"
404
- @member_1 = app_client.member
405
- @member_2 = app_client.member("rossta")
406
- end
407
-
408
- it "adds a member's vote to card" do
409
- app_client.vote(@card.id, @member_1.id)
410
-
411
- voted = app_client.card_members_voted(@card.id)
412
- expect(voted.size).to eq(1)
413
- expect(voted.first.username).to eq("tacokit")
414
- end
415
-
416
- after do
417
- app_client.delete_card(@card.id)
418
- end
419
- end
420
-
421
- describe "#delete_card", :vcr do
422
- before do
423
- @card = app_client.create_card test_list_id, "Autocard"
424
- end
425
-
426
- it "deletes a card" do
427
- app_client.delete_card(@card.id)
428
-
429
- assert_requested :delete, trello_url_template("cards/#{@card.id}{?key,token}")
430
- expect { app_client.card(@card.id) }.to raise_error(Tacokit::Error::ResourceNotFound)
431
- end
432
- end
433
-
434
- describe "#delete_comment", :vcr do
435
- before do
436
- @comment = app_client.add_comment(test_card_link, "This is a comment")
437
- end
438
-
439
- it "deletes comment" do
440
- # rubocop:disable Style/DotPosition
441
- expect { app_client.delete_comment(test_card_link, @comment.id) }.
442
- to change { app_client.card_actions(test_card_link, filter: "comment_card").size }.by(-1)
443
- # rubocop:enable Style/DotPosition
444
- end
445
- end
446
- end