ruby-trello 1.2.1 → 1.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 +6 -5
- data/lib/trello/board.rb +6 -8
- data/lib/trello/card.rb +14 -28
- data/lib/trello/checklist.rb +14 -0
- data/lib/trello/item.rb +4 -0
- data/lib/trello/label.rb +3 -3
- data/lib/trello/list.rb +13 -3
- data/lib/trello/organization.rb +14 -7
- data/spec/action_spec.rb +67 -31
- data/spec/array_spec.rb +1 -1
- data/spec/association_spec.rb +11 -7
- data/spec/basic_auth_policy_spec.rb +4 -4
- data/spec/board_spec.rb +169 -92
- data/spec/card_spec.rb +232 -119
- data/spec/checklist_spec.rb +109 -16
- data/spec/client_spec.rb +83 -45
- data/spec/configuration_spec.rb +24 -43
- data/spec/hash_spec.rb +5 -1
- data/spec/item_spec.rb +27 -9
- data/spec/label_spec.rb +52 -27
- data/spec/list_spec.rb +86 -29
- data/spec/member_spec.rb +62 -40
- data/spec/notification_spec.rb +57 -22
- data/spec/oauth_policy_spec.rb +45 -24
- data/spec/organization_spec.rb +16 -8
- data/spec/spec_helper.rb +28 -3
- data/spec/string_spec.rb +11 -8
- data/spec/token_spec.rb +31 -11
- data/spec/trello_spec.rb +20 -23
- data/spec/webhook_spec.rb +24 -9
- metadata +4 -6
- data/spec/item_state_spec.rb +0 -0
data/spec/organization_spec.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
module Trello
|
@@ -8,28 +7,37 @@ module Trello
|
|
8
7
|
let(:organization) { client.find(:organization, '4ee7e59ae582acdec8000291') }
|
9
8
|
let(:client) { Client.new }
|
10
9
|
|
11
|
-
before
|
12
|
-
client
|
13
|
-
|
10
|
+
before do
|
11
|
+
allow(client)
|
12
|
+
.to receive(:get)
|
13
|
+
.with('/organizations/4ee7e59ae582acdec8000291', {})
|
14
|
+
.and_return organization_payload
|
14
15
|
end
|
15
16
|
|
16
17
|
context 'finding' do
|
17
18
|
let(:client) { Trello.client }
|
18
19
|
|
19
20
|
it 'delegates to Trello.client#find' do
|
20
|
-
client
|
21
|
+
expect(client)
|
22
|
+
.to receive(:find)
|
23
|
+
.with(:organization, '4ee7e59ae582acdec8000291', {})
|
24
|
+
|
21
25
|
Organization.find('4ee7e59ae582acdec8000291')
|
22
26
|
end
|
23
27
|
|
24
28
|
it 'is equivalent to client#find' do
|
25
|
-
Organization.find('4ee7e59ae582acdec8000291').
|
29
|
+
expect(Organization.find('4ee7e59ae582acdec8000291')).to eq(organization)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
33
|
context 'actions' do
|
30
34
|
it 'retrieves actions' do
|
31
|
-
client
|
32
|
-
|
35
|
+
allow(client)
|
36
|
+
.to receive(:get)
|
37
|
+
.with('/organizations/4ee7e59ae582acdec8000291/actions', { filter: :all })
|
38
|
+
.and_return actions_payload
|
39
|
+
|
40
|
+
expect(organization.actions.count).to be > 0
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
2
3
|
unless defined? Rubinius
|
3
4
|
require 'simplecov'
|
4
5
|
SimpleCov.start
|
5
6
|
end
|
6
7
|
|
8
|
+
begin
|
9
|
+
require 'pry-byebug'
|
10
|
+
rescue LoadError
|
11
|
+
end
|
12
|
+
|
7
13
|
# Set up gems listed in the Gemfile.
|
8
14
|
begin
|
9
15
|
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
|
@@ -23,10 +29,10 @@ require 'stringio'
|
|
23
29
|
|
24
30
|
Trello.logger = Logger.new(StringIO.new)
|
25
31
|
|
26
|
-
RSpec.configure do |
|
27
|
-
|
32
|
+
RSpec.configure do |rspec|
|
33
|
+
rspec.filter_run_excluding broken: true
|
28
34
|
|
29
|
-
|
35
|
+
rspec.before :each do
|
30
36
|
Trello.reset!
|
31
37
|
end
|
32
38
|
end
|
@@ -84,6 +90,25 @@ module Helpers
|
|
84
90
|
JSON.generate(checklists_details)
|
85
91
|
end
|
86
92
|
|
93
|
+
def copied_checklists_details
|
94
|
+
[{
|
95
|
+
'id' => 'uvwxyz987654321987654321',
|
96
|
+
'name' => 'Test Checklist',
|
97
|
+
'desc' => '',
|
98
|
+
'closed' => nil,
|
99
|
+
'position' => 99999,
|
100
|
+
'url' => nil,
|
101
|
+
'idBoard' => 'abcdef123456789123456789',
|
102
|
+
'idList' => nil,
|
103
|
+
'idMembers' => nil,
|
104
|
+
'checkItems' => []
|
105
|
+
}]
|
106
|
+
end
|
107
|
+
|
108
|
+
def copied_checklists_payload
|
109
|
+
JSON.generate(copied_checklists_details)
|
110
|
+
end
|
111
|
+
|
87
112
|
def lists_details
|
88
113
|
[{
|
89
114
|
'id' => 'abcdef123456789123456789',
|
data/spec/string_spec.rb
CHANGED
@@ -16,14 +16,17 @@ describe String, '#json_into' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'converts json into an instance of a class' do
|
19
|
-
'{}'.json_into(example_class).
|
19
|
+
expect('{}'.json_into(example_class)).to be_a example_class
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'supplies the parsed json to the class ctor as a hash' do
|
23
|
-
example_class
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
expect(example_class)
|
24
|
+
.to receive(:new)
|
25
|
+
.once
|
26
|
+
.with({
|
27
|
+
"name" => "Jazz Kang",
|
28
|
+
"description" => "Plonker"
|
29
|
+
})
|
27
30
|
|
28
31
|
json_text = '{"name" : "Jazz Kang", "description": "Plonker"}'
|
29
32
|
|
@@ -40,10 +43,10 @@ describe String, '#json_into' do
|
|
40
43
|
|
41
44
|
result = json_text.json_into example_class
|
42
45
|
|
43
|
-
result.
|
44
|
-
result.size.
|
46
|
+
expect(result).to be_an Array
|
47
|
+
expect(result.size).to eq 2
|
45
48
|
result.each do |parsed|
|
46
|
-
parsed.
|
49
|
+
expect(parsed).to be_a example_class
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
data/spec/token_spec.rb
CHANGED
@@ -7,43 +7,63 @@ module Trello
|
|
7
7
|
let(:token) { client.find(:token, '1234') }
|
8
8
|
let(:client) { Client.new }
|
9
9
|
|
10
|
-
before
|
11
|
-
client
|
10
|
+
before do
|
11
|
+
allow(client)
|
12
|
+
.to receive(:get)
|
13
|
+
.with('/tokens/1234', {})
|
14
|
+
.and_return token_payload
|
12
15
|
end
|
13
16
|
|
14
17
|
context 'finding' do
|
15
18
|
let(:client) { Trello.client }
|
16
19
|
|
17
20
|
it 'delegates to Trello.client#find' do
|
18
|
-
client
|
21
|
+
expect(client)
|
22
|
+
.to receive(:find)
|
23
|
+
.with(:token, '1234', {webhooks: true})
|
24
|
+
|
19
25
|
Token.find('1234')
|
20
26
|
end
|
21
27
|
|
22
28
|
it 'is equivalent to client#find' do
|
23
|
-
Token.find('1234', {}).
|
29
|
+
expect(Token.find('1234', {})).to eq(token)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
33
|
context 'attributes' do
|
28
34
|
it 'has an id' do
|
29
|
-
token.id.
|
35
|
+
expect(token.id).to eq '4f2c10c7b3eb95a45b294cd5'
|
30
36
|
end
|
31
37
|
|
32
38
|
it 'gets its created_at date' do
|
33
|
-
token.created_at.
|
39
|
+
expect(token.created_at).to eq Time.iso8601('2012-02-03T16:52:23.661Z')
|
34
40
|
end
|
35
41
|
|
36
42
|
it 'has a permission grant' do
|
37
|
-
token.permissions.count.
|
43
|
+
expect(token.permissions.count).to eq 3
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
41
47
|
context 'members' do
|
48
|
+
before do
|
49
|
+
allow(client)
|
50
|
+
.to receive(:get)
|
51
|
+
.with('/members/abcdef123456789123456789', {})
|
52
|
+
.and_return user_payload
|
53
|
+
|
54
|
+
allow(Trello.client)
|
55
|
+
.to receive(:get)
|
56
|
+
.with('/members/abcdef123456789123456789', {})
|
57
|
+
.and_return user_payload
|
58
|
+
|
59
|
+
allow(client)
|
60
|
+
.to receive(:get)
|
61
|
+
.with('/tokens/1234', {})
|
62
|
+
.and_return token_payload
|
63
|
+
end
|
64
|
+
|
42
65
|
it 'retrieves the member who authorized the token' do
|
43
|
-
|
44
|
-
Trello.client.stub(:get).with('/members/abcdef123456789123456789', {}).and_return user_payload
|
45
|
-
client.stub(:get).with('/tokens/1234', {}).and_return token_payload
|
46
|
-
token.member.should == Member.find('abcdef123456789123456789')
|
66
|
+
expect(token.member).to eq Member.find('abcdef123456789123456789')
|
47
67
|
end
|
48
68
|
end
|
49
69
|
end
|
data/spec/trello_spec.rb
CHANGED
@@ -6,27 +6,24 @@ include Trello::Authorization
|
|
6
6
|
describe Trello do
|
7
7
|
|
8
8
|
describe 'self.configure' do
|
9
|
-
|
9
|
+
before do
|
10
10
|
Trello.configure do |config|
|
11
11
|
config.developer_public_key = 'developer_public_key'
|
12
12
|
config.member_token = 'member_token'
|
13
13
|
end
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
it 'builds auth policy client uses to make requests' do
|
17
|
+
allow(TInternet).to receive(:execute)
|
18
|
+
expect(Trello.auth_policy).to receive(:authorize)
|
17
19
|
Trello.client.get(:member, params = {})
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'configures basic auth policy' do
|
21
|
-
Trello.configure do |config|
|
22
|
-
config.developer_public_key = 'developer_public_key'
|
23
|
-
config.member_token = 'member_token'
|
24
|
-
end
|
25
|
-
|
26
23
|
auth_policy = Trello.auth_policy
|
27
|
-
auth_policy.
|
28
|
-
auth_policy.developer_public_key.
|
29
|
-
auth_policy.member_token.
|
24
|
+
expect(auth_policy).to be_a(BasicAuthPolicy)
|
25
|
+
expect(auth_policy.developer_public_key).to eq('developer_public_key')
|
26
|
+
expect(auth_policy.member_token).to eq('member_token')
|
30
27
|
end
|
31
28
|
|
32
29
|
context 'oauth' do
|
@@ -42,16 +39,16 @@ describe Trello do
|
|
42
39
|
it 'configures oauth policy' do
|
43
40
|
auth_policy = Trello.auth_policy
|
44
41
|
|
45
|
-
auth_policy.
|
46
|
-
auth_policy.consumer_key.
|
47
|
-
auth_policy.consumer_secret.
|
48
|
-
auth_policy.oauth_token.
|
49
|
-
auth_policy.oauth_token_secret.
|
42
|
+
expect(auth_policy).to be_a(OAuthPolicy)
|
43
|
+
expect(auth_policy.consumer_key).to eq('consumer_key')
|
44
|
+
expect(auth_policy.consumer_secret).to eq('consumer_secret')
|
45
|
+
expect(auth_policy.oauth_token).to eq('oauth_token')
|
46
|
+
expect(auth_policy.oauth_token_secret).to eq('oauth_token_secret')
|
50
47
|
end
|
51
48
|
|
52
49
|
it 'updates auth policy configuration' do
|
53
50
|
auth_policy = Trello.auth_policy
|
54
|
-
auth_policy.consumer_key.
|
51
|
+
expect(auth_policy.consumer_key).to eq('consumer_key')
|
55
52
|
|
56
53
|
Trello.configure do |config|
|
57
54
|
config.consumer_key = 'new_consumer_key'
|
@@ -62,11 +59,11 @@ describe Trello do
|
|
62
59
|
|
63
60
|
auth_policy = Trello.auth_policy
|
64
61
|
|
65
|
-
auth_policy.
|
66
|
-
auth_policy.consumer_key.
|
67
|
-
auth_policy.consumer_secret.
|
68
|
-
auth_policy.oauth_token.
|
69
|
-
auth_policy.oauth_token_secret.
|
62
|
+
expect(auth_policy).to be_a(OAuthPolicy)
|
63
|
+
expect(auth_policy.consumer_key).to eq('new_consumer_key')
|
64
|
+
expect(auth_policy.consumer_secret).to eq('new_consumer_secret')
|
65
|
+
expect(auth_policy.oauth_token).to eq('new_oauth_token')
|
66
|
+
expect(auth_policy.oauth_token_secret).to be_nil
|
70
67
|
end
|
71
68
|
end
|
72
69
|
|
@@ -75,7 +72,7 @@ describe Trello do
|
|
75
72
|
Trello.configure
|
76
73
|
end
|
77
74
|
|
78
|
-
it { Trello.auth_policy.
|
75
|
+
it { expect(Trello.auth_policy).to be_a(AuthPolicy) }
|
79
76
|
it { expect { Trello.client.get(:member) }.to raise_error(Trello::ConfigurationError) }
|
80
77
|
end
|
81
78
|
|
data/spec/webhook_spec.rb
CHANGED
@@ -8,19 +8,25 @@ module Trello
|
|
8
8
|
let(:client) { Client.new }
|
9
9
|
|
10
10
|
before(:each) do
|
11
|
-
client
|
11
|
+
allow(client)
|
12
|
+
.to receive(:get)
|
13
|
+
.with("/webhooks/1234", {})
|
14
|
+
.and_return webhook_payload
|
12
15
|
end
|
13
16
|
|
14
17
|
context "finding" do
|
15
18
|
let(:client) { Trello.client }
|
16
19
|
|
17
20
|
it "delegates to Trello.client#find" do
|
18
|
-
client
|
21
|
+
expect(client)
|
22
|
+
.to receive(:find)
|
23
|
+
.with(:webhook, '1234', {})
|
24
|
+
|
19
25
|
Webhook.find('1234')
|
20
26
|
end
|
21
27
|
|
22
28
|
it "is equivalent to client#find" do
|
23
|
-
Webhook.find('1234').
|
29
|
+
expect(Webhook.find('1234')).to eq(webhook)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
@@ -29,7 +35,7 @@ module Trello
|
|
29
35
|
|
30
36
|
it "creates a new webhook" do
|
31
37
|
webhook = Webhook.new(webhooks_details.first)
|
32
|
-
webhook.
|
38
|
+
expect(webhook).to be_valid
|
33
39
|
end
|
34
40
|
|
35
41
|
it 'creates a new webhook and saves it on Trello', refactor: true do
|
@@ -40,11 +46,14 @@ module Trello
|
|
40
46
|
|
41
47
|
expected_payload = {description: webhook[:description], idModel: webhook[:idModel], callbackURL: webhook[:callbackURL]}
|
42
48
|
|
43
|
-
client
|
49
|
+
expect(client)
|
50
|
+
.to receive(:post)
|
51
|
+
.with("/webhooks", expected_payload)
|
52
|
+
.and_return result
|
44
53
|
|
45
54
|
webhook = Webhook.create(webhooks_details.first)
|
46
55
|
|
47
|
-
webhook.class.
|
56
|
+
expect(webhook.class).to be Webhook
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
@@ -54,7 +63,10 @@ module Trello
|
|
54
63
|
|
55
64
|
expected_payload = {description: expected_new_description, idModel: webhook.id_model, callbackURL: webhook.callback_url, active: webhook.active}
|
56
65
|
|
57
|
-
client
|
66
|
+
expect(client)
|
67
|
+
.to receive(:put)
|
68
|
+
.once
|
69
|
+
.with("/webhooks/#{webhook.id}", expected_payload)
|
58
70
|
|
59
71
|
webhook.description = expected_new_description
|
60
72
|
webhook.save
|
@@ -63,14 +75,17 @@ module Trello
|
|
63
75
|
|
64
76
|
context "deleting" do
|
65
77
|
it "deletes the webhook" do
|
66
|
-
client
|
78
|
+
expect(client)
|
79
|
+
.to receive(:delete)
|
80
|
+
.with("/webhooks/#{webhook.id}")
|
81
|
+
|
67
82
|
webhook.delete
|
68
83
|
end
|
69
84
|
end
|
70
85
|
|
71
86
|
context "activated?" do
|
72
87
|
it "returns the active attribute" do
|
73
|
-
expect(webhook
|
88
|
+
expect(webhook).to be_activated
|
74
89
|
end
|
75
90
|
end
|
76
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-trello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Tregunna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: 1.8.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: 1.8.0
|
83
83
|
description: A wrapper around the trello.com API.
|
84
84
|
email: jeremy@tregunna.ca
|
85
85
|
executables: []
|
@@ -131,7 +131,6 @@ files:
|
|
131
131
|
- spec/integration/how_to_use_boards_spec.rb
|
132
132
|
- spec/integration/integration_test.rb
|
133
133
|
- spec/item_spec.rb
|
134
|
-
- spec/item_state_spec.rb
|
135
134
|
- spec/label_spec.rb
|
136
135
|
- spec/list_spec.rb
|
137
136
|
- spec/member_spec.rb
|
@@ -183,7 +182,6 @@ test_files:
|
|
183
182
|
- spec/integration/how_to_use_boards_spec.rb
|
184
183
|
- spec/integration/integration_test.rb
|
185
184
|
- spec/item_spec.rb
|
186
|
-
- spec/item_state_spec.rb
|
187
185
|
- spec/label_spec.rb
|
188
186
|
- spec/list_spec.rb
|
189
187
|
- spec/member_spec.rb
|
data/spec/item_state_spec.rb
DELETED
File without changes
|