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
@@ -0,0 +1,370 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Board#new' do
|
4
|
+
|
5
|
+
let(:board) { Trello::Board.new(data) }
|
6
|
+
|
7
|
+
describe 'parse #id (writable)' do
|
8
|
+
context 'with Trello API respone data' do
|
9
|
+
let(:data) { { 'id' => '5e93ba98614ac22d22f085c4' } }
|
10
|
+
|
11
|
+
it "parse from data['id']" do
|
12
|
+
expect(board.id).to eq('5e93ba98614ac22d22f085c4')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'with Ruby-like data' do
|
17
|
+
let(:data) { { id: '5e93ba98614ac22d22f085c4' } }
|
18
|
+
|
19
|
+
it 'parse from data[:id]' do
|
20
|
+
expect(board.id).to eq('5e93ba98614ac22d22f085c4')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'parse #name (writable)' do
|
26
|
+
context 'with Trello API respone data' do
|
27
|
+
let(:data) { { 'name' => 'Board Name' } }
|
28
|
+
|
29
|
+
it "parse from data['name']" do
|
30
|
+
expect(board.name).to eq('Board Name')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with Ruby-like data' do
|
35
|
+
let(:data) { { name: 'Board Name' } }
|
36
|
+
|
37
|
+
it 'parse from data[:name]' do
|
38
|
+
expect(board.name).to eq('Board Name')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'parse #description (writable)' do
|
44
|
+
context 'with Trello API respone data' do
|
45
|
+
let(:data) { { 'desc' => 'Board Name' } }
|
46
|
+
|
47
|
+
it "parse from data['desc']" do
|
48
|
+
expect(board.description).to eq('Board Name')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'with Ruby-like data' do
|
53
|
+
let(:data) { { description: 'Board Name' } }
|
54
|
+
|
55
|
+
it 'parse from data[:desc]' do
|
56
|
+
expect(board.description).to eq('Board Name')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'parse #description_data (readonly)' do
|
62
|
+
context 'with Trello API respone data' do
|
63
|
+
let(:data) { { 'descData' => 'description data...' } }
|
64
|
+
|
65
|
+
it "parse from data['descData']" do
|
66
|
+
expect(board.description_data).to eq('description data...')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with Ruby-like data' do
|
71
|
+
let(:data) { { description_data: 'description data...' } }
|
72
|
+
|
73
|
+
it "will parse from data[:description_data]" do
|
74
|
+
expect(board.description_data).to eq('description data...')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe 'parse #closed (writable)' do
|
80
|
+
context 'with Trello API respone data' do
|
81
|
+
let(:data) { { 'closed' => true } }
|
82
|
+
|
83
|
+
it "parse from data['closed']" do
|
84
|
+
expect(board.closed).to eq(true)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'with Ruby-like data' do
|
89
|
+
let(:data) { { closed: true } }
|
90
|
+
|
91
|
+
it 'parse from data[:description_data]' do
|
92
|
+
expect(board.closed).to eq(true)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'parse #organization_id (writable)' do
|
98
|
+
context 'with Trello API respone data' do
|
99
|
+
let(:data) { { 'idOrganization' => 'abc123' } }
|
100
|
+
|
101
|
+
it "parse from data['idOrganization']" do
|
102
|
+
expect(board.organization_id).to eq('abc123')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'with Ruby-like data' do
|
107
|
+
let(:data) { { organization_id: 'abc123' } }
|
108
|
+
|
109
|
+
it 'parse from data[:description_data]' do
|
110
|
+
expect(board.organization_id).to eq('abc123')
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'parse #enterprise_id (readonly)' do
|
116
|
+
context 'with Trello API respone data' do
|
117
|
+
let(:data) { { 'idEnterprise' => 'abc123' } }
|
118
|
+
|
119
|
+
it "parse from data['idEnterprise']" do
|
120
|
+
expect(board.enterprise_id).to eq('abc123')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'with Ruby-like data' do
|
125
|
+
let(:data) { { enterprise_id: 'abc123' } }
|
126
|
+
|
127
|
+
it "will parse from data[:enterprise_id]" do
|
128
|
+
expect(board.enterprise_id).to eq('abc123')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'parse #pinned (readonly)' do
|
134
|
+
context 'with Trello API respone data' do
|
135
|
+
let(:data) { { 'pinned' => false } }
|
136
|
+
|
137
|
+
it "parse from data['pinned']" do
|
138
|
+
expect(board.pinned).to eq(false)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context 'with Ruby-like data' do
|
143
|
+
let(:data) { { pinned: false } }
|
144
|
+
|
145
|
+
it "won't parse from data[:pinned]" do
|
146
|
+
expect(board.pinned).to eq(false)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe 'parse #url (readonly)' do
|
152
|
+
context 'with Trello API respone data' do
|
153
|
+
let(:data) { { 'url' => 'https://trello.com/b/y1TF9GTa/board-1' } }
|
154
|
+
|
155
|
+
it "parse from data['url']" do
|
156
|
+
expect(board.url).to eq('https://trello.com/b/y1TF9GTa/board-1')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'with Ruby-like data' do
|
161
|
+
let(:data) { { url: 'https://trello.com/b/y1TF9GTa/board-1' } }
|
162
|
+
|
163
|
+
it "won't parse from data[:url]" do
|
164
|
+
expect(board.url).to eq('https://trello.com/b/y1TF9GTa/board-1')
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe 'parse #short_url (readonly)' do
|
170
|
+
context 'with Trello API respone data' do
|
171
|
+
let(:data) { { 'shortUrl' => 'https://trello.com/b/y1TF9GTa' } }
|
172
|
+
|
173
|
+
it "parse from data['shortUrl']" do
|
174
|
+
expect(board.short_url).to eq('https://trello.com/b/y1TF9GTa')
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'with Ruby-like data' do
|
179
|
+
let(:data) { { short_url: 'https://trello.com/b/y1TF9GTa' } }
|
180
|
+
|
181
|
+
it "parse from data[:short_url]" do
|
182
|
+
expect(board.short_url).to eq('https://trello.com/b/y1TF9GTa')
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# it "parse #label_names from response['labelNames']" do
|
188
|
+
# end
|
189
|
+
|
190
|
+
describe 'parse #visibility_level (writable)' do
|
191
|
+
context 'with Trello API respone data' do
|
192
|
+
let(:data) { { 'prefs' => { 'permissionLevel' => 'org' } } }
|
193
|
+
|
194
|
+
it "parse from data['prefs']['permissionLevel']" do
|
195
|
+
expect(board.visibility_level).to eq('org')
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'with Ruby-like data' do
|
200
|
+
let(:data) { { visibility_level: 'org' } }
|
201
|
+
|
202
|
+
it 'parse from data[:visibility_level]' do
|
203
|
+
expect(board.visibility_level).to eq('org')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe 'parse #voting_permission_level (writable)' do
|
209
|
+
context 'with Trello API respone data' do
|
210
|
+
let(:data) { { 'prefs' => { 'voting' => 'org' } } }
|
211
|
+
|
212
|
+
it "parse from data['prefs']['voting']" do
|
213
|
+
expect(board.voting_permission_level).to eq('org')
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'with Ruby-like data' do
|
218
|
+
let(:data) { { voting_permission_level: 'org' } }
|
219
|
+
|
220
|
+
it 'parse from data[:voting_permission_level]' do
|
221
|
+
expect(board.voting_permission_level).to eq('org')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe 'parse #comment_permission_level (writable)' do
|
227
|
+
context 'with Trello API respone data' do
|
228
|
+
let(:data) { { 'prefs' => { 'comments' => 'org' } } }
|
229
|
+
|
230
|
+
it "parse from data['prefs']['comments']" do
|
231
|
+
expect(board.comment_permission_level).to eq('org')
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
context 'with Ruby-like data' do
|
236
|
+
let(:data) { { comment_permission_level: 'org' } }
|
237
|
+
|
238
|
+
it 'parse from data[:voting_permission_level]' do
|
239
|
+
expect(board.comment_permission_level).to eq('org')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
describe 'parse #invitation_permission_level (writable)' do
|
245
|
+
context 'with Trello API respone data' do
|
246
|
+
let(:data) { { 'prefs' => { 'invitations' => 'org' } } }
|
247
|
+
|
248
|
+
it "parse from data['prefs']['invitations']" do
|
249
|
+
expect(board.invitation_permission_level).to eq('org')
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'with Ruby-like data' do
|
254
|
+
let(:data) { { invitation_permission_level: 'org' } }
|
255
|
+
|
256
|
+
it 'parse from data[:invitation_permission_level]' do
|
257
|
+
expect(board.invitation_permission_level).to eq('org')
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe 'parse #enable_self_join (writable)' do
|
263
|
+
context 'with Trello API respone data' do
|
264
|
+
let(:data) { { 'prefs' => { 'selfJoin' => true } } }
|
265
|
+
|
266
|
+
it "parse from data['prefs']['selfJoin']" do
|
267
|
+
expect(board.enable_self_join).to eq(true)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'with Ruby-like data' do
|
272
|
+
let(:data) { { enable_self_join: true } }
|
273
|
+
|
274
|
+
it 'parse from data[:enable_self_join]' do
|
275
|
+
expect(board.enable_self_join).to eq(true)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe 'parse #enable_card_covers (writable)' do
|
281
|
+
context 'with Trello API respone data' do
|
282
|
+
let(:data) { { 'prefs' => { 'cardCovers' => true } } }
|
283
|
+
|
284
|
+
it "parse from data['prefs']['cardCovers']" do
|
285
|
+
expect(board.enable_card_covers).to eq(true)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context 'with Ruby-like data' do
|
290
|
+
let(:data) { { enable_card_covers: true } }
|
291
|
+
|
292
|
+
it 'parse from data[:enable_card_covers]' do
|
293
|
+
expect(board.enable_card_covers).to eq(true)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
describe 'parse #background_color (writable)' do
|
299
|
+
context 'with Trello API respone data' do
|
300
|
+
let(:data) { { 'prefs' => { 'background' => 'blue' } } }
|
301
|
+
|
302
|
+
it "parse from data['prefs']['background']" do
|
303
|
+
expect(board.background_color).to eq('blue')
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context 'with Ruby-like data' do
|
308
|
+
let(:data) { { background_color: 'blue' } }
|
309
|
+
|
310
|
+
it 'parse from data[:background_color]' do
|
311
|
+
expect(board.background_color).to eq('blue')
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
describe 'parse #background_image (writable)' do
|
317
|
+
context 'with Trello API respone data' do
|
318
|
+
let(:data) { { 'prefs' => { 'backgroundImage' => 'https://image_url' } } }
|
319
|
+
|
320
|
+
it "parse from data['prefs']['background']" do
|
321
|
+
expect(board.background_image).to eq('https://image_url')
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
context 'with Ruby-like data' do
|
326
|
+
let(:data) { { background_image: 'https://image_url' } }
|
327
|
+
|
328
|
+
it 'parse from data[:background_image]' do
|
329
|
+
expect(board.background_image).to eq('https://image_url')
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
describe 'parse #card_aging_type (writable)' do
|
335
|
+
context 'with Trello API respone data' do
|
336
|
+
let(:data) { { 'prefs' => { 'cardAging' => 'pirate' } } }
|
337
|
+
|
338
|
+
it "parse from data['prefs']['cardAging']" do
|
339
|
+
expect(board.card_aging_type).to eq('pirate')
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
context 'with Ruby-like data' do
|
344
|
+
let(:data) { { card_aging_type: 'pirate' } }
|
345
|
+
|
346
|
+
it 'parse from data[:card_aging_type]' do
|
347
|
+
expect(board.card_aging_type).to eq('pirate')
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
describe 'parse #prefs (readonly)' do
|
353
|
+
context 'with Trello API respone data' do
|
354
|
+
let(:data) { { 'prefs' => { 'permissionLevel' => 'org' } } }
|
355
|
+
|
356
|
+
it "parse from data['prefs']" do
|
357
|
+
expect(board.prefs).to eq({ 'permissionLevel' => 'org' })
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
context 'with Ruby-like data' do
|
362
|
+
let(:data) { { prefs: { 'permissionLevel' => 'org' } } }
|
363
|
+
|
364
|
+
it 'will parse from data[:prefs]' do
|
365
|
+
expect(board.prefs).to eq({ 'permissionLevel' => 'org' })
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Board' do
|
4
|
+
|
5
|
+
context 'when id exists' do
|
6
|
+
let(:board) { Trello::Board.new(id: 1) }
|
7
|
+
|
8
|
+
it 'call #update! on board' do
|
9
|
+
expect(board).to receive(:update!)
|
10
|
+
|
11
|
+
board.save
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'when id does not exist' do
|
16
|
+
let(:board) { Trello::Board.new(
|
17
|
+
name: 'IT 1',
|
18
|
+
description: 'description ...',
|
19
|
+
organization_id: 1111,
|
20
|
+
visibility_level: 'org',
|
21
|
+
voting_permission_level: 'org',
|
22
|
+
comment_permission_level: 'org',
|
23
|
+
invitation_permission_level: 'org',
|
24
|
+
enable_self_join: true,
|
25
|
+
enable_card_covers: true,
|
26
|
+
background_color: 'blue',
|
27
|
+
card_aging_type: 'pirate'
|
28
|
+
) }
|
29
|
+
|
30
|
+
it 'call #create on board with correct parameters' do
|
31
|
+
expect(board).to receive(:post).with('/boards', {
|
32
|
+
'name' => 'IT 1',
|
33
|
+
'desc' => 'description ...',
|
34
|
+
'idOrganization' => 1111,
|
35
|
+
'prefs_permissionLevel' => 'org',
|
36
|
+
'prefs_voting' => 'org',
|
37
|
+
'prefs_comments' => 'org',
|
38
|
+
'prefs_invitations' => 'org',
|
39
|
+
'prefs_selfJoin' => true,
|
40
|
+
'prefs_cardCovers' => true,
|
41
|
+
'prefs_background' => 'blue',
|
42
|
+
'prefs_cardAging' => 'pirate'
|
43
|
+
})
|
44
|
+
|
45
|
+
board.save
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Board#update_fields' do
|
4
|
+
|
5
|
+
let(:board_params) { {
|
6
|
+
'id' => '5e93ba403f1ab3603ba81a09',
|
7
|
+
'name' => 'IT 1',
|
8
|
+
'desc' => 'This is a test board called IT 1',
|
9
|
+
'descData' => { 'emoji': {} },
|
10
|
+
'closed' => false,
|
11
|
+
'idOrganization' => "5e93ba154634282b6df23bcc",
|
12
|
+
'idEnterprise' => nil,
|
13
|
+
'pinned' => false,
|
14
|
+
'url' => 'https://trello.com/b/0zx7ive1/it-1',
|
15
|
+
'shortUrl' => 'https://trello.com/b/0zx7ive1',
|
16
|
+
'prefs' => {
|
17
|
+
'permissionLevel' => 'org',
|
18
|
+
'voting' => 'disabled',
|
19
|
+
'comments' => 'members',
|
20
|
+
'invitations' => 'members',
|
21
|
+
'selfJoin' => true,
|
22
|
+
'cardCovers' => true,
|
23
|
+
'cardAging' => 'regular',
|
24
|
+
'background' => 'blue' ,
|
25
|
+
'backgroundImage' => nil
|
26
|
+
}
|
27
|
+
} }
|
28
|
+
|
29
|
+
let(:board) { Trello::Board.new(board_params) }
|
30
|
+
|
31
|
+
context 'when the fields argument is empty' do
|
32
|
+
let(:fields) { {} }
|
33
|
+
|
34
|
+
it 'board does not set any fields' do
|
35
|
+
board.update_fields(fields)
|
36
|
+
|
37
|
+
expect(board.changed?).to be_falsy
|
38
|
+
expect(board.id).to eq(board_params['id'])
|
39
|
+
expect(board.name).to eq(board_params['name'])
|
40
|
+
expect(board.description).to eq(board_params['desc'])
|
41
|
+
expect(board.description_data).to match_hash_with_indifferent_access(board_params['descData'])
|
42
|
+
expect(board.closed).to eq(board_params['closed'])
|
43
|
+
expect(board.organization_id).to eq(board_params['idOrganization'])
|
44
|
+
expect(board.enterprise_id).to eq(board_params['idEnterprise'])
|
45
|
+
expect(board.pinned).to eq(board_params['pinned'])
|
46
|
+
expect(board.url).to eq(board_params['url'])
|
47
|
+
expect(board.short_url).to eq(board_params['shortUrl'])
|
48
|
+
expect(board.visibility_level).to eq(board_params['prefs']['permissionLevel'])
|
49
|
+
expect(board.voting_permission_level).to eq(board_params['prefs']['voting'])
|
50
|
+
expect(board.comment_permission_level).to eq(board_params['prefs']['comments'])
|
51
|
+
expect(board.invitation_permission_level).to eq(board_params['prefs']['invitations'])
|
52
|
+
expect(board.enable_self_join).to eq(board_params['prefs']['selfJoin'])
|
53
|
+
expect(board.enable_card_covers).to eq(board_params['prefs']['cardCovers'])
|
54
|
+
expect(board.card_aging_type).to eq(board_params['prefs']['cardAging'])
|
55
|
+
expect(board.background_color).to eq(board_params['prefs']['background'])
|
56
|
+
expect(board.background_image).to eq(board_params['prefs']['backgroundImage'])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when the fields argument has at least one field' do
|
61
|
+
|
62
|
+
context 'and the field does changed' do
|
63
|
+
let(:fields) { { description: 'Awesome things have changed.' } }
|
64
|
+
|
65
|
+
it 'board does set the changed fields' do
|
66
|
+
board.update_fields(fields)
|
67
|
+
|
68
|
+
expect(board.description).to eq('Awesome things have changed.')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'board has been mark as changed' do
|
72
|
+
board.update_fields(fields)
|
73
|
+
|
74
|
+
expect(board.changed?).to be_truthy
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "and the field doesn't changed" do
|
79
|
+
let(:fields) { { desc: board_params['desc'] } }
|
80
|
+
|
81
|
+
it "board attributes doesn't changed" do
|
82
|
+
board.update_fields(fields)
|
83
|
+
|
84
|
+
expect(board.description).to eq(board_params['desc'])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "board hasn't been mark as changed" do
|
88
|
+
board.update_fields(fields)
|
89
|
+
|
90
|
+
expect(board.changed?).to be_falsy
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context "and the field isn't a correct attributes of the card" do
|
95
|
+
let(:fields) { { abc: 'abc' } }
|
96
|
+
|
97
|
+
it "card attributes doesn't changed" do
|
98
|
+
board.update_fields(fields)
|
99
|
+
|
100
|
+
expect(board.id).to eq(board_params['id'])
|
101
|
+
expect(board.name).to eq(board_params['name'])
|
102
|
+
expect(board.description).to eq(board_params['desc'])
|
103
|
+
expect(board.description_data).to match_hash_with_indifferent_access(board_params['descData'])
|
104
|
+
expect(board.closed).to eq(board_params['closed'])
|
105
|
+
expect(board.organization_id).to eq(board_params['idOrganization'])
|
106
|
+
expect(board.enterprise_id).to eq(board_params['idEnterprise'])
|
107
|
+
expect(board.pinned).to eq(board_params['pinned'])
|
108
|
+
expect(board.url).to eq(board_params['url'])
|
109
|
+
expect(board.short_url).to eq(board_params['shortUrl'])
|
110
|
+
expect(board.visibility_level).to eq(board_params['prefs']['permissionLevel'])
|
111
|
+
expect(board.voting_permission_level).to eq(board_params['prefs']['voting'])
|
112
|
+
expect(board.comment_permission_level).to eq(board_params['prefs']['comments'])
|
113
|
+
expect(board.invitation_permission_level).to eq(board_params['prefs']['invitations'])
|
114
|
+
expect(board.enable_self_join).to eq(board_params['prefs']['selfJoin'])
|
115
|
+
expect(board.enable_card_covers).to eq(board_params['prefs']['cardCovers'])
|
116
|
+
expect(board.card_aging_type).to eq(board_params['prefs']['cardAging'])
|
117
|
+
expect(board.background_color).to eq(board_params['prefs']['background'])
|
118
|
+
expect(board.background_image).to eq(board_params['prefs']['backgroundImage'])
|
119
|
+
end
|
120
|
+
|
121
|
+
it "card hasn't been mark as changed" do
|
122
|
+
board.update_fields(fields)
|
123
|
+
|
124
|
+
expect(board.changed?).to be_falsy
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|