ruby-trello 0.4.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +81 -8
- data/lib/trello.rb +25 -9
- data/lib/trello/action.rb +5 -5
- data/lib/trello/association_proxy.rb +3 -3
- data/lib/trello/authorization.rb +105 -49
- data/lib/trello/basic_data.rb +48 -4
- data/lib/trello/board.rb +10 -9
- data/lib/trello/card.rb +38 -35
- data/lib/trello/checklist.rb +10 -8
- data/lib/trello/client.rb +98 -29
- data/lib/trello/configuration.rb +68 -0
- data/lib/trello/has_actions.rb +1 -1
- data/lib/trello/list.rb +9 -7
- data/lib/trello/member.rb +3 -3
- data/lib/trello/multi_association.rb +4 -2
- data/lib/trello/notification.rb +8 -8
- data/lib/trello/organization.rb +3 -3
- data/lib/trello/token.rb +4 -4
- data/spec/action_spec.rb +30 -18
- data/spec/basic_auth_policy_spec.rb +1 -0
- data/spec/board_spec.rb +141 -120
- data/spec/card_spec.rb +104 -82
- data/spec/checklist_spec.rb +35 -6
- data/spec/client_spec.rb +56 -19
- data/spec/configuration_spec.rb +114 -0
- data/spec/integration/how_to_authorize_spec.rb +1 -1
- data/spec/list_spec.rb +74 -20
- data/spec/member_spec.rb +37 -23
- data/spec/notification_spec.rb +28 -24
- data/spec/oauth_policy_spec.rb +55 -9
- data/spec/organization_spec.rb +18 -7
- data/spec/spec_helper.rb +5 -0
- data/spec/token_spec.rb +25 -8
- data/spec/trello_spec.rb +73 -0
- metadata +10 -6
data/spec/oauth_policy_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
include Trello::Authorization
|
4
3
|
include Trello
|
4
|
+
include Trello::Authorization
|
5
5
|
|
6
6
|
describe OAuthPolicy do
|
7
7
|
before do
|
@@ -9,19 +9,65 @@ describe OAuthPolicy do
|
|
9
9
|
OAuthPolicy.token = nil
|
10
10
|
end
|
11
11
|
|
12
|
+
describe "#consumer_credential" do
|
13
|
+
it "uses class setting if available" do
|
14
|
+
policy = OAuthPolicy.new
|
15
|
+
policy.consumer_credential.key.should eq('xxx')
|
16
|
+
policy.consumer_credential.secret.should eq('xxx')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is built from given consumer_key and consumer_secret" do
|
20
|
+
policy = OAuthPolicy.new(
|
21
|
+
:consumer_key => 'consumer_key',
|
22
|
+
:consumer_secret => 'consumer_secret'
|
23
|
+
)
|
24
|
+
policy.consumer_credential.key.should eq('consumer_key')
|
25
|
+
policy.consumer_credential.secret.should eq('consumer_secret')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "is nil if none supplied to class" do
|
29
|
+
OAuthPolicy.consumer_credential = nil
|
30
|
+
policy = OAuthPolicy.new
|
31
|
+
policy.consumer_credential.should be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#token" do
|
36
|
+
it "uses class setting if available" do
|
37
|
+
OAuthPolicy.token = OAuthCredential.new "xxx", "xxx"
|
38
|
+
policy = OAuthPolicy.new
|
39
|
+
policy.token.key.should eq('xxx')
|
40
|
+
policy.token.secret.should eq('xxx')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "is built from given oauth_token and oauth_token_secret" do
|
44
|
+
policy = OAuthPolicy.new(
|
45
|
+
:oauth_token => 'oauth_token',
|
46
|
+
:oauth_token_secret => 'oauth_token_secret'
|
47
|
+
)
|
48
|
+
policy.token.key.should eq('oauth_token')
|
49
|
+
policy.token.secret.should eq('oauth_token_secret')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "is an empty token if no oauth credentials supplied" do
|
53
|
+
policy = OAuthPolicy.new
|
54
|
+
policy.token.should be_nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
12
58
|
context "2-legged" do
|
13
|
-
it "adds an authorization header" do
|
59
|
+
it "adds an authorization header" do
|
14
60
|
uri = Addressable::URI.parse("https://xxx/")
|
15
61
|
|
16
62
|
request = Request.new :get, uri
|
17
63
|
|
18
|
-
OAuthPolicy.token
|
64
|
+
OAuthPolicy.token = OAuthCredential.new "token", nil
|
19
65
|
|
20
66
|
authorized_request = OAuthPolicy.authorize request
|
21
|
-
|
67
|
+
|
22
68
|
authorized_request.headers.keys.should include "Authorization"
|
23
69
|
end
|
24
|
-
|
70
|
+
|
25
71
|
it "preserves query parameters" do
|
26
72
|
uri = Addressable::URI.parse("https://xxx/?name=Riccardo")
|
27
73
|
request = Request.new :get, uri
|
@@ -32,12 +78,12 @@ describe OAuthPolicy do
|
|
32
78
|
OAuthPolicy.token = OAuthCredential.new "token", nil
|
33
79
|
|
34
80
|
authorized_request = OAuthPolicy.authorize request
|
35
|
-
|
81
|
+
|
36
82
|
the_query_parameters = Addressable::URI.parse(authorized_request.uri).query_values
|
37
83
|
the_query_parameters.should == {"name" => "Riccardo"}
|
38
84
|
end
|
39
85
|
|
40
|
-
it "adds the correct signature as part of authorization header" do
|
86
|
+
it "adds the correct signature as part of authorization header" do
|
41
87
|
Clock.stub(:timestamp).and_return "1327048592"
|
42
88
|
Nonce.stub(:next).and_return "b94ff2bf7f0a5e87a326064ae1dbb18f"
|
43
89
|
|
@@ -47,7 +93,7 @@ describe OAuthPolicy do
|
|
47
93
|
request = Request.new :get, Addressable::URI.parse("http://xxx/")
|
48
94
|
|
49
95
|
authorized_request = OAuthPolicy.authorize request
|
50
|
-
|
96
|
+
|
51
97
|
authorized_request.headers["Authorization"].should =~ /oauth_signature="TVNk%2FCs03FHqutDUqn05%2FDkvVek%3D"/
|
52
98
|
end
|
53
99
|
|
@@ -61,7 +107,7 @@ describe OAuthPolicy do
|
|
61
107
|
request = Request.new :get, Addressable::URI.parse("http://xxx/?a=b")
|
62
108
|
|
63
109
|
authorized_request = OAuthPolicy.authorize request
|
64
|
-
|
110
|
+
|
65
111
|
authorized_request.headers["Authorization"].should =~ /oauth_signature="DprU1bdbNdJQ40UhD4n7wRR9jts%3D"/
|
66
112
|
end
|
67
113
|
|
data/spec/organization_spec.rb
CHANGED
@@ -5,22 +5,33 @@ module Trello
|
|
5
5
|
describe Organization do
|
6
6
|
include Helpers
|
7
7
|
|
8
|
+
let(:organization) { client.find(:organization, "4ee7e59ae582acdec8000291") }
|
9
|
+
let(:client) { Client.new }
|
10
|
+
|
8
11
|
before(:each) do
|
9
|
-
|
12
|
+
client.stub(:get).with("/organizations/4ee7e59ae582acdec8000291").
|
10
13
|
and_return organization_payload
|
14
|
+
end
|
15
|
+
|
16
|
+
context "finding" do
|
17
|
+
let(:client) { Trello.client }
|
18
|
+
|
19
|
+
it "delegates to Trello.client#find" do
|
20
|
+
client.should_receive(:find).with(:organization, '4ee7e59ae582acdec8000291')
|
21
|
+
Organization.find('4ee7e59ae582acdec8000291')
|
22
|
+
end
|
11
23
|
|
12
|
-
|
24
|
+
it "is equivalent to client#find" do
|
25
|
+
Organization.find('4ee7e59ae582acdec8000291').should eq(organization)
|
26
|
+
end
|
13
27
|
end
|
14
28
|
|
15
29
|
context "actions" do
|
16
30
|
it "retrieves actions" do
|
17
|
-
|
18
|
-
|
31
|
+
client.stub(:get).with("/organizations/4ee7e59ae582acdec8000291/actions", { :filter => :all }).and_return actions_payload
|
32
|
+
organization.actions.count.should be > 0
|
19
33
|
end
|
20
|
-
|
21
34
|
end
|
22
|
-
|
23
35
|
end
|
24
|
-
|
25
36
|
end
|
26
37
|
|
data/spec/spec_helper.rb
CHANGED
@@ -26,6 +26,10 @@ Trello.logger = Logger.new($strio)
|
|
26
26
|
|
27
27
|
RSpec.configure do |c|
|
28
28
|
c.filter_run_excluding :broken => true
|
29
|
+
|
30
|
+
c.before :each do
|
31
|
+
Trello.reset!
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
module Helpers
|
@@ -67,6 +71,7 @@ module Helpers
|
|
67
71
|
"closed" => false,
|
68
72
|
"url" => "https://trello.com/blah/blah",
|
69
73
|
"idBoard" => "abcdef123456789123456789",
|
74
|
+
"idList" => "abcdef123456789123456789",
|
70
75
|
"idMembers" => ["abcdef123456789123456789"],
|
71
76
|
"checkItems" => {}
|
72
77
|
}]
|
data/spec/token_spec.rb
CHANGED
@@ -4,30 +4,47 @@ module Trello
|
|
4
4
|
describe Token do
|
5
5
|
include Helpers
|
6
6
|
|
7
|
+
let(:token) { client.find(:token, "1234") }
|
8
|
+
let(:client) { Client.new }
|
9
|
+
|
7
10
|
before(:each) do
|
8
|
-
|
9
|
-
|
11
|
+
client.stub(:get).with("/tokens/1234").and_return token_payload
|
12
|
+
end
|
13
|
+
|
14
|
+
context "finding" do
|
15
|
+
let(:client) { Trello.client }
|
16
|
+
|
17
|
+
it "delegates to Trello.client#find" do
|
18
|
+
client.should_receive(:find).with(:token, '1234')
|
19
|
+
Token.find('1234')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "is equivalent to client#find" do
|
23
|
+
Token.find('1234').should eq(token)
|
24
|
+
end
|
10
25
|
end
|
11
26
|
|
12
27
|
context "attributes" do
|
13
28
|
it "has an id" do
|
14
|
-
|
29
|
+
token.id.should == "4f2c10c7b3eb95a45b294cd5"
|
15
30
|
end
|
16
31
|
|
17
32
|
it "gets its created_at date" do
|
18
|
-
|
33
|
+
token.created_at.should == Time.iso8601("2012-02-03T16:52:23.661Z")
|
19
34
|
end
|
20
35
|
|
21
36
|
it "has a permission grant" do
|
22
|
-
|
37
|
+
token.permissions.count.should be 3
|
23
38
|
end
|
24
39
|
end
|
25
40
|
|
26
41
|
context "members" do
|
27
42
|
it "retrieves the member who authorized the token" do
|
28
|
-
|
29
|
-
|
43
|
+
client.stub(:get).with("/members/abcdef123456789123456789").and_return user_payload
|
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")
|
30
47
|
end
|
31
48
|
end
|
32
49
|
end
|
33
|
-
end
|
50
|
+
end
|
data/spec/trello_spec.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Trello
|
4
|
+
include Trello::Authorization
|
5
|
+
|
6
|
+
describe Trello do
|
7
|
+
|
8
|
+
describe "self.configure" do
|
9
|
+
it "builds auth policy client uses to make requests" do
|
10
|
+
Trello.configure do |config|
|
11
|
+
config.developer_public_key = 'developer_public_key'
|
12
|
+
config.member_token = 'member_token'
|
13
|
+
end
|
14
|
+
|
15
|
+
TInternet.stub(:execute)
|
16
|
+
Trello.auth_policy.should_receive(:authorize)
|
17
|
+
Trello.client.get(:member, params = {})
|
18
|
+
end
|
19
|
+
|
20
|
+
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
|
+
auth_policy = Trello.auth_policy
|
27
|
+
auth_policy.should be_a(BasicAuthPolicy)
|
28
|
+
auth_policy.developer_public_key.should eq('developer_public_key')
|
29
|
+
auth_policy.member_token.should eq('member_token')
|
30
|
+
end
|
31
|
+
|
32
|
+
context "oauth" do
|
33
|
+
before do
|
34
|
+
Trello.configure do |config|
|
35
|
+
config.consumer_key = 'consumer_key'
|
36
|
+
config.consumer_secret = 'consumer_secret'
|
37
|
+
config.oauth_token = 'oauth_token'
|
38
|
+
config.oauth_token_secret = 'oauth_token_secret'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "configures oauth policy" do
|
43
|
+
auth_policy = Trello.auth_policy
|
44
|
+
|
45
|
+
auth_policy.should be_a(OAuthPolicy)
|
46
|
+
auth_policy.consumer_key.should eq('consumer_key')
|
47
|
+
auth_policy.consumer_secret.should eq('consumer_secret')
|
48
|
+
auth_policy.oauth_token.should eq('oauth_token')
|
49
|
+
auth_policy.oauth_token_secret.should eq('oauth_token_secret')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "updates auth policy configuration" do
|
53
|
+
auth_policy = Trello.auth_policy
|
54
|
+
auth_policy.consumer_key.should eq('consumer_key')
|
55
|
+
|
56
|
+
Trello.configure do |config|
|
57
|
+
config.consumer_key = 'new_consumer_key'
|
58
|
+
config.consumer_secret = 'new_consumer_secret'
|
59
|
+
config.oauth_token = 'new_oauth_token'
|
60
|
+
config.oauth_token_secret = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
auth_policy = Trello.auth_policy
|
64
|
+
|
65
|
+
auth_policy.should be_a(OAuthPolicy)
|
66
|
+
auth_policy.consumer_key.should eq('new_consumer_key')
|
67
|
+
auth_policy.consumer_secret.should eq('new_consumer_secret')
|
68
|
+
auth_policy.oauth_token.should eq('new_oauth_token')
|
69
|
+
auth_policy.oauth_token_secret.should be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-trello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.4.4.3
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Jeremy Tregunna
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2013-01-26 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: activemodel
|
@@ -112,6 +111,7 @@ files:
|
|
112
111
|
- lib/trello/card.rb
|
113
112
|
- lib/trello/checklist.rb
|
114
113
|
- lib/trello/client.rb
|
114
|
+
- lib/trello/configuration.rb
|
115
115
|
- lib/trello/has_actions.rb
|
116
116
|
- lib/trello/item.rb
|
117
117
|
- lib/trello/item_state.rb
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- spec/card_spec.rb
|
133
133
|
- spec/checklist_spec.rb
|
134
134
|
- spec/client_spec.rb
|
135
|
+
- spec/configuration_spec.rb
|
135
136
|
- spec/integration/how_to_authorize_spec.rb
|
136
137
|
- spec/integration/how_to_use_boards_spec.rb
|
137
138
|
- spec/integration/integration_test.rb
|
@@ -145,6 +146,7 @@ files:
|
|
145
146
|
- spec/spec_helper.rb
|
146
147
|
- spec/string_spec.rb
|
147
148
|
- spec/token_spec.rb
|
149
|
+
- spec/trello_spec.rb
|
148
150
|
homepage: https://github.com/jeremytregunna/ruby-trello
|
149
151
|
licenses: []
|
150
152
|
|
@@ -187,6 +189,7 @@ test_files:
|
|
187
189
|
- spec/card_spec.rb
|
188
190
|
- spec/checklist_spec.rb
|
189
191
|
- spec/client_spec.rb
|
192
|
+
- spec/configuration_spec.rb
|
190
193
|
- spec/integration/how_to_authorize_spec.rb
|
191
194
|
- spec/integration/how_to_use_boards_spec.rb
|
192
195
|
- spec/integration/integration_test.rb
|
@@ -200,3 +203,4 @@ test_files:
|
|
200
203
|
- spec/spec_helper.rb
|
201
204
|
- spec/string_spec.rb
|
202
205
|
- spec/token_spec.rb
|
206
|
+
- spec/trello_spec.rb
|