ruby-trello 2.2.0 → 2.3.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 +49 -10
- data/lib/trello.rb +47 -35
- data/lib/trello/action.rb +4 -2
- 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/basic_data.rb +7 -48
- data/lib/trello/board.rb +1 -1
- data/lib/trello/card.rb +88 -36
- data/lib/trello/custom_field.rb +26 -9
- data/lib/trello/custom_field_item.rb +32 -12
- data/lib/trello/label.rb +24 -7
- data/lib/trello/member.rb +1 -1
- data/lib/trello/register_attributes.rb +54 -0
- data/spec/action_spec.rb +1 -1
- data/spec/card_spec.rb +98 -22
- 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_card.yml +190 -0
- data/spec/cassettes/can_add_label_on_a_card.yml +281 -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_attachments.yml +187 -0
- data/spec/cassettes/can_get_comments.yml +193 -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_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_card.yml +99 -0
- data/spec/cassettes/can_success_create_new_checklist_to_a_card.yml +189 -0
- data/spec/cassettes/can_success_delete_card.yml +185 -0
- data/spec/cassettes/can_success_upate_a_card.yml +189 -0
- data/spec/cassettes/can_success_update_bong_a_card.yml +191 -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/custom_field_item_save_1.yml +97 -0
- data/spec/cassettes/custom_field_item_save_2.yml +281 -0
- data/spec/cassettes/get_board_of_card.yml +187 -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/remove_upvote_on_a_card_when_have_not_voted.yml +366 -0
- data/spec/cassettes/revote_on_a_card.yml +464 -0
- data/spec/custom_field_item_spec.rb +74 -0
- data/spec/custom_field_spec.rb +76 -0
- data/spec/integration/basic_data/many_spec.rb +123 -0
- data/spec/integration/basic_data/one_spec.rb +84 -0
- data/spec/integration/basic_data/register_attributes_spec.rb +75 -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 +50 -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/custom_field_item_spec.rb +47 -0
- data/spec/label_spec.rb +79 -0
- data/spec/spec_helper.rb +48 -23
- 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 +54 -0
- data/spec/unit/trello/card_spec.rb +103 -0
- metadata +185 -6
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Card#delete' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'can success delete card' do
|
9
|
+
VCR.use_cassette('can_success_delete_card') do
|
10
|
+
card = Trello::Card.find('5e95b664ace3621af695aeb0')
|
11
|
+
respone = card.delete
|
12
|
+
expect(respone.code).to eq(200)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Card#find' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'find with id and get all fields' do
|
9
|
+
VCR.use_cassette('card_find_with_id_and_get_all_fields') do
|
10
|
+
card = Trello::Card.find('5e9310df53f23017628a8011')
|
11
|
+
expect(card).to be_a(Trello::Card)
|
12
|
+
expect(card.id).to eq('5e9310df53f23017628a8011')
|
13
|
+
expect(card.short_id).not_to be_nil
|
14
|
+
expect(card.name).not_to be_nil
|
15
|
+
expect(card.desc).not_to be_nil
|
16
|
+
expect(card.due).not_to be_nil
|
17
|
+
expect(card.due_complete).not_to be_nil
|
18
|
+
expect(card.closed).not_to be_nil
|
19
|
+
expect(card.url).not_to be_nil
|
20
|
+
expect(card.short_url).not_to be_nil
|
21
|
+
expect(card.board_id).not_to be_nil
|
22
|
+
expect(card.member_ids).not_to be_nil
|
23
|
+
expect(card.list_id).not_to be_nil
|
24
|
+
expect(card.pos).not_to be_nil
|
25
|
+
expect(card.last_activity_date).not_to be_nil
|
26
|
+
expect(card.labels).not_to be_nil
|
27
|
+
expect(card.card_labels).not_to be_nil
|
28
|
+
expect(card.cover_image_id).not_to be_nil # only exist when the care use a custom cover image
|
29
|
+
expect(card.badges).not_to be_nil
|
30
|
+
|
31
|
+
expect(card.card_members).to be_nil # default not return members
|
32
|
+
expect(card.source_card_id).to be_nil # it's params only work for create card
|
33
|
+
expect(card.source_card_properties).to be_nil # it's params only work for creae card
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'find with id and get specific fields' do
|
38
|
+
VCR.use_cassette('card_find_with_id_and_get_specific_fields') do
|
39
|
+
card = Trello::Card.find('5e7233b06b440f2b93a57b58', fields: 'desc,pos', members: true)
|
40
|
+
expect(card).to be_a(Trello::Card)
|
41
|
+
expect(card.id).to eq('5e7233b06b440f2b93a57b58')
|
42
|
+
|
43
|
+
expect(card.desc).not_to be_nil
|
44
|
+
expect(card.pos).not_to be_nil
|
45
|
+
expect(card.card_members).not_to be_nil # default not return members
|
46
|
+
|
47
|
+
expect(card.name).to be_nil
|
48
|
+
expect(card.short_id).to be_nil
|
49
|
+
expect(card.url).to be_nil
|
50
|
+
expect(card.short_url).to be_nil
|
51
|
+
expect(card.due).to be_nil
|
52
|
+
expect(card.due_complete).to eq(false)
|
53
|
+
expect(card.closed).to be_nil
|
54
|
+
expect(card.board_id).to be_nil
|
55
|
+
expect(card.member_ids).to be_nil
|
56
|
+
expect(card.list_id).to be_nil
|
57
|
+
expect(card.last_activity_date).to be_nil
|
58
|
+
expect(card.labels).to eq([])
|
59
|
+
expect(card.card_labels).to be_nil
|
60
|
+
expect(card.cover_image_id).to be_nil # only exist when the care use a custom cover image
|
61
|
+
expect(card.badges).to be_nil
|
62
|
+
expect(card.source_card_id).to be_nil # it's params only work for create card
|
63
|
+
expect(card.source_card_properties).to be_nil # it's params only work for creae card
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Card#move_to_board' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'can move a card to another board without specific the target list' do
|
9
|
+
VCR.use_cassette('can_move_a_card_to_another_board_without_specific_list') do
|
10
|
+
board = Trello::Board.find('5e94ee7357ac8a3edc2b2145')
|
11
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
12
|
+
response = card.move_to_board(board)
|
13
|
+
|
14
|
+
expect(response.code).to eq(200)
|
15
|
+
body = JSON.parse(response.body)
|
16
|
+
expect(body['id']).to eq('5e95d1b4f43f9a06497f17f7')
|
17
|
+
expect(body['idBoard']).to eq('5e94ee7357ac8a3edc2b2145')
|
18
|
+
expect(body['idList']).not_to be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can move a card to another board with a specific target list' do
|
23
|
+
VCR.use_cassette('can_move_a_card_to_another_board_with_specific_list') do
|
24
|
+
board = Trello::Board.find('5e94f5ded016b22c2437c13c')
|
25
|
+
list = Trello::List.find('5e95d1b07f2ff83927319128')
|
26
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
27
|
+
response = card.move_to_board(board, list)
|
28
|
+
|
29
|
+
expect(response.code).to eq(200)
|
30
|
+
body = JSON.parse(response.body)
|
31
|
+
expect(body['id']).to eq('5e95d1b4f43f9a06497f17f7')
|
32
|
+
expect(body['idBoard']).to eq('5e94f5ded016b22c2437c13c')
|
33
|
+
expect(body['idList']).to eq('5e95d1b07f2ff83927319128')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Card#move_to_list' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'can move a card to another list' do
|
9
|
+
VCR.use_cassette('can_move_a_card_to_another_list') do
|
10
|
+
list = Trello::List.find('5e95d1b2342114318522f3f1')
|
11
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
12
|
+
response = card.move_to_list(list)
|
13
|
+
|
14
|
+
expect(response.code).to eq(200)
|
15
|
+
body = JSON.parse(response.body)
|
16
|
+
expect(body['idList']).to eq('5e95d1b2342114318522f3f1')
|
17
|
+
expect(body['idList']).not_to eq(card.list_id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trello::Card#remove_member' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'can remove a member to a card' do
|
9
|
+
VCR.use_cassette('can_remove_a_member_from_a_card') do
|
10
|
+
member = Trello::Member.new('id' => '5e679b808e6e8828784b30e1')
|
11
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
12
|
+
response = card.remove_member(member)
|
13
|
+
|
14
|
+
expect(response.code).to eq(200)
|
15
|
+
body = JSON.parse(response.body)
|
16
|
+
expect(body).to be_a(Array)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trell::Card.create' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
it 'can success create the card' do
|
9
|
+
VCR.use_cassette('can_success_create_a_card') do
|
10
|
+
card = Trello::Card.new(
|
11
|
+
name: 'Test Trello::Card.create',
|
12
|
+
list_id: '5e93bac014d40e501ee46b8d',
|
13
|
+
desc: 'testing card create',
|
14
|
+
member_ids: '5e679b808e6e8828784b30e1',
|
15
|
+
card_labels: '5e93ba987669b2254983d69d,5e93ba987669b2254983d69e',
|
16
|
+
due: '2020-12-22T01:59:00.000Z',
|
17
|
+
due_complete: false,
|
18
|
+
pos: 'top',
|
19
|
+
source_card_id: '5e93ba665c58c44a46cb2ef9',
|
20
|
+
source_card_properties: 'comments'
|
21
|
+
)
|
22
|
+
card.save
|
23
|
+
expect(card).to be_a(Trello::Card)
|
24
|
+
|
25
|
+
expect(card.name).to eq('Test Trello::Card.create')
|
26
|
+
expect(card.list_id).to eq('5e93bac014d40e501ee46b8d')
|
27
|
+
expect(card.desc).to eq('testing card create')
|
28
|
+
expect(card.member_ids).to eq(['5e679b808e6e8828784b30e1'])
|
29
|
+
expect(card.labels.count).to eq(2)
|
30
|
+
expect(card.due).to eq(Time.new(2020, 12, 22, 1, 59, 0, '+00:00'))
|
31
|
+
expect(card.due_complete).to eq(false)
|
32
|
+
expect(card.pos).not_to be_nil
|
33
|
+
expect(card.source_card_id).to eq('5e93ba665c58c44a46cb2ef9')
|
34
|
+
expect(card.source_card_properties).to eq('comments')
|
35
|
+
|
36
|
+
expect(card.id).not_to be_nil
|
37
|
+
expect(card.short_id).not_to be_nil
|
38
|
+
expect(card.closed).not_to be_nil
|
39
|
+
expect(card.url).not_to be_nil
|
40
|
+
expect(card.short_url).not_to be_nil
|
41
|
+
expect(card.board_id).not_to be_nil
|
42
|
+
expect(card.last_activity_date).not_to be_nil
|
43
|
+
expect(card.card_labels).not_to be_nil
|
44
|
+
expect(card.badges).not_to be_nil
|
45
|
+
expect(card.card_members).to be_nil # default not return members
|
46
|
+
expect(card.cover_image_id).to be_nil # only exist when the care use a custom cover image
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'can success update a card' do
|
51
|
+
VCR.use_cassette('can_success_upate_a_card') do
|
52
|
+
card = Trello::Card.find('5e946acb3cc40322434c214e')
|
53
|
+
expect(card.name).to eq('C2')
|
54
|
+
card.name = 'C2-changed'
|
55
|
+
card.save
|
56
|
+
expect(card.name).to eq('C2-changed')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trell::Card.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_card') do
|
10
|
+
card = Trello::Card.find('5e94fd9443f25a7263b165d0')
|
11
|
+
expect(card.name).to eq('C1')
|
12
|
+
expect(card.desc).to eq('')
|
13
|
+
expect(card.member_ids).to eq([])
|
14
|
+
expect(card.card_labels).to eq([])
|
15
|
+
expect(card.due).to be_nil
|
16
|
+
expect(card.due_complete).to eq(false)
|
17
|
+
expect(card.list_id).to eq('5e94eafdf553d46ea525faa7')
|
18
|
+
|
19
|
+
card.name = 'Test Trello::Card.update!'
|
20
|
+
card.list_id = '5e94fa1248c5e41ad0464a7f'
|
21
|
+
card.desc = 'testing card update!'
|
22
|
+
card.member_ids = '5e679b808e6e8828784b30e1'
|
23
|
+
card.card_labels = '5e94eaf37669b225494161c7'
|
24
|
+
card.due = '2020-12-22T01:59:00.000Z'
|
25
|
+
card.due_complete = false
|
26
|
+
card.pos = 'top'
|
27
|
+
|
28
|
+
card.update!
|
29
|
+
|
30
|
+
expect(card.name).to eq('Test Trello::Card.update!')
|
31
|
+
expect(card.list_id).to eq('5e94fa1248c5e41ad0464a7f')
|
32
|
+
expect(card.desc).to eq('testing card update!')
|
33
|
+
expect(card.member_ids).to eq(['5e679b808e6e8828784b30e1'])
|
34
|
+
expect(card.card_labels.count).to eq(1)
|
35
|
+
expect(card.due).to eq(Time.new(2020, 12, 22, 1, 59, 0, '+00:00'))
|
36
|
+
expect(card.due_complete).to eq(false)
|
37
|
+
expect(card.pos).not_to be_nil
|
38
|
+
|
39
|
+
expect(card.id).not_to be_nil
|
40
|
+
expect(card.short_id).not_to be_nil
|
41
|
+
expect(card.closed).not_to be_nil
|
42
|
+
expect(card.url).not_to be_nil
|
43
|
+
expect(card.short_url).not_to be_nil
|
44
|
+
expect(card.board_id).not_to be_nil
|
45
|
+
expect(card.last_activity_date).not_to be_nil
|
46
|
+
expect(card.card_labels).not_to be_nil
|
47
|
+
expect(card.badges).not_to be_nil
|
48
|
+
expect(card.card_members).to be_nil # default not return members
|
49
|
+
expect(card.cover_image_id).to be_nil # only exist when the care use a custom cover image
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Trell::Card#upvote #remove_upvote' do
|
4
|
+
include IntegrationHelpers
|
5
|
+
|
6
|
+
before { setup_trello }
|
7
|
+
|
8
|
+
describe '#upvote' do
|
9
|
+
it 'can success upvote on a card' do
|
10
|
+
VCR.use_cassette('can_upvote_on_a_card') do
|
11
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
12
|
+
|
13
|
+
expect(card.voters.count).to eq(0)
|
14
|
+
card.upvote
|
15
|
+
expect(card.voters.count).to eq(1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "won't raise error when already voted" do
|
20
|
+
VCR.use_cassette('revote_on_a_card') do
|
21
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
22
|
+
|
23
|
+
expect(card.voters.count).to eq(1)
|
24
|
+
expect { card.upvote }.not_to raise_error(Trello::Error)
|
25
|
+
expect(card.voters.count).to eq(1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#remove_upvote' do
|
31
|
+
it 'can success remove an upvote on a card' do
|
32
|
+
VCR.use_cassette('can_remove_an_upvote_on_a_card') do
|
33
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
34
|
+
|
35
|
+
expect(card.voters.count).to eq(1)
|
36
|
+
card.remove_upvote
|
37
|
+
expect(card.voters.count).to eq(0)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "won't raise error when haven't voted" do
|
42
|
+
VCR.use_cassette('remove_upvote_on_a_card_when_have_not_voted') do
|
43
|
+
card = Trello::Card.find('5e95d1b4f43f9a06497f17f7')
|
44
|
+
|
45
|
+
expect(card.voters.count).to eq(0)
|
46
|
+
expect { card.remove_upvote }.not_to raise_error(Trello::Error)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'CustomFieldItem 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
|
+
describe '#save' do
|
13
|
+
context 'when id does not exists' do
|
14
|
+
let(:custom_field_item) {
|
15
|
+
Trello::CustomFieldItem.new(
|
16
|
+
model_id: '5e679be5d53dfa748f41d775',
|
17
|
+
custom_field_id: '5e68e8e87c16bf75894df21a',
|
18
|
+
)
|
19
|
+
}
|
20
|
+
|
21
|
+
it 'update the custom field' do
|
22
|
+
VCR.use_cassette('custom_field_item_save_1') do
|
23
|
+
custom_field_item.value = { text: 'cool' }
|
24
|
+
custom_field_item.save
|
25
|
+
|
26
|
+
expect(custom_field_item.id).not_to be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when id exists' do
|
32
|
+
let(:custom_field_item) {
|
33
|
+
card = Trello::Card.find('5e679be5d53dfa748f41d775')
|
34
|
+
card.custom_field_items.find { |item| item.id == '5e68e8f02f77a28502efd036' }
|
35
|
+
}
|
36
|
+
|
37
|
+
it 'update the custom field' do
|
38
|
+
VCR.use_cassette('custom_field_item_save_2') do
|
39
|
+
custom_field_item.value = { text: 'nice' }
|
40
|
+
|
41
|
+
expect { custom_field_item.save }.not_to raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/spec/label_spec.rb
CHANGED
@@ -201,5 +201,84 @@ module Trello
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
|
+
|
205
|
+
describe '#update_fields' do
|
206
|
+
let(:label_detail) {{
|
207
|
+
'id' => 'id',
|
208
|
+
'name' => 'name',
|
209
|
+
'color' => 'color',
|
210
|
+
'idBoard' => 'board_id',
|
211
|
+
'uses' => 'uses'
|
212
|
+
}}
|
213
|
+
let(:label) { Label.new(label_detail) }
|
214
|
+
|
215
|
+
context 'when the fields argument is empty' do
|
216
|
+
let(:fields) { {} }
|
217
|
+
|
218
|
+
it 'card does not set any fields' do
|
219
|
+
label.update_fields(fields)
|
220
|
+
|
221
|
+
expect(label.id).to eq label_detail['id']
|
222
|
+
expect(label.name).to eq label_detail['name']
|
223
|
+
expect(label.color).to eq label_detail['color']
|
224
|
+
expect(label.board_id).to eq label_detail['idBoard']
|
225
|
+
expect(label.uses).to eq label_detail['uses']
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context 'when the fields argument has at least one field' do
|
230
|
+
context 'and the field does changed' do
|
231
|
+
let(:fields) { { name: 'Awesome Name' } }
|
232
|
+
|
233
|
+
it 'label does set the changed fields' do
|
234
|
+
label.update_fields(fields)
|
235
|
+
|
236
|
+
expect(label.name).to eq('Awesome Name')
|
237
|
+
end
|
238
|
+
|
239
|
+
it 'label has been mark as changed' do
|
240
|
+
label.update_fields(fields)
|
241
|
+
|
242
|
+
expect(label.changed?).to be_truthy
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context "and the field doesn't changed" do
|
247
|
+
let(:fields) { { name: label_detail['name'] } }
|
248
|
+
|
249
|
+
it "label attributes doesn't changed" do
|
250
|
+
label.update_fields(fields)
|
251
|
+
|
252
|
+
expect(label.name).to eq(label_detail['name'])
|
253
|
+
end
|
254
|
+
|
255
|
+
it "label hasn't been mark as changed", pending: true do
|
256
|
+
label.update_fields(fields)
|
257
|
+
|
258
|
+
expect(label.changed?).to be_falsy
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
context "and the field isn't a correct attributes of the label" do
|
263
|
+
let(:fields) { { abc: 'abc' } }
|
264
|
+
|
265
|
+
it "label attributes doesn't changed" do
|
266
|
+
label.update_fields(fields)
|
267
|
+
|
268
|
+
expect(label.id).to eq label_detail['id']
|
269
|
+
expect(label.name).to eq label_detail['name']
|
270
|
+
expect(label.color).to eq label_detail['color']
|
271
|
+
expect(label.board_id).to eq label_detail['idBoard']
|
272
|
+
expect(label.uses).to eq label_detail['uses']
|
273
|
+
end
|
274
|
+
|
275
|
+
it "label hasn't been mark as changed" do
|
276
|
+
label.update_fields(fields)
|
277
|
+
|
278
|
+
expect(label.changed?).to be_falsy
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
204
283
|
end
|
205
284
|
end
|