ruby-trello 2.0.1 → 3.0.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 +61 -10
- data/lib/trello.rb +57 -36
- 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.rb +26 -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_one.rb +25 -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_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 +112 -50
- data/lib/trello/board.rb +91 -101
- data/lib/trello/card.rb +53 -200
- data/lib/trello/checklist.rb +17 -71
- data/lib/trello/comment.rb +32 -22
- data/lib/trello/cover_image.rb +20 -0
- data/lib/trello/custom_field.rb +78 -0
- data/lib/trello/custom_field_item.rb +76 -0
- data/lib/trello/custom_field_option.rb +49 -0
- 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 -84
- data/lib/trello/label_name.rb +22 -25
- data/lib/trello/list.rb +31 -44
- data/lib/trello/member.rb +77 -31
- 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.rb +31 -0
- 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/token.rb +15 -12
- data/lib/trello/webhook.rb +18 -71
- data/spec/action_spec.rb +2 -3
- data/spec/basic_data_spec.rb +58 -0
- data/spec/board_spec.rb +53 -100
- data/spec/card_spec.rb +177 -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_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/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 +192 -0
- data/spec/custom_field_option_spec.rb +49 -0
- data/spec/custom_field_spec.rb +273 -0
- 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/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 +118 -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 +542 -29
data/lib/trello/webhook.rb
CHANGED
@@ -5,86 +5,33 @@ module Trello
|
|
5
5
|
# @return [String]
|
6
6
|
# @!attribute [r] description
|
7
7
|
# @return [String]
|
8
|
-
# @!attribute [r]
|
8
|
+
# @!attribute [r] model_id
|
9
9
|
# @return [String] A 24-character hex string
|
10
10
|
# @!attribute [r] callback_url
|
11
11
|
# @return [String]
|
12
12
|
# @!attribute [r] active
|
13
13
|
# @return [Boolean]
|
14
|
+
# @!attribute [r] consecutive_failures
|
15
|
+
# @return [Integer]
|
16
|
+
# @!attribute [r] first_consecutive_fail_date
|
17
|
+
# @return [Datetime]
|
14
18
|
class Webhook < BasicData
|
15
|
-
register_attributes :id, :description, :id_model, :callback_url, :active,
|
16
|
-
readonly: [ :id ]
|
17
|
-
validates_presence_of :id, :id_model, :callback_url
|
18
|
-
validates_length_of :description, in: 1..16384
|
19
19
|
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# @param [Hash] options
|
32
|
-
#
|
33
|
-
# @option options [String] :description (optional) A string with a length from 0 to 16384
|
34
|
-
# @option options [String] :callback_url (required) A valid URL that is
|
35
|
-
# reachable with a HEAD request
|
36
|
-
# @option options [String] :id_model (required) id of the model that should be hooked
|
37
|
-
#
|
38
|
-
# @raise [Trello::Error] if the Webhook could not be created.
|
39
|
-
#
|
40
|
-
# @return [Trello::Webhook]
|
41
|
-
def create(options)
|
42
|
-
client.create(:webhook,
|
43
|
-
'description' => options[:description],
|
44
|
-
'idModel' => options[:id_model],
|
45
|
-
'callbackURL' => options[:callback_url])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# @return [Trello::Webhook] self
|
50
|
-
def update_fields(fields)
|
51
|
-
attributes[:id] = fields['id'] || attributes[:id]
|
52
|
-
attributes[:description] = fields['description'] || fields[:description] || attributes[:description]
|
53
|
-
attributes[:id_model] = fields['idModel'] || fields[:id_model] || attributes[:id_model]
|
54
|
-
attributes[:callback_url] = fields['callbackURL'] || fields[:callback_url] || attributes[:callback_url]
|
55
|
-
attributes[:active] = fields['active'] if fields.has_key?('active')
|
56
|
-
self
|
20
|
+
schema do
|
21
|
+
# Readonly
|
22
|
+
attribute :id, readonly: true, primary_key: true
|
23
|
+
attribute :consecutive_failures, readonly: true, remote_key: 'consecutiveFailures'
|
24
|
+
attribute :first_consecutive_fail_date, readonly: true, remote_key: 'firstConsecutiveFailDate', serializer: 'Time'
|
25
|
+
|
26
|
+
# Writable
|
27
|
+
attribute :description
|
28
|
+
attribute :model_id, remote_key: 'idModel'
|
29
|
+
attribute :callback_url, remote_key: 'callbackURL'
|
30
|
+
attribute :active
|
57
31
|
end
|
58
32
|
|
59
|
-
|
60
|
-
|
61
|
-
# @raise [Trello::Error] if the Webhook could not be saved.
|
62
|
-
#
|
63
|
-
# @return [String] the JSON representation of the saved webhook.
|
64
|
-
def save
|
65
|
-
# If we have an id, just update our fields.
|
66
|
-
return update! if id
|
67
|
-
|
68
|
-
from_response client.post("/webhooks", {
|
69
|
-
description: description,
|
70
|
-
idModel: id_model,
|
71
|
-
callbackURL: callback_url
|
72
|
-
})
|
73
|
-
end
|
74
|
-
|
75
|
-
# Update the webhook.
|
76
|
-
#
|
77
|
-
# @raise [Trello::Error] if the Webhook could not be saved.
|
78
|
-
#
|
79
|
-
# @return [String] the JSON representation of the updated webhook.
|
80
|
-
def update!
|
81
|
-
client.put("/webhooks/#{id}", {
|
82
|
-
description: description,
|
83
|
-
idModel: id_model,
|
84
|
-
callbackURL: callback_url,
|
85
|
-
active: active
|
86
|
-
})
|
87
|
-
end
|
33
|
+
validates_presence_of :id, :model_id, :callback_url
|
34
|
+
validates_length_of :description, in: 1..16384
|
88
35
|
|
89
36
|
# Delete this webhook
|
90
37
|
#
|
data/spec/action_spec.rb
CHANGED
@@ -116,7 +116,7 @@ module Trello
|
|
116
116
|
before do
|
117
117
|
allow(client)
|
118
118
|
.to receive(:get)
|
119
|
-
.with('/
|
119
|
+
.with('/actions/4ee2482134a81a757a08af47/memberCreator')
|
120
120
|
.and_return user_payload
|
121
121
|
end
|
122
122
|
|
@@ -131,8 +131,7 @@ module Trello
|
|
131
131
|
'id' => 'id',
|
132
132
|
'type' => 'type',
|
133
133
|
'data' => 'data',
|
134
|
-
'idMemberCreator' => '
|
135
|
-
'member' => 'member_participant'
|
134
|
+
'idMemberCreator' => 'creator_id'
|
136
135
|
}
|
137
136
|
|
138
137
|
action = Action.new(expected)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
describe BasicData do
|
5
|
+
describe "equality" do
|
6
|
+
specify "two objects of the same type are equal if their id values are equal" do
|
7
|
+
data_object = Card.new('id' => 'abc123')
|
8
|
+
other_data_object = Card.new('id' => 'abc123')
|
9
|
+
|
10
|
+
expect(data_object).to eq(other_data_object)
|
11
|
+
end
|
12
|
+
|
13
|
+
specify "two object of the samy type are not equal if their id values are different" do
|
14
|
+
data_object = Card.new('id' => 'abc123')
|
15
|
+
other_data_object = Card.new('id' => 'def456')
|
16
|
+
|
17
|
+
expect(data_object).not_to eq(other_data_object)
|
18
|
+
end
|
19
|
+
|
20
|
+
specify "two object of different types are not equal even if their id values are equal" do
|
21
|
+
card = Card.new('id' => 'abc123')
|
22
|
+
list = List.new('id' => 'abc123')
|
23
|
+
|
24
|
+
expect(card.id).to eq(list.id)
|
25
|
+
expect(card).to_not eq(list)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "hash equality" do
|
30
|
+
specify "two objects of the same type point to the same hash key" do
|
31
|
+
data_object = Card.new('id' => 'abc123')
|
32
|
+
other_data_object = Card.new('id' => 'abc123')
|
33
|
+
|
34
|
+
hash = {data_object => 'one'}
|
35
|
+
|
36
|
+
expect(hash[other_data_object]).to eq('one')
|
37
|
+
end
|
38
|
+
|
39
|
+
specify "two object of the same type with different ids do not point to the same hash key" do
|
40
|
+
data_object = Card.new('id' => 'abc123')
|
41
|
+
other_data_object = Card.new('id' => 'def456')
|
42
|
+
|
43
|
+
hash = {data_object => 'one'}
|
44
|
+
|
45
|
+
expect(hash[other_data_object]).to be_nil
|
46
|
+
end
|
47
|
+
|
48
|
+
specify "two object of different types with same ids do not point to the same hash key" do
|
49
|
+
card = Card.new('id' => 'abc123')
|
50
|
+
list = List.new('id' => 'abc123')
|
51
|
+
|
52
|
+
hash = {card => 'one'}
|
53
|
+
|
54
|
+
expect(hash[list]).to be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/spec/board_spec.rb
CHANGED
@@ -6,7 +6,7 @@ module Trello
|
|
6
6
|
|
7
7
|
let(:board) { client.find(:board, 'abcdef123456789123456789') }
|
8
8
|
let(:client) { Client.new }
|
9
|
-
let(:member) { Member.new(user_payload) }
|
9
|
+
let(:member) { Member.new(JSON.parse(user_payload)) }
|
10
10
|
|
11
11
|
before do
|
12
12
|
allow(client)
|
@@ -21,7 +21,7 @@ module Trello
|
|
21
21
|
it "delegates to client#find" do
|
22
22
|
expect(client)
|
23
23
|
.to receive(:find)
|
24
|
-
.with(
|
24
|
+
.with('board', 'abcdef123456789123456789', {})
|
25
25
|
|
26
26
|
Board.find('abcdef123456789123456789')
|
27
27
|
end
|
@@ -31,6 +31,35 @@ module Trello
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
describe '.create' do
|
35
|
+
before { allow(Board).to receive(:client).and_return(client) }
|
36
|
+
|
37
|
+
it 'will call create on client with correct parameters' do
|
38
|
+
params = {
|
39
|
+
name: 'Board Name',
|
40
|
+
use_default_labels: true,
|
41
|
+
use_default_lists: true,
|
42
|
+
description: 'description...',
|
43
|
+
organization_id: 11111,
|
44
|
+
source_board_id: 22222,
|
45
|
+
keep_cards_from_source: true,
|
46
|
+
power_ups: 'all',
|
47
|
+
visibility_level: 'org',
|
48
|
+
voting_permission_level: 'org',
|
49
|
+
comment_permission_level: 'org',
|
50
|
+
invitation_permission_level: 'admins',
|
51
|
+
enable_self_join: true,
|
52
|
+
enable_card_covers: true,
|
53
|
+
background_color: 'orange',
|
54
|
+
card_aging_type: 'pirate'
|
55
|
+
}
|
56
|
+
|
57
|
+
expect(client).to receive(:create).with('board', params)
|
58
|
+
|
59
|
+
Board.create(params)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
34
63
|
context "self.all" do
|
35
64
|
let(:client) { Trello.client }
|
36
65
|
|
@@ -133,12 +162,10 @@ module Trello
|
|
133
162
|
expect(labels[2].id).to eq('cbcdef123456789123456789')
|
134
163
|
expect(labels[2].board_id).to eq('abcdef123456789123456789')
|
135
164
|
expect(labels[2].name).to eq('deploy')
|
136
|
-
expect(labels[2].uses).to eq(2)
|
137
165
|
expect(labels[3].color).to eq('blue')
|
138
166
|
expect(labels[3].id).to eq('dbcdef123456789123456789')
|
139
167
|
expect(labels[3].board_id).to eq('abcdef123456789123456789')
|
140
168
|
expect(labels[3].name).to eq('on hold')
|
141
|
-
expect(labels[3].uses).to eq(6)
|
142
169
|
end
|
143
170
|
|
144
171
|
it "passes the label limit" do
|
@@ -170,7 +197,7 @@ module Trello
|
|
170
197
|
it "adds a member to the board as a normal user (default)" do
|
171
198
|
expect(client)
|
172
199
|
.to receive(:put)
|
173
|
-
.with("/boards/abcdef123456789123456789/members
|
200
|
+
.with("/boards/abcdef123456789123456789/members/#{member.id}", type: :normal)
|
174
201
|
|
175
202
|
board.add_member(member)
|
176
203
|
end
|
@@ -178,7 +205,7 @@ module Trello
|
|
178
205
|
it "adds a member to the board as an admin" do
|
179
206
|
expect(client)
|
180
207
|
.to receive(:put)
|
181
|
-
.with("/boards/abcdef123456789123456789/members
|
208
|
+
.with("/boards/abcdef123456789123456789/members/#{member.id}", type: :admin)
|
182
209
|
|
183
210
|
board.add_member(member, :admin)
|
184
211
|
end
|
@@ -193,7 +220,7 @@ module Trello
|
|
193
220
|
it "removes a member from the board" do
|
194
221
|
expect(client)
|
195
222
|
.to receive(:delete)
|
196
|
-
.with("/boards/abcdef123456789123456789/members
|
223
|
+
.with("/boards/abcdef123456789123456789/members/#{member.id}")
|
197
224
|
|
198
225
|
board.remove_member(member)
|
199
226
|
end
|
@@ -251,62 +278,28 @@ module Trello
|
|
251
278
|
end
|
252
279
|
end
|
253
280
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
describe "#update_fields" do
|
263
|
-
it "does not set any fields when the fields argument is empty" do
|
264
|
-
expected = {
|
265
|
-
'id' => "id",
|
266
|
-
'name' => "name",
|
267
|
-
'desc' => "desc",
|
268
|
-
'closed' => false,
|
269
|
-
'starred' => false,
|
270
|
-
'url' => "url",
|
271
|
-
'idOrganization' => "org_id"
|
272
|
-
}
|
273
|
-
|
274
|
-
board = Board.new(expected)
|
275
|
-
board.client = client
|
276
|
-
|
277
|
-
board.update_fields({})
|
278
|
-
|
279
|
-
expected.each_pair do |key, value|
|
280
|
-
if board.respond_to?(key)
|
281
|
-
expect(board.send(key)).to eq value
|
282
|
-
end
|
283
|
-
end
|
281
|
+
context "custom fields" do
|
282
|
+
before do
|
283
|
+
allow(client)
|
284
|
+
.to receive(:get)
|
285
|
+
.with("/boards/abcdef123456789123456789/customFields", {})
|
286
|
+
.and_return JSON.generate([custom_fields_details.first])
|
287
|
+
end
|
284
288
|
|
285
|
-
|
286
|
-
expect(board.
|
289
|
+
it "has custom fields" do
|
290
|
+
expect(board.custom_fields.count).to be > 0
|
287
291
|
end
|
292
|
+
end
|
288
293
|
|
289
|
-
|
290
|
-
|
291
|
-
board
|
292
|
-
expect(board.id).to eq board_details['id']
|
293
|
-
expect(board.name).to eq board_details['name']
|
294
|
-
expect(board.description).to eq board_details['desc']
|
295
|
-
expect(board.closed).to eq board_details['closed']
|
296
|
-
expect(board.starred).to eq board_details['starred']
|
297
|
-
expect(board.organization_id).to eq board_details['idOrganization']
|
298
|
-
expect(board.url).to eq board_details['url']
|
299
|
-
expect(board.last_activity_date).to eq board_details['dateLastActivity']
|
294
|
+
describe '#closed?' do
|
295
|
+
it "returns the closed attribute" do
|
296
|
+
expect(board.closed?).to be_falsy
|
300
297
|
end
|
298
|
+
end
|
301
299
|
|
302
|
-
|
303
|
-
|
304
|
-
board
|
305
|
-
expect(board.name).to eq board_details[:name]
|
306
|
-
expect(board.description).to eq board_details[:desc]
|
307
|
-
expect(board.closed).to eq board_details[:closed]
|
308
|
-
expect(board.starred).to eq board_details[:starred]
|
309
|
-
expect(board.organization_id).to eq board_details[:organization_id]
|
300
|
+
describe '#starred?' do
|
301
|
+
it "returns the starred attribute" do
|
302
|
+
expect(board.starred?).to be_falsy
|
310
303
|
end
|
311
304
|
end
|
312
305
|
|
@@ -329,17 +322,6 @@ module Trello
|
|
329
322
|
}.to raise_error(Trello::ConfigurationError)
|
330
323
|
end
|
331
324
|
|
332
|
-
it "puts all fields except id" do
|
333
|
-
expected_fields = %w{ name description closed starred idOrganization}.map { |s| s.to_sym }
|
334
|
-
|
335
|
-
expect(client).to receive(:put) do |anything, body|
|
336
|
-
expect(body.keys).to match expected_fields
|
337
|
-
any_board_json
|
338
|
-
end
|
339
|
-
|
340
|
-
Board.new('id' => "xxx").save
|
341
|
-
end
|
342
|
-
|
343
325
|
it "mutates the current instance" do
|
344
326
|
allow(client)
|
345
327
|
.to receive(:put)
|
@@ -353,7 +335,7 @@ module Trello
|
|
353
335
|
expected_resource_id = "xxx_board_id_xxx"
|
354
336
|
|
355
337
|
expect(client).to receive(:put) do |path, anything|
|
356
|
-
expect(path).to match(/#{expected_resource_id}
|
338
|
+
expect(path).to match(/#{expected_resource_id}\z/)
|
357
339
|
any_board_json
|
358
340
|
end
|
359
341
|
|
@@ -363,35 +345,6 @@ module Trello
|
|
363
345
|
it "saves OR updates depending on whether or not it has an id set"
|
364
346
|
end
|
365
347
|
|
366
|
-
describe '#update!' do
|
367
|
-
let(:client) { Trello.client }
|
368
|
-
|
369
|
-
let(:any_board_json) do
|
370
|
-
JSON.generate(boards_details.first)
|
371
|
-
end
|
372
|
-
|
373
|
-
it "puts basic attributes" do
|
374
|
-
board = Board.new 'id' => "board_id"
|
375
|
-
|
376
|
-
board.name = "new name"
|
377
|
-
board.description = "new description"
|
378
|
-
board.closed = true
|
379
|
-
board.starred = true
|
380
|
-
|
381
|
-
expect(client)
|
382
|
-
.to receive(:put)
|
383
|
-
.with("/boards/#{board.id}/", {
|
384
|
-
name: "new name",
|
385
|
-
description: "new description",
|
386
|
-
closed: true,
|
387
|
-
starred: true,
|
388
|
-
idOrganization: nil })
|
389
|
-
.and_return any_board_json
|
390
|
-
|
391
|
-
board.update!
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
348
|
describe "Repository" do
|
396
349
|
include Helpers
|
397
350
|
|
@@ -408,7 +361,7 @@ module Trello
|
|
408
361
|
|
409
362
|
it "creates a new board with whatever attributes are supplied " do
|
410
363
|
expected_attributes = { name: "Any new board name", description: "Any new board desription" }
|
411
|
-
sent_attributes = { name
|
364
|
+
sent_attributes = { 'name' => expected_attributes[:name], 'desc' => expected_attributes[:description] }
|
412
365
|
|
413
366
|
expect(client)
|
414
367
|
.to receive(:post)
|
data/spec/card_spec.rb
CHANGED
@@ -25,7 +25,7 @@ module Trello
|
|
25
25
|
it "delegates to Trello.client#find" do
|
26
26
|
expect(client)
|
27
27
|
.to receive(:find)
|
28
|
-
.with(
|
28
|
+
.with('card', 'abcdef123456789123456789', {})
|
29
29
|
|
30
30
|
Card.find('abcdef123456789123456789')
|
31
31
|
end
|
@@ -62,7 +62,8 @@ module Trello
|
|
62
62
|
expect(card.url).to eq(card_details['url'])
|
63
63
|
expect(card.short_url).to eq(card_details['shortUrl'])
|
64
64
|
expect(card.pos).to eq(card_details['pos'])
|
65
|
-
expect(card.last_activity_date).to
|
65
|
+
expect(card.last_activity_date).to be_a(Time)
|
66
|
+
expect(card.last_activity_date).to eq(Time.iso8601(card_details['dateLastActivity']))
|
66
67
|
end
|
67
68
|
|
68
69
|
it 'properly initializes all fields from options-like formatted hash' do
|
@@ -73,7 +74,7 @@ module Trello
|
|
73
74
|
expect(card.desc).to eq(card_details[:desc])
|
74
75
|
expect(card.member_ids).to eq(card_details[:member_ids])
|
75
76
|
expect(card.card_labels).to eq(card_details[:card_labels])
|
76
|
-
expect(card.due).to eq(card_details[:due])
|
77
|
+
expect(card.due).to eq(card_details[:due].to_time)
|
77
78
|
expect(card.pos).to eq(card_details[:pos])
|
78
79
|
expect(card.source_card_id).to eq(card_details[:source_card_id])
|
79
80
|
expect(card.source_card_properties).to eq(card_details[:source_card_properties])
|
@@ -96,17 +97,18 @@ module Trello
|
|
96
97
|
card_labels: "abcdef123456789123456789"
|
97
98
|
}
|
98
99
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
expected_payload = {
|
101
|
+
'name' => "Test Card",
|
102
|
+
'idList' => "abcdef123456789123456789",
|
103
|
+
'idLabels' => "abcdef123456789123456789",
|
104
|
+
}
|
103
105
|
|
104
106
|
expect(client)
|
105
107
|
.to receive(:post)
|
106
108
|
.with("/cards", expected_payload)
|
107
|
-
.and_return
|
109
|
+
.and_return JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
|
108
110
|
|
109
|
-
card = Card.create(
|
111
|
+
card = Card.create(payload.merge(list_id: lists_details.first['id']))
|
110
112
|
|
111
113
|
expect(card).to be_a Card
|
112
114
|
end
|
@@ -118,15 +120,17 @@ module Trello
|
|
118
120
|
|
119
121
|
result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
|
120
122
|
|
121
|
-
expected_payload = {
|
122
|
-
|
123
|
+
expected_payload = {
|
124
|
+
'idList' => "abcdef123456789123456789",
|
125
|
+
'idCardSource' => cards_details.first['id'],
|
126
|
+
}
|
123
127
|
|
124
128
|
expect(client)
|
125
129
|
.to receive(:post)
|
126
130
|
.with("/cards", expected_payload)
|
127
131
|
.and_return result
|
128
132
|
|
129
|
-
card = Card.create(
|
133
|
+
card = Card.create(payload.merge(list_id: lists_details.first['id']))
|
130
134
|
|
131
135
|
expect(card).to be_a Card
|
132
136
|
end
|
@@ -139,15 +143,18 @@ module Trello
|
|
139
143
|
|
140
144
|
result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
|
141
145
|
|
142
|
-
expected_payload = {
|
143
|
-
|
146
|
+
expected_payload = {
|
147
|
+
'idList' => "abcdef123456789123456789",
|
148
|
+
'idCardSource' => cards_details.first['id'],
|
149
|
+
'keepFromSource' => ['due', 'checklists']
|
150
|
+
}
|
144
151
|
|
145
152
|
expect(client)
|
146
153
|
.to receive(:post)
|
147
154
|
.with("/cards", expected_payload)
|
148
155
|
.and_return result
|
149
156
|
|
150
|
-
card = Card.create(
|
157
|
+
card = Card.create(payload.merge(list_id: lists_details.first['id']))
|
151
158
|
|
152
159
|
expect(card).to be_a Card
|
153
160
|
end
|
@@ -160,15 +167,17 @@ module Trello
|
|
160
167
|
|
161
168
|
result = JSON.generate(cards_details.first.merge(payload.merge(idList: lists_details.first['id'])))
|
162
169
|
|
163
|
-
expected_payload = {
|
164
|
-
|
170
|
+
expected_payload = {
|
171
|
+
'idList' => "abcdef123456789123456789",
|
172
|
+
'idCardSource' => cards_details.first['id'],
|
173
|
+
}
|
165
174
|
|
166
175
|
expect(client)
|
167
176
|
.to receive(:post)
|
168
177
|
.with("/cards", expected_payload)
|
169
178
|
.and_return result
|
170
179
|
|
171
|
-
card = Card.create(
|
180
|
+
card = Card.create(payload.merge(list_id: lists_details.first['id']))
|
172
181
|
|
173
182
|
expect(card).to be_a Card
|
174
183
|
end
|
@@ -180,13 +189,14 @@ module Trello
|
|
180
189
|
expected_new_name = "xxx"
|
181
190
|
|
182
191
|
payload = {
|
183
|
-
name
|
192
|
+
'name' => expected_new_name,
|
184
193
|
}
|
185
194
|
|
186
195
|
expect(client)
|
187
196
|
.to receive(:put)
|
188
197
|
.once
|
189
198
|
.with("/cards/abcdef123456789123456789", payload)
|
199
|
+
.and_return(payload.to_json)
|
190
200
|
|
191
201
|
card.name = expected_new_name
|
192
202
|
card.save
|
@@ -196,10 +206,13 @@ module Trello
|
|
196
206
|
expected_new_desc = "xxx"
|
197
207
|
|
198
208
|
payload = {
|
199
|
-
desc
|
209
|
+
'desc' => expected_new_desc,
|
200
210
|
}
|
201
211
|
|
202
|
-
expect(client)
|
212
|
+
expect(client)
|
213
|
+
.to receive(:put).once
|
214
|
+
.with("/cards/abcdef123456789123456789", payload)
|
215
|
+
.and_return(payload.to_json)
|
203
216
|
|
204
217
|
card.desc = expected_new_desc
|
205
218
|
card.save
|
@@ -257,7 +270,6 @@ module Trello
|
|
257
270
|
expect(card.pos).to_not be_nil
|
258
271
|
end
|
259
272
|
|
260
|
-
|
261
273
|
it 'gets its creation time' do
|
262
274
|
expect(card.created_at).to be_kind_of Time
|
263
275
|
end
|
@@ -308,7 +320,7 @@ module Trello
|
|
308
320
|
before do
|
309
321
|
allow(client)
|
310
322
|
.to receive(:get)
|
311
|
-
.with("/attachments/abcdef123456789123456789", {})
|
323
|
+
.with("/cards/#{card.id}/attachments/abcdef123456789123456789", {})
|
312
324
|
.and_return JSON.generate(attachments_details.first)
|
313
325
|
end
|
314
326
|
|
@@ -338,6 +350,50 @@ module Trello
|
|
338
350
|
end
|
339
351
|
end
|
340
352
|
|
353
|
+
context "custom field items" do
|
354
|
+
before do
|
355
|
+
allow(client)
|
356
|
+
.to receive(:get)
|
357
|
+
.with("/cards/abcdef123456789123456789/customFieldItems", {})
|
358
|
+
.and_return JSON.generate([custom_field_item_details])
|
359
|
+
end
|
360
|
+
|
361
|
+
it "has a list of custom field items" do
|
362
|
+
expect(card.custom_field_items.count).to be > 0
|
363
|
+
end
|
364
|
+
|
365
|
+
it "clears the custom field value on a card" do
|
366
|
+
params = { value: {} }
|
367
|
+
|
368
|
+
expect(client)
|
369
|
+
.to receive(:put)
|
370
|
+
.with("/cards/abcdef123456789123456789/customField/abcdef123456789123456789/item", params)
|
371
|
+
|
372
|
+
card.custom_field_items.last.remove
|
373
|
+
end
|
374
|
+
|
375
|
+
it "updates a custom field value" do
|
376
|
+
payload = { 'value' => { 'text' => 'Test Text' } }
|
377
|
+
|
378
|
+
expect(client)
|
379
|
+
.to receive(:put)
|
380
|
+
.with("/cards/abcdef123456789123456789/customField/abcdef123456789123456789/item", payload)
|
381
|
+
.and_return(JSON.generate({
|
382
|
+
"id" => "5e68e885e4baf545ec8ce7ba",
|
383
|
+
"value" => {
|
384
|
+
"text" => "Test Text"
|
385
|
+
},
|
386
|
+
"idCustomField" => "abcdef123456789123456789",
|
387
|
+
"idModel" => "abcdef123456789123456789",
|
388
|
+
"modelType" => "card"
|
389
|
+
}))
|
390
|
+
|
391
|
+
text_custom_field = card.custom_field_items.last
|
392
|
+
text_custom_field.value = { text: 'Test Text' }
|
393
|
+
text_custom_field.save
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
341
397
|
context "list" do
|
342
398
|
before do
|
343
399
|
allow(client)
|
@@ -345,6 +401,7 @@ module Trello
|
|
345
401
|
.with("/lists/abcdef123456789123456789", {})
|
346
402
|
.and_return JSON.generate(lists_details.first)
|
347
403
|
end
|
404
|
+
|
348
405
|
it 'has a list' do
|
349
406
|
expect(card.list).to_not be_nil
|
350
407
|
end
|
@@ -438,7 +495,7 @@ module Trello
|
|
438
495
|
card.move_to_list_on_any_board(other_list.id)
|
439
496
|
end
|
440
497
|
|
441
|
-
it 'should not be moved if new board is identical with old board'
|
498
|
+
it 'should not be moved if new board is identical with old board' do
|
442
499
|
other_board = double(id: 'abcdef123456789123456789')
|
443
500
|
expect(client).to_not receive(:put)
|
444
501
|
card.move_to_board(other_board)
|
@@ -454,7 +511,7 @@ module Trello
|
|
454
511
|
|
455
512
|
allow(client)
|
456
513
|
.to receive(:get)
|
457
|
-
.with("/
|
514
|
+
.with("/cards/abcdef123456789123456789/members")
|
458
515
|
.and_return user_payload
|
459
516
|
end
|
460
517
|
|
@@ -471,7 +528,7 @@ module Trello
|
|
471
528
|
|
472
529
|
expect(client)
|
473
530
|
.to receive(:post)
|
474
|
-
.with("/cards/abcdef123456789123456789/
|
531
|
+
.with("/cards/abcdef123456789123456789/idMembers", payload)
|
475
532
|
|
476
533
|
card.add_member(new_member)
|
477
534
|
end
|
@@ -481,7 +538,7 @@ module Trello
|
|
481
538
|
|
482
539
|
expect(client)
|
483
540
|
.to receive(:delete)
|
484
|
-
.with("/cards/abcdef123456789123456789/
|
541
|
+
.with("/cards/abcdef123456789123456789/idMembers/#{existing_member.id}")
|
485
542
|
|
486
543
|
card.remove_member(existing_member)
|
487
544
|
end
|
@@ -556,7 +613,6 @@ module Trello
|
|
556
613
|
end
|
557
614
|
end
|
558
615
|
|
559
|
-
|
560
616
|
context "comments" do
|
561
617
|
it "posts a comment" do
|
562
618
|
expect(client)
|
@@ -588,12 +644,10 @@ module Trello
|
|
588
644
|
expect(labels[0].id).to eq('abcdef123456789123456789')
|
589
645
|
expect(labels[0].board_id).to eq('abcdef123456789123456789')
|
590
646
|
expect(labels[0].name).to eq('iOS')
|
591
|
-
expect(labels[0].uses).to eq(3)
|
592
647
|
expect(labels[1].color).to eq('purple')
|
593
648
|
expect(labels[1].id).to eq('bbcdef123456789123456789')
|
594
649
|
expect(labels[1].board_id).to eq('abcdef123456789123456789')
|
595
650
|
expect(labels[1].name).to eq('Issue or bug')
|
596
|
-
expect(labels[1].uses).to eq(1)
|
597
651
|
end
|
598
652
|
|
599
653
|
it "includes label ids list" do
|
@@ -653,18 +707,18 @@ module Trello
|
|
653
707
|
|
654
708
|
first_plugin = card.plugin_data.first
|
655
709
|
expect(first_plugin.id).to eq plugin_data_details[0]["id"]
|
656
|
-
expect(first_plugin.
|
710
|
+
expect(first_plugin.plugin_id).to eq plugin_data_details[0]["idPlugin"]
|
657
711
|
expect(first_plugin.scope).to eq plugin_data_details[0]["scope"]
|
658
|
-
expect(first_plugin.
|
659
|
-
expect(first_plugin.value).to eq
|
712
|
+
expect(first_plugin.model_id).to eq plugin_data_details[0]["idModel"]
|
713
|
+
expect(first_plugin.value).to eq plugin_data_details[0]["value"]
|
660
714
|
expect(first_plugin.access).to eq plugin_data_details[0]["access"]
|
661
715
|
|
662
716
|
second_plugin = card.plugin_data[1]
|
663
717
|
expect(second_plugin.id).to eq plugin_data_details[1]["id"]
|
664
|
-
expect(second_plugin.
|
718
|
+
expect(second_plugin.plugin_id).to eq plugin_data_details[1]["idPlugin"]
|
665
719
|
expect(second_plugin.scope).to eq plugin_data_details[1]["scope"]
|
666
|
-
expect(second_plugin.
|
667
|
-
expect(second_plugin.value).to eq
|
720
|
+
expect(second_plugin.model_id).to eq plugin_data_details[1]["idModel"]
|
721
|
+
expect(second_plugin.value).to eq plugin_data_details[1]["value"]
|
668
722
|
expect(second_plugin.access).to eq plugin_data_details[1]["access"]
|
669
723
|
|
670
724
|
end
|
@@ -748,12 +802,13 @@ module Trello
|
|
748
802
|
|
749
803
|
describe "#close!" do
|
750
804
|
it "updates the close attribute to true and saves the list" do
|
751
|
-
payload = { closed
|
805
|
+
payload = { 'closed' => true }
|
752
806
|
|
753
807
|
expect(client)
|
754
808
|
.to receive(:put)
|
755
809
|
.once
|
756
810
|
.with("/cards/abcdef123456789123456789", payload)
|
811
|
+
.and_return(payload.to_json)
|
757
812
|
|
758
813
|
card.close!
|
759
814
|
end
|
@@ -764,57 +819,113 @@ module Trello
|
|
764
819
|
due_date = Time.now
|
765
820
|
|
766
821
|
payload = {
|
767
|
-
due
|
822
|
+
'due' => due_date.strftime('%FT%T.%LZ'),
|
768
823
|
}
|
769
824
|
|
770
825
|
expect(client)
|
771
826
|
.to receive(:put)
|
772
827
|
.once
|
773
828
|
.with("/cards/abcdef123456789123456789", payload)
|
829
|
+
.and_return(payload.to_json)
|
774
830
|
|
775
831
|
card.due = due_date
|
776
832
|
card.save
|
777
833
|
|
778
834
|
expect(card.due).to_not be_nil
|
835
|
+
end
|
836
|
+
end
|
779
837
|
|
780
|
-
|
781
|
-
|
782
|
-
}
|
838
|
+
describe '#update_fields' do
|
839
|
+
context 'when the fields argument is empty' do
|
840
|
+
let(:fields) { {} }
|
783
841
|
|
784
|
-
|
785
|
-
.
|
786
|
-
.once
|
787
|
-
.with("/cards/abcdef123456789123456789", payload)
|
842
|
+
it 'card does not set any fields' do
|
843
|
+
expected = cards_details.first
|
788
844
|
|
789
|
-
|
790
|
-
|
845
|
+
card = Card.new(expected)
|
846
|
+
card.client = client
|
847
|
+
|
848
|
+
card.update_fields(fields)
|
791
849
|
|
792
|
-
|
850
|
+
expected.each do |key, value|
|
851
|
+
if card.respond_to?(key) && key != 'labels'
|
852
|
+
expect(card.send(key)).to eq value
|
853
|
+
end
|
854
|
+
|
855
|
+
expect(card.labels).to eq expected['labels'].map { |lbl| Trello::Label.new(lbl) }
|
856
|
+
expect(card.short_id).to eq expected['idShort']
|
857
|
+
expect(card.short_url).to eq expected['shortUrl']
|
858
|
+
expect(card.board_id).to eq expected['idBoard']
|
859
|
+
expect(card.member_ids).to eq expected['idMembers']
|
860
|
+
expect(card.cover_image_id).to eq expected['idAttachmentCover']
|
861
|
+
expect(card.list_id).to eq expected['idList']
|
862
|
+
expect(card.card_labels).to eq expected['idLabels']
|
863
|
+
end
|
864
|
+
end
|
793
865
|
end
|
794
|
-
end
|
795
866
|
|
796
|
-
|
797
|
-
|
798
|
-
|
867
|
+
context 'when the fields argument has at least one field' do
|
868
|
+
let(:expected) { cards_details.first }
|
869
|
+
let(:card) {
|
870
|
+
card = Card.new(expected)
|
871
|
+
card.client = client
|
872
|
+
card
|
873
|
+
}
|
799
874
|
|
800
|
-
|
801
|
-
|
875
|
+
context 'and the field does changed' do
|
876
|
+
let(:fields) { { desc: 'Awesome things have changed.' } }
|
802
877
|
|
803
|
-
|
878
|
+
it 'card does set the changed fields' do
|
879
|
+
card.update_fields(fields)
|
804
880
|
|
805
|
-
|
806
|
-
if card.respond_to?(key) && key != 'labels'
|
807
|
-
expect(card.send(key)).to eq value
|
881
|
+
expect(card.desc).to eq('Awesome things have changed.')
|
808
882
|
end
|
809
883
|
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
884
|
+
it 'card has been mark as changed' do
|
885
|
+
card.update_fields(fields)
|
886
|
+
|
887
|
+
expect(card.changed?).to be_truthy
|
888
|
+
end
|
889
|
+
end
|
890
|
+
|
891
|
+
context "and the field doesn't changed" do
|
892
|
+
let(:fields) { { desc: expected['desc'] } }
|
893
|
+
|
894
|
+
it "card attributes doesn't changed" do
|
895
|
+
card.update_fields(fields)
|
896
|
+
|
897
|
+
expect(card.desc).to eq(expected['desc'])
|
898
|
+
end
|
899
|
+
|
900
|
+
it "card hasn't been mark as changed" do
|
901
|
+
card.update_fields(fields)
|
902
|
+
|
903
|
+
expect(card.changed?).to be_falsy
|
904
|
+
end
|
905
|
+
end
|
906
|
+
|
907
|
+
context "and the field isn't a correct attributes of the card" do
|
908
|
+
let(:fields) { { abc: 'abc' } }
|
909
|
+
|
910
|
+
it "card attributes doesn't changed" do
|
911
|
+
card.update_fields(fields)
|
912
|
+
|
913
|
+
expect(card.labels).to eq expected['labels'].map { |lbl| Trello::Label.new(lbl) }
|
914
|
+
expect(card.short_id).to eq expected['idShort']
|
915
|
+
expect(card.short_url).to eq expected['shortUrl']
|
916
|
+
expect(card.board_id).to eq expected['idBoard']
|
917
|
+
expect(card.member_ids).to eq expected['idMembers']
|
918
|
+
expect(card.cover_image_id).to eq expected['idAttachmentCover']
|
919
|
+
expect(card.list_id).to eq expected['idList']
|
920
|
+
expect(card.card_labels).to eq expected['idLabels']
|
921
|
+
expect(card.desc).to eq expected['desc']
|
922
|
+
end
|
923
|
+
|
924
|
+
it "card hasn't been mark as changed" do
|
925
|
+
card.update_fields(fields)
|
926
|
+
|
927
|
+
expect(card.changed?).to be_falsy
|
928
|
+
end
|
818
929
|
end
|
819
930
|
end
|
820
931
|
end
|