ruby-trello 2.0.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +106 -17
  3. data/lib/trello.rb +47 -34
  4. data/lib/trello/action.rb +10 -8
  5. data/lib/trello/association_builder/has_many.rb +17 -0
  6. data/lib/trello/association_builder/has_one.rb +16 -0
  7. data/lib/trello/association_fetcher/has_many.rb +26 -0
  8. data/lib/trello/association_fetcher/has_many/fetch.rb +47 -0
  9. data/lib/trello/association_fetcher/has_many/params.rb +56 -0
  10. data/lib/trello/association_fetcher/has_one.rb +25 -0
  11. data/lib/trello/association_fetcher/has_one/fetch.rb +49 -0
  12. data/lib/trello/association_fetcher/has_one/params.rb +36 -0
  13. data/lib/trello/association_infer_tool.rb +13 -0
  14. data/lib/trello/association_proxy.rb +1 -1
  15. data/lib/trello/attachment.rb +13 -10
  16. data/lib/trello/basic_data.rb +16 -49
  17. data/lib/trello/board.rb +17 -3
  18. data/lib/trello/card.rb +103 -38
  19. data/lib/trello/checklist.rb +14 -13
  20. data/lib/trello/client.rb +1 -1
  21. data/lib/trello/comment.rb +4 -4
  22. data/lib/trello/custom_field.rb +131 -0
  23. data/lib/trello/custom_field_item.rb +98 -0
  24. data/lib/trello/custom_field_option.rb +22 -0
  25. data/lib/trello/error.rb +12 -0
  26. data/lib/trello/item.rb +7 -7
  27. data/lib/trello/item_state.rb +3 -3
  28. data/lib/trello/label.rb +30 -12
  29. data/lib/trello/label_name.rb +10 -10
  30. data/lib/trello/list.rb +6 -6
  31. data/lib/trello/member.rb +10 -9
  32. data/lib/trello/notification.rb +6 -6
  33. data/lib/trello/organization.rb +11 -11
  34. data/lib/trello/plugin_datum.rb +6 -6
  35. data/lib/trello/register_attributes.rb +54 -0
  36. data/lib/trello/token.rb +6 -5
  37. data/lib/trello/webhook.rb +5 -5
  38. data/spec/action_spec.rb +22 -1
  39. data/spec/basic_data_spec.rb +58 -0
  40. data/spec/board_spec.rb +28 -2
  41. data/spec/card_spec.rb +183 -8
  42. data/spec/cassettes/can_add_a_file_from_url_on_a_card.yml +189 -0
  43. data/spec/cassettes/can_add_a_file_on_a_card.yml +200 -0
  44. data/spec/cassettes/can_add_a_member_to_a_card.yml +190 -0
  45. data/spec/cassettes/can_add_label_on_a_card.yml +281 -0
  46. data/spec/cassettes/can_close_bong_a_card.yml +189 -0
  47. data/spec/cassettes/can_get_actions.yml +196 -0
  48. data/spec/cassettes/can_get_attachments.yml +187 -0
  49. data/spec/cassettes/can_get_comments.yml +193 -0
  50. data/spec/cassettes/can_move_a_card_to_another_board_with_specific_list.yml +373 -0
  51. data/spec/cassettes/can_move_a_card_to_another_board_without_specific_list.yml +281 -0
  52. data/spec/cassettes/can_move_a_card_to_another_list.yml +281 -0
  53. data/spec/cassettes/can_remove_a_member_from_a_card.yml +185 -0
  54. data/spec/cassettes/can_remove_an_attachment_on_a_card.yml +277 -0
  55. data/spec/cassettes/can_remove_an_upvote_on_a_card.yml +465 -0
  56. data/spec/cassettes/can_remove_label_on_a_card.yml +279 -0
  57. data/spec/cassettes/can_success_add_comment_to_a_card.yml +196 -0
  58. data/spec/cassettes/can_success_copy_checklist_to_a_card.yml +281 -0
  59. data/spec/cassettes/can_success_copy_checklist_to_a_card_without_name_pos.yml +281 -0
  60. data/spec/cassettes/can_success_create_a_card.yml +99 -0
  61. data/spec/cassettes/can_success_create_new_checklist_to_a_card.yml +189 -0
  62. data/spec/cassettes/can_success_delete_card.yml +185 -0
  63. data/spec/cassettes/can_success_upate_a_card.yml +189 -0
  64. data/spec/cassettes/can_success_update_bong_a_board.yml +283 -0
  65. data/spec/cassettes/can_success_update_bong_a_card.yml +191 -0
  66. data/spec/cassettes/can_upvote_on_a_card.yml +469 -0
  67. data/spec/cassettes/card_find_with_id_and_get_all_fields.yml +95 -0
  68. data/spec/cassettes/card_find_with_id_and_get_specific_fields.yml +96 -0
  69. data/spec/cassettes/custom_field_item_save_1.yml +97 -0
  70. data/spec/cassettes/custom_field_item_save_2.yml +281 -0
  71. data/spec/cassettes/get_board_of_card.yml +187 -0
  72. data/spec/cassettes/get_check_item_states_of_card.yml +188 -0
  73. data/spec/cassettes/get_checklists_of_card.yml +187 -0
  74. data/spec/cassettes/get_cover_image_of_card.yml +187 -0
  75. data/spec/cassettes/get_custom_field_items_of_card.yml +187 -0
  76. data/spec/cassettes/get_list_of_card.yml +188 -0
  77. data/spec/cassettes/get_lists.yml +187 -0
  78. data/spec/cassettes/get_members_of_card.yml +189 -0
  79. data/spec/cassettes/get_plugin_data_of_card.yml +187 -0
  80. data/spec/cassettes/get_voters_of_card.yml +188 -0
  81. data/spec/cassettes/remove_upvote_on_a_card_when_have_not_voted.yml +366 -0
  82. data/spec/cassettes/revote_on_a_card.yml +464 -0
  83. data/spec/checklist_spec.rb +39 -3
  84. data/spec/client_spec.rb +5 -1
  85. data/spec/custom_field_item_spec.rb +192 -0
  86. data/spec/custom_field_option_spec.rb +49 -0
  87. data/spec/custom_field_spec.rb +261 -0
  88. data/spec/integration/basic_data/many_spec.rb +123 -0
  89. data/spec/integration/basic_data/one_spec.rb +84 -0
  90. data/spec/integration/basic_data/register_attributes_spec.rb +75 -0
  91. data/spec/integration/board/update!_spec.rb +31 -0
  92. data/spec/integration/board_lists_spec.rb +21 -0
  93. data/spec/integration/card/add_and_remove_attachment_spec.rb +45 -0
  94. data/spec/integration/card/add_and_remove_label_spec.rb +35 -0
  95. data/spec/integration/card/add_checklist_spec.rb +32 -0
  96. data/spec/integration/card/add_comment_spec.rb +19 -0
  97. data/spec/integration/card/add_memeber_spec.rb +19 -0
  98. data/spec/integration/card/associations/actions_spec.rb +17 -0
  99. data/spec/integration/card/associations/attachments_spec.rb +18 -0
  100. data/spec/integration/card/associations/board_spec.rb +17 -0
  101. data/spec/integration/card/associations/check_item_states_spec.rb +17 -0
  102. data/spec/integration/card/associations/checklists_spec.rb +18 -0
  103. data/spec/integration/card/associations/comments_spec.rb +19 -0
  104. data/spec/integration/card/associations/cover_image_spec.rb +18 -0
  105. data/spec/integration/card/associations/custom_field_items_spec.rb +18 -0
  106. data/spec/integration/card/associations/list_spec.rb +16 -0
  107. data/spec/integration/card/associations/members_spec.rb +18 -0
  108. data/spec/integration/card/associations/plugin_data_spec.rb +18 -0
  109. data/spec/integration/card/associations/voters_spec.rb +17 -0
  110. data/spec/integration/card/close!_spec.rb +16 -0
  111. data/spec/integration/card/create_new_check_list_spec.rb +19 -0
  112. data/spec/integration/card/create_spec.rb +50 -0
  113. data/spec/integration/card/delete_spec.rb +16 -0
  114. data/spec/integration/card/find_spec.rb +67 -0
  115. data/spec/integration/card/move_to_board_spec.rb +36 -0
  116. data/spec/integration/card/move_to_list_spec.rb +20 -0
  117. data/spec/integration/card/remove_member_spec.rb +19 -0
  118. data/spec/integration/card/save_spec.rb +61 -0
  119. data/spec/integration/card/update!_spec.rb +53 -0
  120. data/spec/integration/card/vote_spec.rb +50 -0
  121. data/spec/integration/custom_field_item_spec.rb +47 -0
  122. data/spec/item_spec.rb +20 -0
  123. data/spec/label_spec.rb +99 -0
  124. data/spec/list_spec.rb +21 -0
  125. data/spec/member_spec.rb +23 -0
  126. data/spec/notification_spec.rb +21 -0
  127. data/spec/organization_spec.rb +26 -0
  128. data/spec/spec_helper.rb +96 -23
  129. data/spec/token_spec.rb +19 -0
  130. data/spec/unit/trello/association_builder/has_many_spec.rb +36 -0
  131. data/spec/unit/trello/association_builder/has_one_spec.rb +36 -0
  132. data/spec/unit/trello/association_fetcher/has_many/fetch_spec.rb +38 -0
  133. data/spec/unit/trello/association_fetcher/has_many/params_spec.rb +107 -0
  134. data/spec/unit/trello/association_fetcher/has_many_spec.rb +50 -0
  135. data/spec/unit/trello/association_fetcher/has_one/fetch_spec.rb +51 -0
  136. data/spec/unit/trello/association_fetcher/has_one/params_spec.rb +81 -0
  137. data/spec/unit/trello/association_fetcher/has_one_spec.rb +49 -0
  138. data/spec/unit/trello/association_infer_tool_spec.rb +41 -0
  139. data/spec/unit/trello/basic_data_spec.rb +54 -0
  140. data/spec/unit/trello/card_spec.rb +103 -0
  141. data/spec/webhook_spec.rb +20 -0
  142. metadata +224 -30
@@ -0,0 +1,123 @@
1
+ require 'spec_helper'
2
+
3
+ module Trello
4
+ describe BasicData do
5
+ describe '.many' do
6
+ let(:client_double) { double('client') }
7
+ let(:cards) { double('cards') }
8
+
9
+ around do |example|
10
+ class FakeCard < BasicData
11
+ end
12
+ class FakeBoard < BasicData
13
+ def update_fields(fields)
14
+ attributes[:id] = fields[:id]
15
+ end
16
+ end
17
+
18
+ example.run
19
+
20
+ Trello.send(:remove_const, 'FakeBoard')
21
+ Trello.send(:remove_const, 'FakeCard')
22
+ end
23
+
24
+ def mock_client_and_association(klass:, resource:, id:, path:, params:)
25
+ resources = double('resources')
26
+ allow(FakeBoard).to receive(:client).and_return(client_double)
27
+ allow_any_instance_of(FakeBoard).to receive(:client).and_return(client_double)
28
+ allow(client_double).to receive(:find_many).with(klass, "/#{resource}/#{id}/#{path}", params).and_return(resources)
29
+ allow(MultiAssociation).to receive(:new).with(FakeBoard, resources).and_return(double('association', proxy: cards))
30
+ end
31
+
32
+ context 'when only pass in the name' do
33
+ before do
34
+ FakeBoard.class_eval { many :fake_cards }
35
+
36
+ mock_client_and_association(
37
+ klass: Trello::FakeCard,
38
+ resource: 'fakeboards',
39
+ id: 1,
40
+ path: 'fake_cards',
41
+ params: {}
42
+ )
43
+ end
44
+
45
+ it 'can get cards from client' do
46
+ expect(FakeBoard.new(id: 1).fake_cards).to eq(cards)
47
+ end
48
+ end
49
+
50
+ context 'when pass in name with in:' do
51
+ before do
52
+ FakeBoard.class_eval { many :fake_cards, in: 'boards' }
53
+
54
+ mock_client_and_association(
55
+ klass: Trello::FakeCard,
56
+ resource: 'boards',
57
+ id: 1,
58
+ path: 'fake_cards',
59
+ params: {}
60
+ )
61
+ end
62
+
63
+ it 'can get cards from client' do
64
+ expect(FakeBoard.new(id: 1).fake_cards).to eq(cards)
65
+ end
66
+ end
67
+
68
+ context 'when pass in name with via:' do
69
+ before do
70
+ FakeBoard.class_eval { many :fake_cards, via: Card }
71
+
72
+ mock_client_and_association(
73
+ klass: Trello::Card,
74
+ resource: 'fakeboards',
75
+ id: 1,
76
+ path: 'fake_cards',
77
+ params: {}
78
+ )
79
+ end
80
+
81
+ it 'can get cards from client' do
82
+ expect(FakeBoard.new(id: 1).fake_cards).to eq(cards)
83
+ end
84
+ end
85
+
86
+ context 'when pass in name with path:' do
87
+ before do
88
+ FakeBoard.class_eval { many :fake_cards, path: 'test' }
89
+
90
+ mock_client_and_association(
91
+ klass: Trello::FakeCard,
92
+ resource: 'fakeboards',
93
+ id: 1,
94
+ path: 'test',
95
+ params: {}
96
+ )
97
+ end
98
+
99
+ it 'can get cards from client' do
100
+ expect(FakeBoard.new(id: 1).fake_cards).to eq(cards)
101
+ end
102
+ end
103
+
104
+ context 'when pass in name with other params' do
105
+ before do
106
+ FakeBoard.class_eval { many :fake_cards, test: 'test' }
107
+
108
+ mock_client_and_association(
109
+ klass: Trello::FakeCard,
110
+ resource: 'fakeboards',
111
+ id: 1,
112
+ path: 'fake_cards',
113
+ params: {test: 'test'}
114
+ )
115
+ end
116
+
117
+ it 'can get cards from client' do
118
+ expect(FakeBoard.new(id: 1).fake_cards).to eq(cards)
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trello::BasicData.one' do
4
+
5
+ let(:client_double) { double('client') }
6
+ let(:organization) { double('organization') }
7
+
8
+ around do |example|
9
+ module Trello
10
+ class FakeOrganization < BasicData
11
+ end
12
+ class FakeBoard < BasicData
13
+ def update_fields(fields)
14
+ attributes[:id] = fields[:id]
15
+ end
16
+ end
17
+ end
18
+
19
+ example.run
20
+
21
+ Trello.send(:remove_const, 'FakeBoard')
22
+ Trello.send(:remove_const, 'FakeOrganization')
23
+ end
24
+
25
+ def mock_client_and_association(klass: Trello::FakeOrganization, id: 1, path: nil, id_field: :id)
26
+ association_restful_name = path
27
+ allow(Trello::FakeBoard).to receive(:client).and_return(client_double)
28
+ allow_any_instance_of(Trello::FakeBoard).to receive(:client).and_return(client_double)
29
+ allow_any_instance_of(Trello::FakeBoard).to receive(id_field).and_return(id)
30
+ if association_restful_name
31
+ allow(client_double).to receive(:find).with(association_restful_name, id).and_return(organization)
32
+ else
33
+ allow(klass).to receive(:find).with(id).and_return(organization)
34
+ end
35
+ end
36
+
37
+ context 'when only pass in the name' do
38
+ before do
39
+ Trello::FakeBoard.class_eval { one :fake_organization }
40
+
41
+ mock_client_and_association
42
+ end
43
+
44
+ it 'can get the association from client' do
45
+ expect(Trello::FakeBoard.new(id: 1).fake_organization).to eq(organization)
46
+ end
47
+ end
48
+
49
+ context 'when pass in name with path' do
50
+ before do
51
+ Trello::FakeBoard.class_eval { one :fake_organization, path: 'organizations' }
52
+
53
+ mock_client_and_association(path: 'organizations')
54
+ end
55
+
56
+ it 'can get the association from client' do
57
+ expect(Trello::FakeBoard.new(id: 1).fake_organization).to eq(organization)
58
+ end
59
+ end
60
+
61
+ context 'when pass in name with via' do
62
+ before do
63
+ Trello::FakeBoard.class_eval { one :fake_organization, via: Trello::FakeOrganization }
64
+
65
+ mock_client_and_association
66
+ end
67
+
68
+ it 'can get the association from client' do
69
+ expect(Trello::FakeBoard.new(id: 1).fake_organization).to eq(organization)
70
+ end
71
+ end
72
+
73
+ context 'when pass in name with using' do
74
+ before do
75
+ Trello::FakeBoard.class_eval { one :fake_organization, using: :test_id }
76
+
77
+ mock_client_and_association(id_field: :test_id)
78
+ end
79
+
80
+ it 'can get the association from client' do
81
+ expect(Trello::FakeBoard.new(id: 1).fake_organization).to eq(organization)
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trello::BasicData.register_attributes' do
4
+
5
+ around do |example|
6
+ module Trello
7
+ class FakeBoard < BasicData
8
+ end
9
+ end
10
+
11
+ example.run
12
+
13
+ Trello.send(:remove_const, 'FakeBoard')
14
+ end
15
+
16
+ context 'when register attributes are all writable' do
17
+ before do
18
+ Trello::FakeBoard.class_eval do
19
+ register_attributes :id, :name, :description
20
+
21
+ def initialize(fields={})
22
+ attributes[:id] = fields[:id]
23
+ attributes[:name] = fields[:name]
24
+ attributes[:description] = fields[:description]
25
+ end
26
+ end
27
+ end
28
+
29
+ it 'create getter method for all attributes' do
30
+ expect(Trello::FakeBoard.new).to respond_to(:id, :name, :description)
31
+ end
32
+
33
+ it 'create setting method for all attributes' do
34
+ expect(Trello::FakeBoard.new).to respond_to(:id=, :name=, :description=)
35
+ end
36
+
37
+ it 'any attributes changes will caused the record being marked as changed' do
38
+ fake_board = Trello::FakeBoard.new(id: 1, name: 'test')
39
+ expect(fake_board.changed?).to eq(false)
40
+ fake_board.name = 'TEST'
41
+ expect(fake_board.changed?).to eq(true)
42
+ end
43
+ end
44
+
45
+ context 'when register attributes are partial read-only' do
46
+ before do
47
+ Trello::FakeBoard.class_eval do
48
+ register_attributes :id, :name, :description, readonly: [:id]
49
+
50
+ def initialize(fields={})
51
+ attributes[:id] = fields[:id]
52
+ attributes[:name] = fields[:name]
53
+ attributes[:description] = fields[:description]
54
+ end
55
+ end
56
+ end
57
+
58
+ it 'create getter method for all attributes' do
59
+ expect(Trello::FakeBoard.new).to respond_to(:id, :name, :description)
60
+ end
61
+
62
+ it 'create setting method for all writable attributes' do
63
+ expect(Trello::FakeBoard.new).to respond_to(:name=, :description=)
64
+ expect(Trello::FakeBoard.new).not_to respond_to(:id=)
65
+ end
66
+
67
+ it 'any writable attributes changes will caused the record being marked as changed' do
68
+ fake_board = Trello::FakeBoard.new(id: 1, name: 'test')
69
+ expect(fake_board.changed?).to eq(false)
70
+ fake_board.name = 'TEST'
71
+ expect(fake_board.changed?).to eq(true)
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trell::Board.update!' do
4
+ include IntegrationHelpers
5
+
6
+ before { setup_trello }
7
+
8
+ it 'can update! a card' do
9
+ VCR.use_cassette('can_success_update_bong_a_board') do
10
+ board = Trello::Board.find('5e93ba403f1ab3603ba81a09')
11
+
12
+ expect(board.name).to eq('IT 1')
13
+ expect(board.description).to eq('')
14
+ expect(board.closed).to eq(true)
15
+ expect(board.organization_id).to eq('5e93ba154634282b6df23bcc')
16
+
17
+ board.name = 'IT 1 - Changed'
18
+ board.description = 'This is a test board called IT 1'
19
+ board.closed = false
20
+ board.organization_id = '5eb427016b5a464a74803f1c'
21
+
22
+ board.update!
23
+
24
+ board = Trello::Board.find('5e93ba403f1ab3603ba81a09')
25
+ expect(board.name).to eq('IT 1 - Changed')
26
+ expect(board.description).to eq('This is a test board called IT 1')
27
+ expect(board.closed).to eq(false)
28
+ expect(board.organization_id).to eq('5eb427016b5a464a74803f1c')
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Board - Lists API' do
4
+
5
+ before do
6
+ Trello.configure do |config|
7
+ config.developer_public_key = ENV['TRELLO_DEVELOPER_PUBLIC_KEY'] || 'developerpublickey'
8
+ config.member_token = ENV['TRELLO_MEMBER_TOKEN'] || 'membertoken'
9
+ end
10
+ end
11
+
12
+ it 'AssociationProxy#to_a, #to_ary' do
13
+ VCR.use_cassette('get_lists') do
14
+ board = Trello::Board.find('5e679be40c407034b479459c')
15
+ lists = board.lists
16
+ expect(lists.to_a).to be_a(Array)
17
+ expect(lists.to_ary).to be_a(Array)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trell::Card add and remove attachment' do
4
+ include IntegrationHelpers
5
+
6
+ before { setup_trello }
7
+
8
+ describe '#add_attachment' do
9
+ it 'can success add an attachment(file) on a card' do
10
+ VCR.use_cassette('can_add_a_file_on_a_card') do
11
+ card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
12
+ file = File.new('spec/integration/card/add_and_remove_attachment_spec.rb', 'r')
13
+
14
+ response = card.add_attachment(file)
15
+ expect(response.code).to eq(200)
16
+ body = JSON.parse(response.body)
17
+ expect(body['name']).to eq('add_and_remove_attachment_spec.rb')
18
+ end
19
+ end
20
+
21
+ it 'can success add and attachment(url) on a card' do
22
+ VCR.use_cassette('can_add_a_file_from_url_on_a_card') do
23
+ card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
24
+ file_url = 'https://upload.wikimedia.org/wikipedia/en/6/6b/Hello_Web_Series_%28Wordmark%29_Logo.png'
25
+
26
+ response = card.add_attachment(file_url, 'hello.png')
27
+ expect(response.code).to eq(200)
28
+ body = JSON.parse(response.body)
29
+ expect(body['name']).to eq('hello.png')
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '#remove_attachment' do
35
+ it 'can success remove and attachment on a card' do
36
+ VCR.use_cassette('can_remove_an_attachment_on_a_card') do
37
+ card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
38
+ attachments = card.attachments
39
+
40
+ response = card.remove_attachment(attachments.last)
41
+ expect(response.code).to eq(200)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trell::Card add and remove label' do
4
+ include IntegrationHelpers
5
+
6
+ before { setup_trello }
7
+
8
+ describe '#add_label' do
9
+ it 'can success add a label on a card' do
10
+ VCR.use_cassette('can_add_label_on_a_card') do
11
+ card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
12
+ label = Trello::Label.find('5e94f5de7669b2254978bd14')
13
+ label.name = 'label name' # For past name valiation
14
+
15
+ response = card.add_label(label)
16
+ expect(response.code).to eq(200)
17
+ body = JSON.parse(response.body)
18
+ expect(body.first).to eq('5e94f5de7669b2254978bd14')
19
+ end
20
+ end
21
+ end
22
+
23
+ describe '#remove_label' do
24
+ it 'can success remove a label on a card' do
25
+ VCR.use_cassette('can_remove_label_on_a_card') do
26
+ card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
27
+ label = Trello::Label.find('5e94f5de7669b2254978bd14')
28
+ label.name = 'label name' # For past name valiation
29
+
30
+ response = card.remove_label(label)
31
+ expect(response.code).to eq(200)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Trell::Card#add_checklist' do
4
+ include IntegrationHelpers
5
+
6
+ before { setup_trello }
7
+
8
+ it 'can copy a checklist from another card' do
9
+ VCR.use_cassette('can_success_copy_checklist_to_a_card') do
10
+ checklist = Trello::Checklist.find('5e948a1a9e2cfd0ef6818e89')
11
+ card = Trello::Card.find('5e93ba665c58c44a46cb2ef9')
12
+ response = card.add_checklist(checklist, name: 'ToDo2', position: 'top')
13
+
14
+ expect(response.code).to eq(200)
15
+ body = JSON.parse(response.body)
16
+ expect(body['name']).to eq('ToDo2')
17
+ end
18
+ end
19
+
20
+ it 'can copy a checklist from another card without specify name and position' do
21
+ VCR.use_cassette('can_success_copy_checklist_to_a_card_without_name_pos') do
22
+ checklist = Trello::Checklist.find('5e948a1a9e2cfd0ef6818e89')
23
+ card = Trello::Card.find('5e93ba665c58c44a46cb2ef9')
24
+ response = card.add_checklist(checklist)
25
+
26
+ expect(response.code).to eq(200)
27
+ body = JSON.parse(response.body)
28
+ expect(body['idCard']).to eq(card.id)
29
+ expect(body['name']).to eq(checklist.name)
30
+ end
31
+ end
32
+ end