ruby-trello 2.2.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -10
- data/lib/trello/action.rb +31 -23
- data/lib/trello/association_builder/has_many.rb +17 -0
- data/lib/trello/association_builder/has_one.rb +16 -0
- data/lib/trello/association_fetcher/has_many/fetch.rb +47 -0
- data/lib/trello/association_fetcher/has_many/params.rb +56 -0
- data/lib/trello/association_fetcher/has_many.rb +26 -0
- data/lib/trello/association_fetcher/has_one/fetch.rb +49 -0
- data/lib/trello/association_fetcher/has_one/params.rb +36 -0
- data/lib/trello/association_fetcher/has_one.rb +25 -0
- data/lib/trello/association_infer_tool.rb +13 -0
- data/lib/trello/association_proxy.rb +1 -1
- data/lib/trello/attachment.rb +40 -27
- data/lib/trello/basic_data.rb +103 -49
- data/lib/trello/board.rb +88 -102
- data/lib/trello/card.rb +49 -198
- data/lib/trello/checklist.rb +17 -71
- data/lib/trello/comment.rb +39 -26
- data/lib/trello/cover_image.rb +20 -0
- data/lib/trello/custom_field.rb +31 -67
- data/lib/trello/custom_field_item.rb +37 -39
- data/lib/trello/custom_field_option.rb +40 -13
- data/lib/trello/item.rb +27 -16
- data/lib/trello/item_state.rb +7 -15
- data/lib/trello/json_utils.rb +1 -1
- data/lib/trello/label.rb +15 -85
- data/lib/trello/label_name.rb +22 -25
- data/lib/trello/list.rb +31 -44
- data/lib/trello/member.rb +77 -32
- data/lib/trello/notification.rb +27 -20
- data/lib/trello/organization.rb +53 -25
- data/lib/trello/plugin_datum.rb +11 -16
- data/lib/trello/schema/attribute/base.rb +79 -0
- data/lib/trello/schema/attribute/board_pref.rb +45 -0
- data/lib/trello/schema/attribute/custom_field_display.rb +45 -0
- data/lib/trello/schema/attribute/default.rb +45 -0
- data/lib/trello/schema/attribute_builder.rb +42 -0
- data/lib/trello/schema/attribute_registration.rb +47 -0
- data/lib/trello/schema/serializer/default.rb +17 -0
- data/lib/trello/schema/serializer/labels.rb +23 -0
- data/lib/trello/schema/serializer/time.rb +25 -0
- data/lib/trello/schema/serializer/webhooks.rb +25 -0
- data/lib/trello/schema.rb +31 -0
- data/lib/trello/token.rb +15 -12
- data/lib/trello/webhook.rb +18 -71
- data/lib/trello.rb +57 -39
- data/spec/action_spec.rb +2 -3
- data/spec/board_spec.rb +43 -103
- data/spec/card_spec.rb +143 -66
- data/spec/cassettes/action_find_with_id_and_get_all_fields.yml +104 -0
- data/spec/cassettes/board_find_with_id_and_get_all_fields.yml +96 -0
- data/spec/cassettes/board_find_with_id_and_get_specific_fields.yml +96 -0
- data/spec/cassettes/can_add_a_file_from_url_on_a_card.yml +189 -0
- data/spec/cassettes/can_add_a_file_on_a_card.yml +200 -0
- data/spec/cassettes/can_add_a_member_to_a_board.yml +191 -0
- data/spec/cassettes/can_add_a_member_to_a_card.yml +190 -0
- data/spec/cassettes/can_add_label_on_a_card.yml +281 -0
- data/spec/cassettes/can_arvhice_all_cards_of_list.yml +397 -0
- data/spec/cassettes/can_close_bong_a_card.yml +189 -0
- data/spec/cassettes/can_get_actions.yml +196 -0
- data/spec/cassettes/can_get_actions_of_board.yml +188 -0
- data/spec/cassettes/can_get_actions_of_list.yml +202 -0
- data/spec/cassettes/can_get_actions_of_members.yml +199 -0
- data/spec/cassettes/can_get_actions_of_organization.yml +201 -0
- data/spec/cassettes/can_get_attachments.yml +187 -0
- data/spec/cassettes/can_get_boards_of_custom_field.yml +198 -0
- data/spec/cassettes/can_get_boards_of_label.yml +197 -0
- data/spec/cassettes/can_get_boards_of_organization.yml +207 -0
- data/spec/cassettes/can_get_cards_of_board.yml +193 -0
- data/spec/cassettes/can_get_cards_of_list.yml +201 -0
- data/spec/cassettes/can_get_cards_of_member.yml +204 -0
- data/spec/cassettes/can_get_checklists_of_board.yml +187 -0
- data/spec/cassettes/can_get_comments.yml +193 -0
- data/spec/cassettes/can_get_comments_board.yml +109 -0
- data/spec/cassettes/can_get_comments_card.yml +111 -0
- data/spec/cassettes/can_get_comments_list.yml +109 -0
- data/spec/cassettes/can_get_custom_field_options_of_custom_field.yml +197 -0
- data/spec/cassettes/can_get_custom_fields_of_board.yml +187 -0
- data/spec/cassettes/can_get_label_names_of_board.yml +187 -0
- data/spec/cassettes/can_get_labels_of_board.yml +187 -0
- data/spec/cassettes/can_get_lists_of_board.yml +187 -0
- data/spec/cassettes/can_get_members_of_board.yml +188 -0
- data/spec/cassettes/can_get_members_of_organization.yml +200 -0
- data/spec/cassettes/can_get_notifications_of_member.yml +199 -0
- data/spec/cassettes/can_get_organization_of_board.yml +189 -0
- data/spec/cassettes/can_get_organizations_of_member.yml +203 -0
- data/spec/cassettes/can_get_plugin_data_of_board.yml +187 -0
- data/spec/cassettes/can_move_a_card_to_another_board_with_specific_list.yml +373 -0
- data/spec/cassettes/can_move_a_card_to_another_board_without_specific_list.yml +281 -0
- data/spec/cassettes/can_move_a_card_to_another_list.yml +281 -0
- data/spec/cassettes/can_move_all_cards_to_another_list.yml +886 -0
- data/spec/cassettes/can_remove_a_member_from_a_card.yml +185 -0
- data/spec/cassettes/can_remove_an_attachment_on_a_card.yml +277 -0
- data/spec/cassettes/can_remove_an_upvote_on_a_card.yml +465 -0
- data/spec/cassettes/can_remove_label_on_a_card.yml +279 -0
- data/spec/cassettes/can_success_add_comment_to_a_card.yml +196 -0
- data/spec/cassettes/can_success_copy_checklist_to_a_card.yml +281 -0
- data/spec/cassettes/can_success_copy_checklist_to_a_card_without_name_pos.yml +281 -0
- data/spec/cassettes/can_success_create_a_board.yml +98 -0
- data/spec/cassettes/can_success_create_a_board_with_full_parameters.yml +97 -0
- data/spec/cassettes/can_success_create_a_board_without_clone_from_other.yml +98 -0
- data/spec/cassettes/can_success_create_a_card.yml +99 -0
- data/spec/cassettes/can_success_create_a_card_when_due_is_datetime.yml +98 -0
- data/spec/cassettes/can_success_create_a_card_when_due_is_time.yml +98 -0
- data/spec/cassettes/can_success_create_a_checklist.yml +102 -0
- data/spec/cassettes/can_success_create_a_custom_field.yml +102 -0
- data/spec/cassettes/can_success_create_a_custom_field_option.yml +102 -0
- data/spec/cassettes/can_success_create_a_label.yml +102 -0
- data/spec/cassettes/can_success_create_a_list.yml +102 -0
- data/spec/cassettes/can_success_create_a_list_with_full_parameters.yml +102 -0
- data/spec/cassettes/can_success_create_a_organization.yml +104 -0
- data/spec/cassettes/can_success_create_a_webhook.yml +102 -0
- data/spec/cassettes/can_success_create_new_checklist_to_a_card.yml +189 -0
- data/spec/cassettes/can_success_delete_a_custom_field_option.yml +389 -0
- data/spec/cassettes/can_success_delete_card.yml +185 -0
- data/spec/cassettes/can_success_delete_checklist.yml +284 -0
- data/spec/cassettes/can_success_get_card_of_board_by_card_id.yml +188 -0
- data/spec/cassettes/can_success_remove_member_from_board.yml +186 -0
- data/spec/cassettes/can_success_return_all_boards_of_current_user.yml +195 -0
- data/spec/cassettes/can_success_upate_a_board.yml +191 -0
- data/spec/cassettes/can_success_upate_a_card.yml +189 -0
- data/spec/cassettes/can_success_upate_a_list.yml +296 -0
- data/spec/cassettes/can_success_update_bong_a_board.yml +283 -0
- data/spec/cassettes/can_success_update_bong_a_board_with_specific_fields.yml +284 -0
- data/spec/cassettes/can_success_update_bong_a_card.yml +191 -0
- data/spec/cassettes/can_success_update_bong_a_checklist_with_specific_fields.yml +296 -0
- data/spec/cassettes/can_success_update_bong_a_custom_field.yml +200 -0
- data/spec/cassettes/can_success_update_bong_a_label.yml +200 -0
- data/spec/cassettes/can_success_update_bong_a_list.yml +199 -0
- data/spec/cassettes/can_success_update_bong_a_list_with_specific_fields.yml +296 -0
- data/spec/cassettes/can_success_update_bong_a_organization.yml +203 -0
- data/spec/cassettes/can_success_update_bong_a_webhook.yml +296 -0
- data/spec/cassettes/can_upvote_on_a_card.yml +469 -0
- data/spec/cassettes/card_find_with_id_and_get_all_fields.yml +95 -0
- data/spec/cassettes/card_find_with_id_and_get_specific_fields.yml +96 -0
- data/spec/cassettes/checklist_can_add_an_item.yml +296 -0
- data/spec/cassettes/checklist_can_update_the_item_state.yml +296 -0
- data/spec/cassettes/checklist_find_with_id_and_get_all_fields.yml +100 -0
- data/spec/cassettes/comment_delete.yml +331 -0
- data/spec/cassettes/comment_find_with_id.yml +116 -0
- data/spec/cassettes/custom_field_find_with_id_and_get_all_fields.yml +100 -0
- data/spec/cassettes/custom_field_find_with_id_and_get_specific_fields.yml +100 -0
- data/spec/cassettes/custom_field_item_save_1.yml +97 -0
- data/spec/cassettes/custom_field_item_save_2.yml +281 -0
- data/spec/cassettes/custom_field_option_find_with_id.yml +100 -0
- data/spec/cassettes/get_board_of_card.yml +187 -0
- data/spec/cassettes/get_board_of_list.yml +197 -0
- data/spec/cassettes/get_boards_of_member.yml +207 -0
- data/spec/cassettes/get_check_item_states_of_card.yml +188 -0
- data/spec/cassettes/get_checklists_of_card.yml +187 -0
- data/spec/cassettes/get_cover_image_of_card.yml +187 -0
- data/spec/cassettes/get_custom_field_items_of_card.yml +187 -0
- data/spec/cassettes/get_list_of_card.yml +188 -0
- data/spec/cassettes/get_lists.yml +187 -0
- data/spec/cassettes/get_members_of_card.yml +189 -0
- data/spec/cassettes/get_plugin_data_of_card.yml +187 -0
- data/spec/cassettes/get_voters_of_card.yml +188 -0
- data/spec/cassettes/label_delete.yml +285 -0
- data/spec/cassettes/label_find_with_id.yml +100 -0
- data/spec/cassettes/list_find_with_id_and_get_all_fields.yml +100 -0
- data/spec/cassettes/list_find_with_id_and_get_specific_fields.yml +100 -0
- data/spec/cassettes/member_find_with_id_and_get_all_fields.yml +101 -0
- data/spec/cassettes/member_find_with_id_and_get_specific_fields.yml +100 -0
- data/spec/cassettes/notification_find_with_id.yml +103 -0
- data/spec/cassettes/organization_find_with_id_and_get_all_fields.yml +102 -0
- data/spec/cassettes/organization_find_with_id_and_get_specific_fields.yml +100 -0
- data/spec/cassettes/remove_upvote_on_a_card_when_have_not_voted.yml +366 -0
- data/spec/cassettes/revote_on_a_card.yml +464 -0
- data/spec/cassettes/token_find_with_token_string.yml +100 -0
- data/spec/cassettes/webhook_delete.yml +286 -0
- data/spec/cassettes/webhook_find_with_id.yml +100 -0
- data/spec/checklist_spec.rb +27 -43
- data/spec/custom_field_item_spec.rb +74 -0
- data/spec/custom_field_option_spec.rb +2 -2
- data/spec/custom_field_spec.rb +98 -10
- data/spec/integration/action/find_spec.rb +23 -0
- data/spec/integration/basic_data/many_spec.rb +127 -0
- data/spec/integration/basic_data/one_spec.rb +84 -0
- data/spec/integration/basic_data/schema_spec.rb +156 -0
- data/spec/integration/board/add_member_spec.rb +21 -0
- data/spec/integration/board/all_spec.rb +20 -0
- data/spec/integration/board/associations/actions_spec.rb +18 -0
- data/spec/integration/board/associations/cards_spec.rb +18 -0
- data/spec/integration/board/associations/checklists_spec.rb +18 -0
- data/spec/integration/board/associations/custom_fields_spec.rb +18 -0
- data/spec/integration/board/associations/label_names_spec.rb +17 -0
- data/spec/integration/board/associations/labels_spec.rb +18 -0
- data/spec/integration/board/associations/lists_spec.rb +18 -0
- data/spec/integration/board/associations/members_spec.rb +18 -0
- data/spec/integration/board/associations/organization_spec.rb +19 -0
- data/spec/integration/board/associations/plugin_data_spec.rb +18 -0
- data/spec/integration/board/create_spec.rb +95 -0
- data/spec/integration/board/find_card_spec.rb +18 -0
- data/spec/integration/board/find_spec.rb +42 -0
- data/spec/integration/board/remove_member_spec.rb +21 -0
- data/spec/integration/board/save_spec.rb +37 -0
- data/spec/integration/board/update!_spec.rb +62 -0
- data/spec/integration/board_lists_spec.rb +21 -0
- data/spec/integration/card/add_and_remove_attachment_spec.rb +45 -0
- data/spec/integration/card/add_and_remove_label_spec.rb +35 -0
- data/spec/integration/card/add_checklist_spec.rb +32 -0
- data/spec/integration/card/add_comment_spec.rb +19 -0
- data/spec/integration/card/add_memeber_spec.rb +19 -0
- data/spec/integration/card/associations/actions_spec.rb +17 -0
- data/spec/integration/card/associations/attachments_spec.rb +18 -0
- data/spec/integration/card/associations/board_spec.rb +17 -0
- data/spec/integration/card/associations/check_item_states_spec.rb +17 -0
- data/spec/integration/card/associations/checklists_spec.rb +18 -0
- data/spec/integration/card/associations/comments_spec.rb +19 -0
- data/spec/integration/card/associations/cover_image_spec.rb +18 -0
- data/spec/integration/card/associations/custom_field_items_spec.rb +18 -0
- data/spec/integration/card/associations/list_spec.rb +16 -0
- data/spec/integration/card/associations/members_spec.rb +18 -0
- data/spec/integration/card/associations/plugin_data_spec.rb +18 -0
- data/spec/integration/card/associations/voters_spec.rb +17 -0
- data/spec/integration/card/close!_spec.rb +16 -0
- data/spec/integration/card/create_new_check_list_spec.rb +19 -0
- data/spec/integration/card/create_spec.rb +84 -0
- data/spec/integration/card/delete_spec.rb +16 -0
- data/spec/integration/card/find_spec.rb +67 -0
- data/spec/integration/card/move_to_board_spec.rb +36 -0
- data/spec/integration/card/move_to_list_spec.rb +20 -0
- data/spec/integration/card/remove_member_spec.rb +19 -0
- data/spec/integration/card/save_spec.rb +61 -0
- data/spec/integration/card/update!_spec.rb +53 -0
- data/spec/integration/card/vote_spec.rb +50 -0
- data/spec/integration/checklist/add_item_spec.rb +20 -0
- data/spec/integration/checklist/create_spec.rb +23 -0
- data/spec/integration/checklist/delete_spec.rb +17 -0
- data/spec/integration/checklist/find_spec.rb +22 -0
- data/spec/integration/checklist/update!_spec.rb +21 -0
- data/spec/integration/checklist/update_item_state_spec.rb +20 -0
- data/spec/integration/comment/association/board_spec.rb +17 -0
- data/spec/integration/comment/association/card_spec.rb +17 -0
- data/spec/integration/comment/association/list_spec.rb +17 -0
- data/spec/integration/comment/delete_spec.rb +20 -0
- data/spec/integration/comment/find_spec.rb +17 -0
- data/spec/integration/custom_field/association/board_spec.rb +18 -0
- data/spec/integration/custom_field/association/custom_field_options_spec.rb +18 -0
- data/spec/integration/custom_field/create_spec.rb +29 -0
- data/spec/integration/custom_field/find_spec.rb +41 -0
- data/spec/integration/custom_field/update!_spec.rb +25 -0
- data/spec/integration/custom_field_item_spec.rb +47 -0
- data/spec/integration/custom_field_option/create_spec.rb +23 -0
- data/spec/integration/custom_field_option/delete_spec.rb +19 -0
- data/spec/integration/custom_field_option/find_spec.rb +21 -0
- data/spec/integration/label/association/board_spec.rb +18 -0
- data/spec/integration/label/create_spec.rb +23 -0
- data/spec/integration/label/delete_spec.rb +21 -0
- data/spec/integration/label/find_spec.rb +20 -0
- data/spec/integration/label/update!_spec.rb +25 -0
- data/spec/integration/list/archive_all_cards_spec.rb +20 -0
- data/spec/integration/list/associations/actions_spec.rb +18 -0
- data/spec/integration/list/associations/board_spec.rb +18 -0
- data/spec/integration/list/associations/cards_spec.rb +18 -0
- data/spec/integration/list/create_spec.rb +44 -0
- data/spec/integration/list/find_spec.rb +37 -0
- data/spec/integration/list/move_all_cards_spec.rb +31 -0
- data/spec/integration/list/save_spec.rb +40 -0
- data/spec/integration/list/update!_spec.rb +43 -0
- data/spec/integration/member/associations/actions_spec.rb +17 -0
- data/spec/integration/member/associations/boards_spec.rb +18 -0
- data/spec/integration/member/associations/cards_spec.rb +18 -0
- data/spec/integration/member/associations/notifications_spec.rb +18 -0
- data/spec/integration/member/associations/organizations_spec.rb +18 -0
- data/spec/integration/member/find_spec.rb +39 -0
- data/spec/integration/member/update!_spec.rb +18 -0
- data/spec/integration/notification/find_spec.rb +27 -0
- data/spec/integration/organization/associations/actions_spec.rb +18 -0
- data/spec/integration/organization/associations/boards_spec.rb +18 -0
- data/spec/integration/organization/associations/members_spec.rb +18 -0
- data/spec/integration/organization/create_spec.rb +23 -0
- data/spec/integration/organization/find_spec.rb +37 -0
- data/spec/integration/organization/update!_spec.rb +28 -0
- data/spec/integration/token/find_spec.rb +24 -0
- data/spec/integration/webhook/create_spec.rb +27 -0
- data/spec/integration/webhook/delete_spec.rb +21 -0
- data/spec/integration/webhook/find_spec.rb +22 -0
- data/spec/integration/webhook/update!_spec.rb +24 -0
- data/spec/item_spec.rb +2 -2
- data/spec/label_spec.rb +105 -28
- data/spec/list_spec.rb +32 -14
- data/spec/notification_spec.rb +3 -3
- data/spec/organization_spec.rb +6 -5
- data/spec/spec_helper.rb +70 -37
- data/spec/token_spec.rb +10 -11
- data/spec/unit/trello/association_builder/has_many_spec.rb +36 -0
- data/spec/unit/trello/association_builder/has_one_spec.rb +36 -0
- data/spec/unit/trello/association_fetcher/has_many/fetch_spec.rb +38 -0
- data/spec/unit/trello/association_fetcher/has_many/params_spec.rb +107 -0
- data/spec/unit/trello/association_fetcher/has_many_spec.rb +50 -0
- data/spec/unit/trello/association_fetcher/has_one/fetch_spec.rb +51 -0
- data/spec/unit/trello/association_fetcher/has_one/params_spec.rb +81 -0
- data/spec/unit/trello/association_fetcher/has_one_spec.rb +49 -0
- data/spec/unit/trello/association_infer_tool_spec.rb +41 -0
- data/spec/unit/trello/basic_data_spec.rb +113 -0
- data/spec/unit/trello/board/new_spec.rb +370 -0
- data/spec/unit/trello/board/save_spec.rb +49 -0
- data/spec/unit/trello/board/update_fields_spec.rb +129 -0
- data/spec/unit/trello/board/update_spec.rb +197 -0
- data/spec/unit/trello/card_spec.rb +103 -0
- data/spec/unit/trello/member/new_spec.rb +62 -0
- data/spec/unit/trello/member/update_fields_spec.rb +80 -0
- data/spec/unit/trello/schema/attribute/base_spec.rb +349 -0
- data/spec/unit/trello/schema/attribute/board_pref_spec.rb +208 -0
- data/spec/unit/trello/schema/attribute/default_spec.rb +236 -0
- data/spec/unit/trello/schema/attribute_builder_spec.rb +55 -0
- data/spec/unit/trello/schema/attribute_registration_spec.rb +59 -0
- data/spec/unit/trello/schema/serializer/default_spec.rb +19 -0
- data/spec/unit/trello/schema/serializer/time_spec.rb +39 -0
- data/spec/unit/trello/schema_spec.rb +25 -0
- data/spec/webhook_spec.rb +23 -7
- metadata +556 -33
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Board#update!' do
|
4
|
+
|
5
|
+
let(:client) { Trello.client }
|
6
|
+
let(:board) { Trello::Board.new(id: 'abc123') }
|
7
|
+
|
8
|
+
before { allow(board).to receive(:from_response) }
|
9
|
+
|
10
|
+
it 'can update name through client' do
|
11
|
+
board.name = 'Board 1'
|
12
|
+
|
13
|
+
expect(client)
|
14
|
+
.to receive(:put)
|
15
|
+
.with('/boards/abc123', {
|
16
|
+
'name' => 'Board 1'
|
17
|
+
})
|
18
|
+
|
19
|
+
board.update!
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can update description through client' do
|
23
|
+
board.description = 'description ...'
|
24
|
+
|
25
|
+
expect(client)
|
26
|
+
.to receive(:put)
|
27
|
+
.with('/boards/abc123', {
|
28
|
+
'desc' => 'description ...'
|
29
|
+
})
|
30
|
+
|
31
|
+
board.update!
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can update closed through client' do
|
35
|
+
board.closed = true
|
36
|
+
|
37
|
+
expect(client)
|
38
|
+
.to receive(:put)
|
39
|
+
.with('/boards/abc123', {
|
40
|
+
'closed' => true
|
41
|
+
})
|
42
|
+
|
43
|
+
board.update!
|
44
|
+
end
|
45
|
+
|
46
|
+
# it 'can update subscribed through client' do
|
47
|
+
# end
|
48
|
+
|
49
|
+
it 'can update organization_id through client' do
|
50
|
+
board.organization_id = 123
|
51
|
+
|
52
|
+
expect(client)
|
53
|
+
.to receive(:put)
|
54
|
+
.with('/boards/abc123', {
|
55
|
+
'idOrganization' => 123
|
56
|
+
})
|
57
|
+
|
58
|
+
board.update!
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'can update visibility_level through client' do
|
62
|
+
board.visibility_level = 'org'
|
63
|
+
|
64
|
+
expect(client)
|
65
|
+
.to receive(:put)
|
66
|
+
.with('/boards/abc123', {
|
67
|
+
'prefs/permissionLevel' => 'org'
|
68
|
+
})
|
69
|
+
|
70
|
+
board.update!
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'can update enable_self_join through client' do
|
74
|
+
board.enable_self_join = true
|
75
|
+
|
76
|
+
expect(client)
|
77
|
+
.to receive(:put)
|
78
|
+
.with('/boards/abc123', {
|
79
|
+
'prefs/selfJoin' => true
|
80
|
+
})
|
81
|
+
|
82
|
+
board.update!
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'can update enable_card_covers through client' do
|
86
|
+
board.enable_card_covers = true
|
87
|
+
|
88
|
+
expect(client)
|
89
|
+
.to receive(:put)
|
90
|
+
.with('/boards/abc123', {
|
91
|
+
'prefs/cardCovers' => true
|
92
|
+
})
|
93
|
+
|
94
|
+
board.update!
|
95
|
+
end
|
96
|
+
|
97
|
+
# it 'can update hide_votes through client' do
|
98
|
+
# end
|
99
|
+
|
100
|
+
it 'can update invitation_permission_level through client' do
|
101
|
+
board.invitation_permission_level = 'org'
|
102
|
+
|
103
|
+
expect(client)
|
104
|
+
.to receive(:put)
|
105
|
+
.with('/boards/abc123', {
|
106
|
+
'prefs/invitations' => 'org'
|
107
|
+
})
|
108
|
+
|
109
|
+
board.update!
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'can update voting_permission_level through client' do
|
113
|
+
board.voting_permission_level = 'org'
|
114
|
+
|
115
|
+
expect(client)
|
116
|
+
.to receive(:put)
|
117
|
+
.with('/boards/abc123', {
|
118
|
+
'prefs/voting' => 'org'
|
119
|
+
})
|
120
|
+
|
121
|
+
board.update!
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'can update comment_permission_level through client' do
|
125
|
+
board.comment_permission_level = 'org'
|
126
|
+
|
127
|
+
expect(client)
|
128
|
+
.to receive(:put)
|
129
|
+
.with('/boards/abc123', {
|
130
|
+
'prefs/comments' => 'org'
|
131
|
+
})
|
132
|
+
|
133
|
+
board.update!
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'can update background_color through client' do
|
137
|
+
board.background_color = 'blue'
|
138
|
+
|
139
|
+
expect(client)
|
140
|
+
.to receive(:put)
|
141
|
+
.with('/boards/abc123', {
|
142
|
+
'prefs/background' => 'blue'
|
143
|
+
})
|
144
|
+
|
145
|
+
board.update!
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'can update card_aging_type through client' do
|
149
|
+
board.card_aging_type = 'pirate'
|
150
|
+
|
151
|
+
expect(client)
|
152
|
+
.to receive(:put)
|
153
|
+
.with('/boards/abc123', {
|
154
|
+
'prefs/cardAging' => 'pirate'
|
155
|
+
})
|
156
|
+
|
157
|
+
board.update!
|
158
|
+
end
|
159
|
+
|
160
|
+
# it 'can update enable_calendar_feed through client' do
|
161
|
+
# end
|
162
|
+
|
163
|
+
it 'can update all through client' do
|
164
|
+
board.name = 'Board 1'
|
165
|
+
board.description = 'description ...'
|
166
|
+
board.closed = true
|
167
|
+
board.organization_id = 123
|
168
|
+
board.visibility_level = 'org'
|
169
|
+
board.enable_self_join = true
|
170
|
+
board.enable_card_covers = true
|
171
|
+
board.invitation_permission_level = 'org'
|
172
|
+
board.voting_permission_level = 'org'
|
173
|
+
board.comment_permission_level = 'org'
|
174
|
+
board.background_color = 'blue'
|
175
|
+
board.card_aging_type = 'pirate'
|
176
|
+
|
177
|
+
expect(client)
|
178
|
+
.to receive(:put)
|
179
|
+
.with('/boards/abc123', {
|
180
|
+
'name' => 'Board 1',
|
181
|
+
'desc' => 'description ...',
|
182
|
+
'closed' => true,
|
183
|
+
'idOrganization' => 123,
|
184
|
+
'prefs/permissionLevel' => 'org',
|
185
|
+
'prefs/selfJoin' => true,
|
186
|
+
'prefs/cardCovers' => true,
|
187
|
+
'prefs/invitations' => 'org',
|
188
|
+
'prefs/voting' => 'org',
|
189
|
+
'prefs/comments' => 'org',
|
190
|
+
'prefs/background' => 'blue',
|
191
|
+
'prefs/cardAging' => 'pirate'
|
192
|
+
})
|
193
|
+
|
194
|
+
board.update!
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Trello::Card do
|
4
|
+
|
5
|
+
describe '.path_name' do
|
6
|
+
specify { expect(Trello::Card.path_name).to eq('card') }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#closed?' do
|
10
|
+
specify { expect(Trello::Card.new('closed' => true).closed?).to eq(true) }
|
11
|
+
specify { expect(Trello::Card.new('closed' => false).closed?).to eq(false) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#close' do
|
15
|
+
let(:card) { Trello::Card.new('closed' => false) }
|
16
|
+
|
17
|
+
it 'can mark card as closed' do
|
18
|
+
card.close
|
19
|
+
expect(card.closed).to eq(true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'close!' do
|
24
|
+
let(:card) { Trello::Card.new('closed' => false) }
|
25
|
+
|
26
|
+
it 'will call save' do
|
27
|
+
expect(card).to receive(:save)
|
28
|
+
card.close!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'valid?' do
|
33
|
+
let(:card) { Trello::Card.new('name' => name, 'idList' => list_id) }
|
34
|
+
|
35
|
+
context 'when name is nil' do
|
36
|
+
let(:name) { nil }
|
37
|
+
let(:list_id) { 1 }
|
38
|
+
|
39
|
+
specify { expect(card.valid?).to eq(false) }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when list_id is nil' do
|
43
|
+
let(:name) { 'Card Name' }
|
44
|
+
let(:list_id) { nil }
|
45
|
+
|
46
|
+
specify { expect(card.valid?).to eq(false) }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "when name and list_id both aren't nil" do
|
50
|
+
let(:name) { 'Card' }
|
51
|
+
let(:list_id) { 1 }
|
52
|
+
|
53
|
+
specify { expect(card.valid?).to eq(true) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#move_to_list_on_any_board' do
|
58
|
+
let(:card) { Trello::Card.new(board_id: 'board-aaa') }
|
59
|
+
let(:move_to_list_on_any_board) { card.move_to_list_on_any_board('listid') }
|
60
|
+
|
61
|
+
let(:board) { Trello::Board.new(id: 'board-aaa') }
|
62
|
+
let(:target_list) { Trello::List.new(board_id: target_board_id) }
|
63
|
+
|
64
|
+
before do
|
65
|
+
allow(Trello::List).to receive(:find).with('listid').and_return(target_list)
|
66
|
+
allow(card).to receive(:board).and_return(board)
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when target list is in the same board' do
|
70
|
+
let(:target_board_id) { 'board-aaa' }
|
71
|
+
|
72
|
+
it 'call #move_to_list on card' do
|
73
|
+
expect(card).to receive(:move_to_list).with('listid')
|
74
|
+
|
75
|
+
move_to_list_on_any_board
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'when target list is in a different board' do
|
80
|
+
let(:target_board_id) { 'board-bbb' }
|
81
|
+
let(:target_board) { Trello::Board.new(id: 'board-bbb') }
|
82
|
+
|
83
|
+
before { allow(Trello::Board).to receive(:find).with('board-bbb').and_return(target_board) }
|
84
|
+
|
85
|
+
it 'call #move_to_board on card' do
|
86
|
+
expect(card).to receive(:move_to_board).with(target_board, target_list)
|
87
|
+
|
88
|
+
move_to_list_on_any_board
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#created_at' do
|
94
|
+
it 'can get created_at from card id' do
|
95
|
+
card = Trello::Card.new('id' => '5e95d1b4f43f9a06497f17f7')
|
96
|
+
expect(card.created_at).to eq(Time.new(2020, 4, 14, 15, 7, 32, '+00:00'))
|
97
|
+
|
98
|
+
card = Trello::Card.new('id' => '5e94ee7df8784d61ee48319e')
|
99
|
+
expect(card.created_at).to eq(Time.new(2020, 4, 13, 22, 58, 05, '+00:00'))
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
RSpec.describe 'Trello::Member#new' do
|
5
|
+
|
6
|
+
let(:member) { Trello::Member.new(data) }
|
7
|
+
|
8
|
+
describe 'parse #id (readonly primary_key)' do
|
9
|
+
context 'with Trello API respone data' do
|
10
|
+
let(:data) { { 'id' => '5e93ba98614ac22d22f085c4' } }
|
11
|
+
|
12
|
+
it "parse from data['id']" do
|
13
|
+
expect(member.id).to eq('5e93ba98614ac22d22f085c4')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with Ruby-like data' do
|
18
|
+
let(:data) { { id: '5e93ba98614ac22d22f085c4' } }
|
19
|
+
|
20
|
+
it 'parse from data[:id]' do
|
21
|
+
expect(member.id).to eq('5e93ba98614ac22d22f085c4')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'parse #username (writable)' do
|
27
|
+
context 'with Trello API respone data' do
|
28
|
+
let(:data) { { 'username' => 'hoppertest' } }
|
29
|
+
|
30
|
+
it "parse from data['username']" do
|
31
|
+
expect(member.username).to eq('hoppertest')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with Ruby-like data' do
|
36
|
+
let(:data) { { username: 'hoppertest' } }
|
37
|
+
|
38
|
+
it 'parse from data[:id]' do
|
39
|
+
expect(member.username).to eq('hoppertest')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'parse #full_name (writable)' do
|
45
|
+
context 'with Trello API respone data' do
|
46
|
+
let(:data) { { 'fullName' => 'hoppertest' } }
|
47
|
+
|
48
|
+
it "parse from data['fullName']" do
|
49
|
+
expect(member.full_name).to eq('hoppertest')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with Ruby-like data' do
|
54
|
+
let(:data) { { full_name: 'hoppertest' } }
|
55
|
+
|
56
|
+
it 'parse from data[:full_name]' do
|
57
|
+
expect(member.full_name).to eq('hoppertest')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Member#update_fields' do
|
4
|
+
|
5
|
+
let(:member_params) { {
|
6
|
+
'id' => '5e93ba403f1ab3603ba81a09',
|
7
|
+
'bio' => 'test',
|
8
|
+
'username' => 'hoppertest',
|
9
|
+
'email' => 'test@test.com'
|
10
|
+
} }
|
11
|
+
|
12
|
+
let(:member) { Trello::Member.new(member_params) }
|
13
|
+
|
14
|
+
context 'when the fields argument is empty' do
|
15
|
+
let(:fields) { {} }
|
16
|
+
|
17
|
+
it 'member does not set any fields' do
|
18
|
+
member.update_fields(fields)
|
19
|
+
|
20
|
+
expect(member.changed?).to be_falsy
|
21
|
+
expect(member.id).to eq(member_params['id'])
|
22
|
+
expect(member.username).to eq(member_params['username'])
|
23
|
+
expect(member.email).to eq(member_params['email'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the fields argument has at least one field' do
|
28
|
+
|
29
|
+
context 'and the field does changed' do
|
30
|
+
let(:fields) { { username: 'hopperchange' } }
|
31
|
+
|
32
|
+
it 'member does set the changed fields' do
|
33
|
+
member.update_fields(fields)
|
34
|
+
|
35
|
+
expect(member.username).to eq('hopperchange')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'member has been mark as changed' do
|
39
|
+
member.update_fields(fields)
|
40
|
+
|
41
|
+
expect(member.changed?).to be_truthy
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "and the field doesn't changed" do
|
46
|
+
let(:fields) { { username: member_params['username'] } }
|
47
|
+
|
48
|
+
it "member attributes doesn't changed" do
|
49
|
+
member.update_fields(fields)
|
50
|
+
|
51
|
+
expect(member.username).to eq(member_params['username'])
|
52
|
+
end
|
53
|
+
|
54
|
+
it "member hasn't been mark as changed" do
|
55
|
+
member.update_fields(fields)
|
56
|
+
|
57
|
+
expect(member.changed?).to be_falsy
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "and the field isn't a correct attributes of the card" do
|
62
|
+
let(:fields) { { abc: 'abc' } }
|
63
|
+
|
64
|
+
it "card attributes doesn't changed" do
|
65
|
+
member.update_fields(fields)
|
66
|
+
|
67
|
+
expect(member.id).to eq(member_params['id'])
|
68
|
+
expect(member.username).to eq(member_params['username'])
|
69
|
+
expect(member.email).to eq(member_params['email'])
|
70
|
+
end
|
71
|
+
|
72
|
+
it "card hasn't been mark as changed" do
|
73
|
+
member.update_fields(fields)
|
74
|
+
|
75
|
+
expect(member.changed?).to be_falsy
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|