ruby-trello 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -55,7 +55,7 @@ module Trello
55
55
  resource = options.delete(:in) || self.class.to_s.split("::").last.downcase.pluralize
56
56
  klass = options.delete(:via) || Trello.const_get(name.to_s.singularize.camelize)
57
57
  params = options.merge(args[0] || {})
58
- resources = Client.get("/#{resource}/#{id}/#{name}", options).json_into(klass)
58
+ resources = Client.get("/#{resource}/#{id}/#{name}", params).json_into(klass)
59
59
  MultiAssociation.new(self, resources).proxy
60
60
  end
61
61
  end
data/lib/trello/card.rb CHANGED
@@ -110,6 +110,25 @@ module Trello
110
110
  })
111
111
  end
112
112
 
113
+ # Move this card to the given list
114
+ def move_to_list(list)
115
+ Client.put("/cards/#{id}/idList", {
116
+ :value => list.id
117
+ })
118
+ end
119
+
120
+ # Add a member to this card
121
+ def add_member(member)
122
+ Client.post("/cards/#{id}/members", {
123
+ :value => member.id
124
+ })
125
+ end
126
+
127
+ # Remove a member from this card
128
+ def remove_member(member)
129
+ Client.delete("/cards/#{id}/members/#{member.id}")
130
+ end
131
+
113
132
  # Retrieve a list of labels
114
133
  def labels
115
134
  labels = Client.get("/cards/#{id}/labels").json_into(Label)
@@ -14,7 +14,7 @@ module Trello
14
14
 
15
15
  def create(options)
16
16
  new('name' => options[:name],
17
- 'idBoard' => options[:board_id]).save!
17
+ 'idBoard' => options[:board_id]).save
18
18
  end
19
19
  end
20
20
 
@@ -50,7 +50,7 @@ module Trello
50
50
  end
51
51
 
52
52
  def update!
53
- Client.put("/checklists", { :name => name }).json_into(self)
53
+ Client.put("/checklists/#{id}", { :name => name }).json_into(self)
54
54
  end
55
55
 
56
56
  # Return a list of items on the checklist.
data/lib/trello/list.rb CHANGED
@@ -15,7 +15,7 @@ module Trello
15
15
 
16
16
  def create(options)
17
17
  new('name' => options[:name],
18
- 'idBoard' => options[:board_id]).save!
18
+ 'idBoard' => options[:board_id]).save
19
19
  end
20
20
  end
21
21
 
data/lib/trello.rb CHANGED
@@ -7,8 +7,20 @@ require 'active_model'
7
7
  #
8
8
  # First, set up your key information. You can get this information by {clicking here}[https://trello.com/1/appKey/generate].
9
9
  #
10
- # Trello.public_key = 'xxxxxxxxxxxxxxxxx'
11
- # Trello.secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
10
+ # include Trello
11
+ # include Trello::Authorization
12
+ #
13
+ # Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
14
+ #
15
+ # OAuthPolicy.consumer_credential = OAuthCredential.new 'PUBLIC_KEY', 'SECRET'
16
+ #
17
+ # You can get the key by going to this url in your browser:
18
+ # https://trello.com/1/connect?key=PUBLIC_KEY_FROM_ABOVE&name=MyApp&response_type=token&scope=read,write,account&expiration=never
19
+ # Only request the permissions you need; i.e., scope=read if you only need read, or scope=write if you only need write. Comma separate scopes you need.
20
+ # If you want your token to expire after 30 days, drop the &expiration=never. Then run the following code, where KEY denotes the key returned from the
21
+ # url above:
22
+ #
23
+ # OAuthPolicy.token = OAuthCredential.new 'KEY', nil
12
24
  #
13
25
  # All the calls this library make to Trello require authentication using these keys. Be sure to protect them.
14
26
  #
data/spec/card_spec.rb CHANGED
@@ -123,6 +123,13 @@ module Trello
123
123
  Client.stub(:get).with("/lists/abcdef123456789123456789").and_return JSON.generate(lists_details.first)
124
124
  @card.list.should_not be_nil
125
125
  end
126
+
127
+ it 'can be moved to another list' do
128
+ other_list = stub(:id => '987654321987654321fedcba')
129
+ payload = {:value => other_list.id}
130
+ Client.should_receive(:put).with("/cards/abcdef123456789123456789/idList", payload)
131
+ @card.move_to_list(other_list)
132
+ end
126
133
  end
127
134
 
128
135
  context "members" do
@@ -133,6 +140,21 @@ module Trello
133
140
  @card.board.should_not be_nil
134
141
  @card.members.should_not be_nil
135
142
  end
143
+
144
+ it "allows a member to be added to a card" do
145
+ new_member = stub(:id => '4ee7df3ce582acdec80000b2')
146
+ payload = {
147
+ :value => new_member.id
148
+ }
149
+ Client.should_receive(:post).with("/cards/abcdef123456789123456789/members", payload)
150
+ @card.add_member(new_member)
151
+ end
152
+
153
+ it "allows a member to be removed from a card" do
154
+ existing_member = stub(:id => '4ee7df3ce582acdec80000b2')
155
+ Client.should_receive(:delete).with("/cards/abcdef123456789123456789/members/#{existing_member.id}")
156
+ @card.remove_member(existing_member)
157
+ end
136
158
  end
137
159
 
138
160
  context "comments" do
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ module Trello
4
+ describe Checklist do
5
+ include Helpers
6
+
7
+ before(:each) do
8
+ Client.stub(:get).with("/checklists/abcdef123456789123456789").
9
+ and_return JSON.generate(checklists_details.first)
10
+
11
+ @checklist = Checklist.find('abcdef123456789123456789')
12
+ end
13
+
14
+ context "creating" do
15
+ it 'creates a new record and saves it on Trello', :refactor => true do
16
+ payload = {
17
+ :name => 'Test Checklist',
18
+ :desc => '',
19
+ }
20
+
21
+ result = JSON.generate(checklists_details.first.merge(payload.merge(:idBoard => boards_details.first['id'])))
22
+
23
+ expected_payload = {:name => "Test Checklist", :idBoard => "abcdef123456789123456789"}
24
+
25
+ Client.should_receive(:post).with("/checklists", expected_payload).and_return result
26
+
27
+ checklist = Checklist.create(checklists_details.first.merge(payload.merge(:board_id => boards_details.first['id'])))
28
+
29
+ checklist.class.should be Checklist
30
+ end
31
+ end
32
+
33
+ context "updating" do
34
+ it "updating name does a put on the correct resource with the correct value" do
35
+ expected_new_name = "xxx"
36
+ expected_resource = "/checklists/#{@checklist.id}"
37
+ payload = {
38
+ :name => expected_new_name
39
+ }
40
+
41
+ result = JSON.generate(checklists_details.first)
42
+ Client.should_receive(:put).once.with("/checklists/abcdef123456789123456789", payload).and_return result
43
+ checklist = @checklist.dup
44
+ checklist.name = expected_new_name
45
+ checklist.save
46
+ end
47
+ end
48
+
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &70222887650260 !ruby/object:Gem::Requirement
16
+ requirement: &70366093754380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70222887650260
24
+ version_requirements: *70366093754380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: addressable
27
- requirement: &70222887648300 !ruby/object:Gem::Requirement
27
+ requirement: &70366093753620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.2.6
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70222887648300
35
+ version_requirements: *70366093753620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rest-client
38
- requirement: &70222887646220 !ruby/object:Gem::Requirement
38
+ requirement: &70366093752440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.7
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70222887646220
46
+ version_requirements: *70366093752440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activemodel
49
- requirement: &70222887645500 !ruby/object:Gem::Requirement
49
+ requirement: &70366093750780 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70222887645500
57
+ version_requirements: *70366093750780
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70222887625140 !ruby/object:Gem::Requirement
60
+ requirement: &70366093749620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70222887625140
68
+ version_requirements: *70366093749620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70222887623700 !ruby/object:Gem::Requirement
71
+ requirement: &70366093747380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.8.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70222887623700
79
+ version_requirements: *70366093747380
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &70222887621880 !ruby/object:Gem::Requirement
82
+ requirement: &70366093746180 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70222887621880
90
+ version_requirements: *70366093746180
91
91
  description: A wrapper around the trello.com API.
92
92
  email: jeremy@tregunna.ca
93
93
  executables: []